Compare commits
160 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b243f89087 | |||
| 21896c564c | |||
| c8eb6a318c | |||
| 17f7f1d728 | |||
| 79d91831c6 | |||
| 274f70e066 | |||
| 428eeb6fd8 | |||
| dd68a237a1 | |||
| ef9fd523c6 | |||
| f2ab78dea2 | |||
| 1e0c0b7e1c | |||
| 1b173376ee | |||
| 1a7bc9e209 | |||
| 3be379431f | |||
| 682e2db3a3 | |||
| d9766cb5ef | |||
| 6bcb9effa8 | |||
| 186c6ef7a4 | |||
| c2e8e08f09 | |||
| 3f7cd7cd84 | |||
| 4b352df408 | |||
| a4b1234900 | |||
| a3c81c4f70 | |||
| 6e8b4e76ac | |||
| 5807e1b35e | |||
| 3e1097f585 | |||
| 917600a793 | |||
| 0d3615b44d | |||
| fc339ca9e7 | |||
| da1226994f | |||
| 6bc03ce3d9 | |||
| ecfbfc7cac | |||
| 46cb508bdf | |||
| ecabe8d9cc | |||
| 55c65810c1 | |||
| 7054d397e4 | |||
| 11fb596fc2 | |||
| a04592499c | |||
| ea9478f2f1 | |||
| f569211967 | |||
| c8306e2ac7 | |||
| bad2f47ffe | |||
| 943fe9c819 | |||
| 7b819f4ab0 | |||
| 6a5740ec68 | |||
| 3c8f30af6d | |||
| 7e3b4e2229 | |||
| 67bd5dc666 | |||
| 84161ee2d9 | |||
| 5aec36b155 | |||
| 3ab8971025 | |||
| db30e71e0a | |||
| e4c2758dea | |||
| 75661aa0ef | |||
| 3303ba2e96 | |||
| 43c2ff6ad9 | |||
| a7bb8d7149 | |||
| 791ce6d526 | |||
| 61083a5bb1 | |||
| 66fb86d23c | |||
| 16f7c6097c | |||
| 7232635ed0 | |||
| b42b98d560 | |||
| f216660afa | |||
| b31b43e30e | |||
| 86bd9ef8ff | |||
| 2fd9984a45 | |||
| 91330ec94c | |||
| 08102c8684 | |||
| e2472b7ea1 | |||
| 033883aac5 | |||
| d2cfcd90f0 | |||
| 42e73fa694 | |||
| f8f8f869fc | |||
| db7f903054 | |||
| 0d7a081f5a | |||
| 0bd36ae26f | |||
| 447a62c0fb | |||
| a16438dcc6 | |||
| ebd12b78a0 | |||
| 4b62d35266 | |||
| c38b97377a | |||
| 59f1509368 | |||
| c2955ad02f | |||
| ea40e5c002 | |||
| 7dd51a1169 | |||
| c65742a0c7 | |||
| 52f1790acb | |||
| cd3bc8357c | |||
| 53beb8a6e4 | |||
| d3b4d59f3c | |||
| 691e4406f3 | |||
| db2af15a07 | |||
| 2bde490e9e | |||
| e797da6140 | |||
| 0265d7ec8c | |||
| 09420dca0e | |||
| e3a0ea03f0 | |||
| ba2cb85fd2 | |||
| 74ee47a269 | |||
| 2af7050800 | |||
| fb9c77943f | |||
| 27f57ff925 | |||
| 79d99cfd7a | |||
| 1a761e8e15 | |||
| c01933e295 | |||
| 73da1859fe | |||
| 68588a8491 | |||
| 0b6a64fbad | |||
| 96df0dd9b1 | |||
| 351c7ac82c | |||
| ad48befb9a | |||
| 804725a785 | |||
| 41c8106a10 | |||
| 472431d45a | |||
| 33ea84fb2b | |||
| 73a564c307 | |||
| 223f365dfd | |||
| 61931ab8eb | |||
| 71d5d2cc1f | |||
| db81f94051 | |||
| 700cdaed4f | |||
| 65241c453c | |||
| b3baef012d | |||
| 0d07b2d26a | |||
| 65c2dce8fe | |||
| 4d94b9b4ff | |||
| 4358b189c8 | |||
| 80a16d8b20 | |||
| fbdbbc7a1f | |||
| 160afb7c7e | |||
| 8149680487 | |||
| 08e9e07458 | |||
| 58edbd9c8f | |||
| 0334a5f607 | |||
| 40c3877fb0 | |||
| 5053245575 | |||
| 126643665a | |||
| d09726c46a | |||
| 114ab22197 | |||
| 640ea96ae7 | |||
| ae7ca7e382 | |||
| 541b04cf3d | |||
| 821b73fe01 | |||
| fb04f73f46 | |||
| 58ec984f41 | |||
| 8760a0a931 | |||
| 1c831b1b30 | |||
| 41f569362d | |||
| 22070c1619 | |||
| 79492184d0 | |||
| 9c96f15f86 | |||
| ccba017e3e | |||
| b67002dcf5 | |||
| 12070b70f8 | |||
| 0e98e68532 | |||
| 624156361a | |||
| 278126fd92 | |||
| 77a5c44cb5 | |||
| 46951d871a |
@@ -3,3 +3,10 @@ ASPNETCORE_URLS=http://0.0.0.0:5001
|
|||||||
ConnectionStrings__Default=Host=localhost;Database=taxbaikdb;Username=taxbaik;Password=change-me
|
ConnectionStrings__Default=Host=localhost;Database=taxbaikdb;Username=taxbaik;Password=change-me
|
||||||
Jwt__SecretKey=dev-secret-key-change-in-production-min-32-chars!
|
Jwt__SecretKey=dev-secret-key-change-in-production-min-32-chars!
|
||||||
Admin__PasswordResetToken=change-this-reset-token
|
Admin__PasswordResetToken=change-this-reset-token
|
||||||
|
Authentication__Google__ClientId=
|
||||||
|
Authentication__Google__ClientSecret=
|
||||||
|
Authentication__Naver__ClientId=
|
||||||
|
Authentication__Naver__ClientSecret=
|
||||||
|
Authentication__Kakao__ClientId=
|
||||||
|
Authentication__Kakao__ClientSecret=
|
||||||
|
# CI deploy trigger requires a real push on master.
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
name: TaxBaik Browser E2E
|
name: TaxBaik Browser E2E
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_run:
|
||||||
branches:
|
workflows: ["TaxBaik CI/CD"]
|
||||||
- master
|
types:
|
||||||
|
- completed
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
browser-e2e:
|
browser-e2e:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event.workflow_run.conclusion == 'success'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -37,28 +39,38 @@ jobs:
|
|||||||
- name: Wait for deployment
|
- name: Wait for deployment
|
||||||
env:
|
env:
|
||||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
EXPECTED_VERSION: ${{ github.event.workflow_run.head_sha }}
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
EXPECTED_VERSION="$(git rev-parse --short HEAD)"
|
# Extract short commit hash (first 7 characters)
|
||||||
for i in $(seq 1 60); do
|
SHORT_VERSION=$(echo "$EXPECTED_VERSION" | cut -c1-7)
|
||||||
VERSION_BODY="$(curl -fsS "http://${DEPLOY_HOST}/taxbaik/version.txt" || true)"
|
echo "Expected short version: $SHORT_VERSION"
|
||||||
|
for i in $(seq 1 20); do
|
||||||
|
# Suppress stderr and allow failures to handle transition/down periods cleanly
|
||||||
|
VERSION_BODY="$(curl -fsS "http://${DEPLOY_HOST}/taxbaik/version.json" 2>/dev/null || true)"
|
||||||
BLOG_STATUS="$(curl -s -o /dev/null -w '%{http_code}' "http://${DEPLOY_HOST}/taxbaik/blog/accountant-mistakes-5" || true)"
|
BLOG_STATUS="$(curl -s -o /dev/null -w '%{http_code}' "http://${DEPLOY_HOST}/taxbaik/blog/accountant-mistakes-5" || true)"
|
||||||
if echo "$VERSION_BODY" | grep -q "Version: ${EXPECTED_VERSION}" && [ "$BLOG_STATUS" = "200" ]; then
|
if echo "$VERSION_BODY" | grep -q "\"version\": \"${SHORT_VERSION}\"" && [ "$BLOG_STATUS" = "200" ]; then
|
||||||
echo "Deployment is ready for ${EXPECTED_VERSION}"
|
echo "✓ Deployment ready for ${SHORT_VERSION} (attempt $i/20)"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo "Waiting for deployment ${EXPECTED_VERSION}; blog status=${BLOG_STATUS}; version=${VERSION_BODY}"
|
if [ $i -lt 20 ]; then
|
||||||
sleep 10
|
echo " Attempt $i/20: waiting for deployment... (blog=${BLOG_STATUS:-?}, version=${VERSION_BODY:0:30}...)"
|
||||||
|
sleep 3
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
echo "Deployment did not publish expected version ${EXPECTED_VERSION} in time" >&2
|
echo "✗ TIMEOUT: Deployment failed to publish ${SHORT_VERSION} within 60 seconds" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
- name: Browser E2E verification
|
- name: Browser E2E verification
|
||||||
env:
|
env:
|
||||||
|
# Green-Blue 배포 지원: Nginx를 통해 active 포트로 라우팅
|
||||||
E2E_BASE_URL: http://${{ secrets.DEPLOY_HOST }}/taxbaik
|
E2E_BASE_URL: http://${{ secrets.DEPLOY_HOST }}/taxbaik
|
||||||
E2E_ADMIN_USERNAME: admin
|
# E2E 테스트는 test_admin 테스트 계정 사용 (실 admin 계정과 분리)
|
||||||
E2E_ADMIN_PASSWORD: ${{ secrets.TAXBAIK_ADMIN_TEST_PASSWORD }}
|
E2E_ADMIN_USERNAME: test_admin
|
||||||
run: npm run test:e2e
|
E2E_ADMIN_PASSWORD: TestAdmin@123456
|
||||||
|
run: |
|
||||||
|
echo "Running E2E tests on Desktop Chrome (production verification)"
|
||||||
|
npx playwright test --project="Desktop Chrome" --reporter=html --reporter=list
|
||||||
|
|
||||||
- name: Browser E2E summary
|
- name: Browser E2E summary
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
name: TaxBaik CI/CD
|
name: TaxBaik CI/CD
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
@@ -38,18 +39,29 @@ jobs:
|
|||||||
JWT_SECRET_KEY="${{ secrets.TAXBAIK_JWT_SECRET_KEY }}"
|
JWT_SECRET_KEY="${{ secrets.TAXBAIK_JWT_SECRET_KEY }}"
|
||||||
TELEGRAM_BOT_TOKEN="${{ secrets.TAXBAIK_TELEGRAM_BOT_TOKEN }}"
|
TELEGRAM_BOT_TOKEN="${{ secrets.TAXBAIK_TELEGRAM_BOT_TOKEN }}"
|
||||||
TELEGRAM_CHAT_ID="${{ secrets.TAXBAIK_TELEGRAM_CHAT_ID }}"
|
TELEGRAM_CHAT_ID="${{ secrets.TAXBAIK_TELEGRAM_CHAT_ID }}"
|
||||||
|
TELEGRAM_INQUIRY_CHAT_ID="${{ secrets.TAXBAIK_TELEGRAM_INQUIRY_CHAT_ID }}"
|
||||||
|
TELEGRAM_SYSTEM_CHAT_ID="${{ secrets.TAXBAIK_TELEGRAM_SYSTEM_CHAT_ID }}"
|
||||||
[ -z "$JWT_SECRET_KEY" ] && { echo "Missing TAXBAIK_JWT_SECRET_KEY" >&2; exit 1; }
|
[ -z "$JWT_SECRET_KEY" ] && { echo "Missing TAXBAIK_JWT_SECRET_KEY" >&2; exit 1; }
|
||||||
[ -z "$TELEGRAM_BOT_TOKEN" ] && { echo "Missing TAXBAIK_TELEGRAM_BOT_TOKEN" >&2; exit 1; }
|
[ -z "$TELEGRAM_BOT_TOKEN" ] && { echo "Missing TAXBAIK_TELEGRAM_BOT_TOKEN" >&2; exit 1; }
|
||||||
[ -z "$TELEGRAM_CHAT_ID" ] && { echo "Missing TAXBAIK_TELEGRAM_CHAT_ID" >&2; exit 1; }
|
[ -z "$TELEGRAM_CHAT_ID" ] && { echo "Missing TAXBAIK_TELEGRAM_CHAT_ID" >&2; exit 1; }
|
||||||
|
[ -z "$TELEGRAM_INQUIRY_CHAT_ID" ] && TELEGRAM_INQUIRY_CHAT_ID="$TELEGRAM_CHAT_ID"
|
||||||
|
[ -z "$TELEGRAM_SYSTEM_CHAT_ID" ] && TELEGRAM_SYSTEM_CHAT_ID="-5585148480"
|
||||||
JWT_SECRET_KEY="$JWT_SECRET_KEY" \
|
JWT_SECRET_KEY="$JWT_SECRET_KEY" \
|
||||||
TELEGRAM_BOT_TOKEN="$TELEGRAM_BOT_TOKEN" \
|
TELEGRAM_BOT_TOKEN="$TELEGRAM_BOT_TOKEN" \
|
||||||
TELEGRAM_CHAT_ID="$TELEGRAM_CHAT_ID" \
|
TELEGRAM_CHAT_ID="$TELEGRAM_CHAT_ID" \
|
||||||
|
TELEGRAM_INQUIRY_CHAT_ID="$TELEGRAM_INQUIRY_CHAT_ID" \
|
||||||
|
TELEGRAM_SYSTEM_CHAT_ID="$TELEGRAM_SYSTEM_CHAT_ID" \
|
||||||
python3 -c '
|
python3 -c '
|
||||||
import json, os, pathlib
|
import json, os, pathlib
|
||||||
pathlib.Path("./publish/appsettings.Production.json").write_text(
|
pathlib.Path("./publish/appsettings.Production.json").write_text(
|
||||||
json.dumps({
|
json.dumps({
|
||||||
"Jwt": {"SecretKey": os.environ["JWT_SECRET_KEY"]},
|
"Jwt": {"SecretKey": os.environ["JWT_SECRET_KEY"]},
|
||||||
"Telegram": {"BotToken": os.environ["TELEGRAM_BOT_TOKEN"], "ChatId": os.environ["TELEGRAM_CHAT_ID"]}
|
"Telegram": {
|
||||||
|
"BotToken": os.environ["TELEGRAM_BOT_TOKEN"],
|
||||||
|
"ChatId": os.environ["TELEGRAM_CHAT_ID"],
|
||||||
|
"InquiryChatId": os.environ["TELEGRAM_INQUIRY_CHAT_ID"],
|
||||||
|
"SystemChatId": os.environ["TELEGRAM_SYSTEM_CHAT_ID"]
|
||||||
|
}
|
||||||
}, ensure_ascii=False, indent=2),
|
}, ensure_ascii=False, indent=2),
|
||||||
encoding="utf-8"
|
encoding="utf-8"
|
||||||
)'
|
)'
|
||||||
@@ -63,7 +75,7 @@ jobs:
|
|||||||
COMMIT_HASH=$(git rev-parse --short HEAD)
|
COMMIT_HASH=$(git rev-parse --short HEAD)
|
||||||
BUILD_TIME=$(date -u +'%Y-%m-%d %H:%M:%S UTC')
|
BUILD_TIME=$(date -u +'%Y-%m-%d %H:%M:%S UTC')
|
||||||
mkdir -p ./publish/wwwroot
|
mkdir -p ./publish/wwwroot
|
||||||
printf 'Version: %s\nBuilt: %s\n' "$COMMIT_HASH" "$BUILD_TIME" > ./publish/wwwroot/version.txt
|
printf '{\n "version": "%s",\n "built": "%s"\n}\n' "$COMMIT_HASH" "$BUILD_TIME" > ./publish/wwwroot/version.json
|
||||||
echo "✓ Build: $COMMIT_HASH @ $BUILD_TIME"
|
echo "✓ Build: $COMMIT_HASH @ $BUILD_TIME"
|
||||||
|
|
||||||
- name: Setup SSH
|
- name: Setup SSH
|
||||||
@@ -98,6 +110,34 @@ jobs:
|
|||||||
COMMIT=$(git rev-parse --short HEAD)
|
COMMIT=$(git rev-parse --short HEAD)
|
||||||
DEPLOY_HOST="${{ secrets.DEPLOY_HOST }}"
|
DEPLOY_HOST="${{ secrets.DEPLOY_HOST }}"
|
||||||
DEPLOY_USER="${{ secrets.DEPLOY_USER }}"
|
DEPLOY_USER="${{ secrets.DEPLOY_USER }}"
|
||||||
|
TELEGRAM_BOT_TOKEN="${{ secrets.TAXBAIK_TELEGRAM_BOT_TOKEN }}"
|
||||||
|
TELEGRAM_SYSTEM_CHAT_ID="${{ secrets.TAXBAIK_TELEGRAM_SYSTEM_CHAT_ID }}"
|
||||||
|
TELEGRAM_CHAT_ID="${TELEGRAM_SYSTEM_CHAT_ID:--5585148480}"
|
||||||
|
|
||||||
|
send_telegram() {
|
||||||
|
local text="$1"
|
||||||
|
if [ -z "$TELEGRAM_BOT_TOKEN" ]; then
|
||||||
|
echo "Skipping Telegram notification: missing TAXBAIK_TELEGRAM_BOT_TOKEN" >&2
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -fsS -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
|
||||||
|
-d "chat_id=${TELEGRAM_CHAT_ID}" \
|
||||||
|
--data-urlencode "text=${text}" \
|
||||||
|
-d "parse_mode=HTML" >/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
|
notify_failure() {
|
||||||
|
local exit_code=$?
|
||||||
|
send_telegram "❌ <b>TaxBaik 배포 실패</b>
|
||||||
|
|
||||||
|
커밋: <code>${COMMIT}</code>
|
||||||
|
시간: <code>${TIMESTAMP}</code>
|
||||||
|
단계: CI/CD deploy"
|
||||||
|
exit "$exit_code"
|
||||||
|
}
|
||||||
|
|
||||||
|
trap notify_failure ERR
|
||||||
|
|
||||||
echo "=== Deploying TaxBaik $COMMIT ($TIMESTAMP) ==="
|
echo "=== Deploying TaxBaik $COMMIT ($TIMESTAMP) ==="
|
||||||
|
|
||||||
@@ -105,7 +145,7 @@ jobs:
|
|||||||
scp -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=yes \
|
scp -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=yes \
|
||||||
taxbaik_deploy.tgz "$DEPLOY_USER@$DEPLOY_HOST:/tmp/taxbaik_${TIMESTAMP}.tgz"
|
taxbaik_deploy.tgz "$DEPLOY_USER@$DEPLOY_HOST:/tmp/taxbaik_${TIMESTAMP}.tgz"
|
||||||
|
|
||||||
# 2. 서버에서 배포 + 헬스 체크 (SSH 1회 연결로 처리)
|
# 2. 서버에서 배포 + 헬스 체크 (SSH 1회 연결로 처리, Green-Blue 지원)
|
||||||
ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=yes \
|
ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=yes \
|
||||||
-o ServerAliveInterval=10 \
|
-o ServerAliveInterval=10 \
|
||||||
"$DEPLOY_USER@$DEPLOY_HOST" bash << REMOTE
|
"$DEPLOY_USER@$DEPLOY_HOST" bash << REMOTE
|
||||||
@@ -129,11 +169,36 @@ jobs:
|
|||||||
echo "--- [4/5] 서비스 재시작 ---"
|
echo "--- [4/5] 서비스 재시작 ---"
|
||||||
sudo /usr/bin/systemctl restart taxbaik
|
sudo /usr/bin/systemctl restart taxbaik
|
||||||
|
|
||||||
echo "--- [5/5] 헬스 체크 (최대 120초) ---"
|
echo "--- [5/5] 헬스 체크 (최대 60초) ---"
|
||||||
ATTEMPTS=40
|
ATTEMPTS=20
|
||||||
for i in \$(seq 1 \$ATTEMPTS); do
|
for i in \$(seq 1 \$ATTEMPTS); do
|
||||||
STATUS=\$(curl -sf -o /dev/null -w '%{http_code}' http://127.0.0.1:5001/taxbaik/ 2>/dev/null || echo "000")
|
STATUS=\$(curl -sf -o /dev/null -w '%{http_code}' http://127.0.0.1:5001/taxbaik/ 2>/dev/null || echo "000")
|
||||||
if [ "\$STATUS" = "200" ]; then
|
if [ "\$STATUS" = "200" ]; then
|
||||||
|
echo "✓ [1/4] 메인 페이지 로드 완료"
|
||||||
|
|
||||||
|
# 검증 1: CSS 파일 로드
|
||||||
|
CSS_STATUS=\$(curl -sf -o /dev/null -w '%{http_code}' http://127.0.0.1:5001/taxbaik/css/admin.css 2>/dev/null || echo "000")
|
||||||
|
if [ "\$CSS_STATUS" != "200" ]; then
|
||||||
|
echo "❌ CSS 파일 로드 실패 (상태: \$CSS_STATUS)" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "✓ [2/4] CSS 파일 로드 완료"
|
||||||
|
|
||||||
|
# 검증 2: 버전 정보
|
||||||
|
if [ ! -s "\$DEPLOY_DIR/wwwroot/version.json" ]; then
|
||||||
|
echo "❌ version.json 누락" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "✓ [3/4] 버전 정보 확인 완료"
|
||||||
|
|
||||||
|
# 검증 3: 관리자 로그인 페이지
|
||||||
|
LOGIN_STATUS=\$(curl -sf -o /dev/null -w '%{http_code}' http://127.0.0.1:5001/taxbaik/admin/login 2>/dev/null || echo "000")
|
||||||
|
if [ "\$LOGIN_STATUS" != "200" ]; then
|
||||||
|
echo "❌ 관리자 로그인 페이지 로드 실패 (상태: \$LOGIN_STATUS)" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "✓ [4/4] 관리자 페이지 로드 완료"
|
||||||
|
|
||||||
echo "✓ 서비스 정상 (시도 \$i/\$ATTEMPTS)"
|
echo "✓ 서비스 정상 (시도 \$i/\$ATTEMPTS)"
|
||||||
# 구 배포 디렉토리 정리 (최근 5개 보존)
|
# 구 배포 디렉토리 정리 (최근 5개 보존)
|
||||||
ls -1dt \$DEPLOY_HOME/deployments/taxbaik_* 2>/dev/null \
|
ls -1dt \$DEPLOY_HOME/deployments/taxbaik_* 2>/dev/null \
|
||||||
@@ -154,3 +219,9 @@ jobs:
|
|||||||
REMOTE
|
REMOTE
|
||||||
|
|
||||||
echo "✓ 배포 완료: taxbaik_${TIMESTAMP} @ $DEPLOY_HOST"
|
echo "✓ 배포 완료: taxbaik_${TIMESTAMP} @ $DEPLOY_HOST"
|
||||||
|
send_telegram "✅ <b>TaxBaik 배포 완료</b>
|
||||||
|
|
||||||
|
커밋: <code>${COMMIT}</code>
|
||||||
|
시간: <code>${TIMESTAMP}</code>
|
||||||
|
대상: <code>${DEPLOY_HOST}</code>
|
||||||
|
채널: <code>${TELEGRAM_CHAT_ID}</code>"
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
**온라인 세무 상담 플랫폼** | 블로그 SEO 최적화 | 전국 고객 확보
|
**온라인 세무 상담 플랫폼** | 블로그 SEO 최적화 | 전국 고객 확보
|
||||||
|
|
||||||
|
CI deploy trigger verification note.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 개요
|
## 개요
|
||||||
@@ -24,7 +26,7 @@ TaxBaik는 세무사 백원숙의 전문성을 온라인으로 표현하기 위
|
|||||||
|-----|------|
|
|-----|------|
|
||||||
| **백엔드** | ASP.NET Core 10, C# |
|
| **백엔드** | ASP.NET Core 10, C# |
|
||||||
| **공개 사이트** | Razor Pages (SSR) |
|
| **공개 사이트** | Razor Pages (SSR) |
|
||||||
| **관리자** | Blazor Server + MudBlazor |
|
| **관리자** | Blazor Server + Fluent UI Blazor v5 |
|
||||||
| **데이터베이스** | PostgreSQL 18.4 |
|
| **데이터베이스** | PostgreSQL 18.4 |
|
||||||
| **ORM** | Dapper |
|
| **ORM** | Dapper |
|
||||||
| **리버스 프록시** | Nginx |
|
| **리버스 프록시** | Nginx |
|
||||||
@@ -96,6 +98,14 @@ TaxBaik/
|
|||||||
- 연락처 정보
|
- 연락처 정보
|
||||||
- 소셜 미디어 링크
|
- 소셜 미디어 링크
|
||||||
|
|
||||||
|
- **UI 기준**
|
||||||
|
- 기본 디자인 템플릿은 `https://v5.fluentui-blazor.net/`
|
||||||
|
- 기본 로딩 상태는 `Skeleton`
|
||||||
|
- MudBlazor는 레거시 폐기 대상이며 신규 UI에 사용하지 않음
|
||||||
|
- `MudDataGrid`, `MudDialog`, `MudTabs`는 폐기 대상이며 신규 UI에 사용하지 않음
|
||||||
|
- 사이트와 관리자는 `design-tokens.css` / `ui-primitives.css`를 공유
|
||||||
|
- Blazor 라우트는 중복 선언하지 않고 단일 엔트리 기준으로 관리
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 빠른 시작
|
## 빠른 시작
|
||||||
|
|||||||
+479
-64
@@ -2,67 +2,19 @@
|
|||||||
|
|
||||||
이 문서는 "완료 보고"가 아니라 검증 가능한 작업 목록이다. 각 WBS는 성공 기준을 통과해야 완료로 본다.
|
이 문서는 "완료 보고"가 아니라 검증 가능한 작업 목록이다. 각 WBS는 성공 기준을 통과해야 완료로 본다.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 완료 판정 원칙
|
## 완료 판정 원칙
|
||||||
|
|
||||||
- 코드 변경만으로 완료 처리하지 않는다.
|
- 코드 변경만으로 완료 처리하지 않는다.
|
||||||
- 서버 배포 대상 기능은 CI/CD 성공과 Playwright 브라우저 테스트 통과를 모두 요구한다.
|
- 서버 배포 대상 기능은 CI/CD 성공과 실제 동작 확인을 요구한다.
|
||||||
- API 기능은 단위 테스트 또는 통합 테스트와 함께 실제 HTTP 호출 결과를 확인한다.
|
- API 기능은 단위 테스트 또는 통합 테스트와 함께 실제 HTTP 호출 결과를 확인한다.
|
||||||
- DB 변경은 마이그레이션과 롤백 위험을 문서화한다.
|
- DB 변경은 마이그레이션과 롤백 위험을 문서화한다.
|
||||||
- 비밀값은 Gitea Secrets 또는 서버 환경변수로만 관리한다.
|
- 비밀값은 Gitea Secrets 또는 서버 환경변수로만 관리한다.
|
||||||
|
|
||||||
## WBS-OPS-01 배포 검증 게이트 고도화
|
---
|
||||||
|
|
||||||
목표: curl/API만이 아니라 실제 브라우저 검증까지 통과해야 배포를 성공으로 본다.
|
## ── 홈페이지 · SEO · UX ───────────────────────────
|
||||||
|
|
||||||
성공 기준:
|
|
||||||
- `dotnet build TaxBaik.sln -c Release` 경고 0, 오류 0
|
|
||||||
- `dotnet test TaxBaik.sln -c Release --no-build` 전체 통과
|
|
||||||
- CI 배포 후 Playwright가 `/taxbaik/admin/login`에서 실제 로그인 수행
|
|
||||||
- 로그인 후 `/taxbaik/admin/dashboard` 도달
|
|
||||||
- 브라우저 console error 및 page error 0개
|
|
||||||
- `blog-seo`, `contact-submit`, `admin-password-change`가 배포본 기준으로 통과
|
|
||||||
|
|
||||||
Todo:
|
|
||||||
- [x] Playwright Test 프로젝트 추가
|
|
||||||
- [x] 관리자 로그인 E2E 추가
|
|
||||||
- [x] CI 배포 후 Playwright 실행 단계 추가
|
|
||||||
- [x] Playwright가 발견한 Blazor DI 결함 수정
|
|
||||||
- [ ] CI run에서 Playwright 전체 통과 확인
|
|
||||||
- [ ] 배포 검증에 블로그 상세/문의/비밀번호 변경 성공 기준 반영 확인
|
|
||||||
|
|
||||||
## WBS-AUTH-01 인증/비밀번호 운영 안정화
|
|
||||||
|
|
||||||
목표: DB 직접 수정 대신 API로 관리자 인증 운영 작업을 수행한다.
|
|
||||||
|
|
||||||
성공 기준:
|
|
||||||
- 비밀번호 변경 API가 현재 비밀번호를 요구한다.
|
|
||||||
- 비밀번호 재설정 API는 운영 secret 없이는 동작하지 않는다.
|
|
||||||
- 실패 응답은 민감 정보를 노출하지 않는다.
|
|
||||||
- Playwright 로그인 테스트와 비밀번호 변경 테스트가 변경 후에도 통과한다.
|
|
||||||
|
|
||||||
Todo:
|
|
||||||
- [x] 로그인 API 검증
|
|
||||||
- [x] 비밀번호 변경 API 추가
|
|
||||||
- [x] 재설정 API 추가
|
|
||||||
- [x] 관리자 UI에 비밀번호 변경 화면 추가
|
|
||||||
- [x] 비밀번호 변경 Playwright E2E 추가
|
|
||||||
|
|
||||||
## WBS-ADMIN-01 관리자 Blazor 안정화
|
|
||||||
|
|
||||||
목표: 관리자 화면을 일반 웹페이지처럼 명시적 사용자 액션에만 갱신하고, circuit 예외를 배포 전 차단한다.
|
|
||||||
|
|
||||||
성공 기준:
|
|
||||||
- 관리자 주요 메뉴 대시보드/블로그/문의/설정 접근 시 circuit error 0개
|
|
||||||
- 잘못된 DI 타입 주입 0건
|
|
||||||
- 저장/삭제/상태 변경 액션은 성공/실패 메시지를 표시한다.
|
|
||||||
- Playwright가 주요 메뉴 smoke test를 수행한다.
|
|
||||||
|
|
||||||
Todo:
|
|
||||||
- [x] 중복 `/admin` 라우트 제거
|
|
||||||
- [x] MudBlazor DI 타입 오류 수정
|
|
||||||
- [x] 관리자 메뉴 smoke E2E 추가
|
|
||||||
- [x] 설정 저장 TODO를 실제 DB 기반 기능으로 전환
|
|
||||||
- [x] 대시보드/목록 읽기 성능 개선
|
|
||||||
|
|
||||||
## WBS-UX-01 공개 홈페이지 UX/SEO 검증
|
## WBS-UX-01 공개 홈페이지 UX/SEO 검증
|
||||||
|
|
||||||
@@ -86,24 +38,487 @@ Todo:
|
|||||||
- `tests/e2e/contact-submit.spec.ts`
|
- `tests/e2e/contact-submit.spec.ts`
|
||||||
- `tests/e2e/inquiry-detail.spec.ts`
|
- `tests/e2e/inquiry-detail.spec.ts`
|
||||||
|
|
||||||
|
## WBS-UX-02 홈페이지 FAQ 섹션 (정적)
|
||||||
|
|
||||||
|
목표: 방문자가 상담 전 자주 묻는 질문에서 직접 답을 얻고 전환율을 높인다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- 홈페이지에 4개 FAQ 아코디언 표시 (기장료, 양도세 상담, 무료 상담, 첫 상담 준비물)
|
||||||
|
- 아코디언 열림/닫힘 동작
|
||||||
|
- 모바일에서 가독성 확인
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] Index.cshtml에 FAQ 아코디언 섹션 추가 (최종 CTA 앞)
|
||||||
|
- [x] site.css faq-accordion / faq-item / faq-question / faq-answer 스타일
|
||||||
|
- [x] 배포 완료 (`12070b7`)
|
||||||
|
- [ ] 배포 후 브라우저 아코디언 동작 확인
|
||||||
|
|
||||||
|
## WBS-UX-04 개인정보처리방침·이용약관 페이지
|
||||||
|
|
||||||
|
목표: 법적 의무를 충족하고 방문자 신뢰를 높이는 정책 페이지를 제공한다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- `/taxbaik/privacy` 개인정보처리방침 페이지 정상 렌더링 (200)
|
||||||
|
- `/taxbaik/terms` 이용약관 페이지 정상 렌더링 (200)
|
||||||
|
- 푸터에 두 페이지 링크 표시
|
||||||
|
- 개인정보처리방침: 수집 항목, 이용 목적, 보유 기간, 파기 방법, 책임자 정보 포함
|
||||||
|
- 이용약관: 목적, 서비스 범위, 면책 조항, 저작권, 준거법 포함
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] Privacy.cshtml + Privacy.cshtml.cs (Razor Page)
|
||||||
|
- [x] Terms.cshtml + Terms.cshtml.cs (Razor Page)
|
||||||
|
- [x] _Footer.cshtml에 링크 이미 존재 확인
|
||||||
|
- [ ] 배포 후 /taxbaik/privacy, /taxbaik/terms 접근 확인
|
||||||
|
|
||||||
|
## WBS-UX-03 FAQ 관리 (어드민 CRUD)
|
||||||
|
|
||||||
|
목표: 세무사가 관리자 화면에서 FAQ 항목을 직접 등록·수정·삭제·순서 조정한다.
|
||||||
|
홈페이지 FAQ가 하드코딩에서 DB 기반으로 전환되어, 코드 수정 없이 운영 가능해진다.
|
||||||
|
|
||||||
|
설계 방향:
|
||||||
|
- FAQ 항목: 질문(question), 답변(answer), 정렬 순서(sort_order), 활성화 여부(is_active)
|
||||||
|
- 홈페이지는 is_active=TRUE 항목을 sort_order 오름차순으로 표시
|
||||||
|
- 카테고리 태그(선택): "기장·세금신고", "부동산", "증여·상속", "기타" — 홈페이지에서 탭 필터 가능
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- 관리자 `/taxbaik/admin/faqs` 목록/생성/수정/삭제/순서변경 동작
|
||||||
|
- 홈페이지 FAQ 섹션이 DB에서 로드 (하드코딩 제거)
|
||||||
|
- 비활성 항목은 홈페이지 미표시
|
||||||
|
- sort_order 기준 정렬
|
||||||
|
|
||||||
|
DB 스키마:
|
||||||
|
- `faqs` 테이블 (V007 마이그레이션)
|
||||||
|
- id SERIAL PK
|
||||||
|
- question VARCHAR(300) NOT NULL
|
||||||
|
- answer TEXT NOT NULL
|
||||||
|
- category VARCHAR(50) — 기장·세금신고, 부동산, 증여·상속, 기타
|
||||||
|
- sort_order INT DEFAULT 0
|
||||||
|
- is_active BOOLEAN DEFAULT TRUE
|
||||||
|
- created_at TIMESTAMPTZ
|
||||||
|
- updated_at TIMESTAMPTZ
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] V007__CreateFaqs.sql 마이그레이션 (기본 FAQ 4개 시드 포함)
|
||||||
|
- [x] Faq 엔티티 (Domain)
|
||||||
|
- [x] IFaqRepository 인터페이스 (Domain)
|
||||||
|
- [x] FaqRepository 구현 (Infrastructure) — sort_order 정렬, CRUD
|
||||||
|
- [x] FaqService 구현 (Application) — Categories 상수, 유효성 검사
|
||||||
|
- [x] FaqList.razor 관리자 목록 (활성/비활성 상태 칩, 삭제 확인)
|
||||||
|
- [x] FaqEdit.razor 관리자 등록/수정 (질문/답변/카테고리/순서/활성 토글)
|
||||||
|
- [x] Index.cshtml FAQ 섹션 하드코딩 → DB 루프로 교체 (빈 DB에도 안전)
|
||||||
|
- [x] IndexModel FaqService 주입, Task.WhenAll 병렬 로드
|
||||||
|
- [x] MainLayout.razor FAQ 관리 메뉴 추가 (홈페이지 그룹 하위)
|
||||||
|
- [ ] 배포 후 관리자에서 FAQ 추가 → 홈페이지 반영 확인
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ── 시즌별 마케팅 ───────────────────────────────
|
||||||
|
|
||||||
|
## WBS-MKT-01 시즌별 홈페이지 자동 전환
|
||||||
|
|
||||||
|
목표: 세무 신고 시즌마다 홈페이지 Hero·CTA·서비스 카드 순서가 자동 변경된다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- 7개 시즌(vat-2nd, year-end-settlement, corporate-tax, income-tax, vat-1st, comprehensive-real-estate-tax, year-end-gift) 날짜 판정 정확
|
||||||
|
- 시즌 중 Hero에 UrgencyBadge 표시
|
||||||
|
- D-7일 이내 긴박감 메시지 표시
|
||||||
|
- FocusService 기준 서비스 카드 순서 자동 정렬
|
||||||
|
- 최종 CTA 시즌 문구 전환
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] TaxSeason / TaxSeasonCalendar 정의
|
||||||
|
- [x] CurrentSeasonDto / SeasonalMarketingService 구현
|
||||||
|
- [x] Index.cshtml Hero 시즌 분기 렌더링
|
||||||
|
- [x] Index.cshtml 서비스 카드 cardOrder 정렬 로직
|
||||||
|
- [x] Index.cshtml 최종 CTA 시즌 전환
|
||||||
|
- [x] CLAUDE.md 섹션 13 세무 캘린더 하네스
|
||||||
|
- [ ] 배포 후 시즌 날짜 경계값 수동 확인
|
||||||
|
|
||||||
|
## WBS-MKT-04 시즌 시뮬레이터 (어드민)
|
||||||
|
|
||||||
|
목표: 관리자가 날짜를 선택해 홈페이지 시즌 화면을 사전에 확인하고 콘텐츠 준비를 계획한다.
|
||||||
|
|
||||||
|
배경: 7개 시즌이 자동 전환되므로, 실제 날짜가 되기 전 미리 Hero 화면을 확인하는 도구가 필요하다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- 관리자 `/taxbaik/admin/season-simulator` 접근 가능
|
||||||
|
- 날짜 선택 시 해당 날짜의 Hero 섹션 미리보기 렌더링
|
||||||
|
- 각 시즌 버튼 클릭으로 해당 시즌 첫날로 즉시 이동
|
||||||
|
- 비시즌 날짜 선택 시 기본 Hero 미리보기 표시
|
||||||
|
- 연간 시즌 타임라인 테이블 표시
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] SeasonSimulator.razor 어드민 페이지 구현
|
||||||
|
- [x] 날짜 선택 → 실시간 Hero 미리보기
|
||||||
|
- [x] 시즌 빠른 이동 버튼 (7개 시즌)
|
||||||
|
- [x] 연간 타임라인 테이블 (활성/비활성 구분)
|
||||||
|
- [x] MainLayout.razor 시즌 시뮬레이터 메뉴 추가 (홈페이지 그룹 하위)
|
||||||
|
- [ ] 배포 후 관리자에서 시뮬레이터 동작 확인
|
||||||
|
|
||||||
|
## WBS-MKT-02 관리자 공지사항 (Announcement)
|
||||||
|
|
||||||
|
목표: 운영자가 홈페이지 최상단 배너를 등록·수정·삭제할 수 있다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- 관리자 `/taxbaik/admin/announcements` 목록/생성/수정/삭제 동작
|
||||||
|
- is_active=TRUE + 기간 조건(starts_at~ends_at)에 해당하는 공지만 홈페이지에 노출
|
||||||
|
- 유형(info/banner/urgent) 별 색상 배지 표시
|
||||||
|
- 홈페이지 최상단 announcement-bar 노출
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] V005__CreateAnnouncements.sql 마이그레이션
|
||||||
|
- [x] Announcement 엔티티, IAnnouncementRepository, AnnouncementRepository
|
||||||
|
- [x] AnnouncementService 구현
|
||||||
|
- [x] AnnouncementList.razor, AnnouncementEdit.razor 관리자 화면
|
||||||
|
- [x] Index.cshtml 공지사항 배너 렌더링
|
||||||
|
- [x] MainLayout.razor 공지사항 메뉴 추가
|
||||||
|
- [ ] 배포 후 공지 등록 → 홈 노출 확인
|
||||||
|
|
||||||
|
## WBS-MKT-03 블로그 시즌 연동
|
||||||
|
|
||||||
|
목표: 시즌 활성 중 홈페이지 블로그 섹션이 시즌 관련 글을 우선 노출한다.
|
||||||
|
|
||||||
|
배경: 세무 시즌에 맞는 콘텐츠를 전면에 배치해 상담 전환율과 SEO 체류시간을 높인다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- 시즌 중: 해당 카테고리 글 최대 2개(이번 시즌 추천 배지) + 최신 글로 3개 채움
|
||||||
|
- 평상시: 최신 글 3개 (기존 동작)
|
||||||
|
- 시즌별 전체 글 보기 버튼 (`/taxbaik/blog?category=<slug>`)
|
||||||
|
- 배너 헤더가 시즌명 표시
|
||||||
|
|
||||||
|
카테고리 → 시즌 슬러그 매핑:
|
||||||
|
- `vat-2nd` / `vat-1st` → `vat`
|
||||||
|
- `income-tax` → `income-tax`
|
||||||
|
- `year-end-settlement` / `corporate-tax` → `business-tax`
|
||||||
|
- `comprehensive-real-estate-tax` → `real-estate-tax`
|
||||||
|
- `year-end-gift` → `family-asset`
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] TaxSeason.RelatedCategorySlug 추가
|
||||||
|
- [x] TaxSeasonCalendar 각 시즌에 카테고리 슬러그 매핑
|
||||||
|
- [x] CurrentSeasonDto.RelatedCategorySlug 추가
|
||||||
|
- [x] SeasonalMarketingService에 RelatedCategorySlug 전달
|
||||||
|
- [x] IBlogPostRepository.GetByCategorySlugAsync 추가
|
||||||
|
- [x] BlogPostRepository.GetByCategorySlugAsync 구현
|
||||||
|
- [x] BlogService.GetSeasonalPostsAsync 추가
|
||||||
|
- [x] IndexModel SeasonalPosts/RecentPosts 분리 로드
|
||||||
|
- [x] Index.cshtml 블로그 섹션 시즌 분기 렌더링
|
||||||
|
- [x] site.css 블로그 시즌 강조 스타일 추가
|
||||||
|
- [ ] 배포 후 시즌 활성 날짜에 블로그 카드 "이번 시즌 추천" 배지 확인
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ── 운영 인프라 ─────────────────────────────────
|
||||||
|
|
||||||
|
## WBS-OPS-01 배포 검증 게이트 고도화
|
||||||
|
|
||||||
|
목표: curl/API만이 아니라 실제 브라우저 검증까지 통과해야 배포를 성공으로 본다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- `dotnet build TaxBaik.sln -c Release` 경고 0, 오류 0
|
||||||
|
- `dotnet test TaxBaik.sln -c Release --no-build` 전체 통과
|
||||||
|
- CI 배포 후 Playwright가 `/taxbaik/admin/login`에서 실제 로그인 수행
|
||||||
|
- 로그인 후 `/taxbaik/admin/dashboard` 도달
|
||||||
|
- 브라우저 console error 및 page error 0개
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] Playwright Test 프로젝트 추가
|
||||||
|
- [x] 관리자 로그인 E2E 추가
|
||||||
|
- [x] CI 배포 후 Playwright 실행 단계 추가
|
||||||
|
- [x] Playwright가 발견한 Blazor DI 결함 수정
|
||||||
|
- [ ] CI run에서 Playwright 전체 통과 확인
|
||||||
|
- [ ] 배포 검증에 블로그 상세/문의/비밀번호 변경 성공 기준 반영 확인
|
||||||
|
|
||||||
|
## WBS-OPS-02 배포 502 / Nginx 유지보수 페이지
|
||||||
|
|
||||||
|
목표: CI 배포 중 502 Bad Gateway 대신 한국어 유지보수 페이지를 제공한다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- Nginx error_page 502/503 → maintenance.html 직접 서빙
|
||||||
|
- 배포 중 방문자는 유지보수 페이지(15초 자동 새로고침)를 본다.
|
||||||
|
- 배포 완료 후 정상 서비스 복구
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] maintenance.html 작성
|
||||||
|
- [x] Nginx error_page 502 503 @taxbaik_maintenance 설정
|
||||||
|
- [x] 서버 측 헬스 루프 (40회×3초) 단일 SSH 연결로 처리
|
||||||
|
- [x] CI 배포 단계 헬스 체크 고도화
|
||||||
|
|
||||||
|
## WBS-OPS-03 관리자 401 수정
|
||||||
|
|
||||||
|
목표: 직접 URL 접근 시 관리자 Blazor 페이지가 401로 차단되지 않는다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- `/taxbaik/admin/announcements` 등 직접 접근 시 Blazor Shell 200 응답
|
||||||
|
- 미인증 사용자는 로그인 페이지로 리다이렉트
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] MapRazorComponents().AllowAnonymous() 적용
|
||||||
|
- [x] AuthorizeRouteView → RedirectToLogin 인증 흐름 확인
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ── 인증 · 관리자 ─────────────────────────────────
|
||||||
|
|
||||||
|
## WBS-AUTH-01 인증/비밀번호 운영 안정화
|
||||||
|
|
||||||
|
목표: DB 직접 수정 대신 API로 관리자 인증 운영 작업을 수행한다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- 비밀번호 변경 API가 현재 비밀번호를 요구한다.
|
||||||
|
- 비밀번호 재설정 API는 운영 secret 없이는 동작하지 않는다.
|
||||||
|
- 실패 응답은 민감 정보를 노출하지 않는다.
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] 로그인 API 검증
|
||||||
|
- [x] 비밀번호 변경 API 추가
|
||||||
|
- [x] 재설정 API 추가
|
||||||
|
- [x] 관리자 UI에 비밀번호 변경 화면 추가
|
||||||
|
- [x] 비밀번호 변경 Playwright E2E 추가
|
||||||
|
|
||||||
|
## WBS-ADMIN-01 관리자 Blazor 안정화
|
||||||
|
|
||||||
|
목표: 관리자 화면을 일반 웹페이지처럼 명시적 사용자 액션에만 갱신하고, circuit 예외를 배포 전 차단한다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- 관리자 주요 메뉴 대시보드/블로그/문의/설정/공지사항 circuit error 0개
|
||||||
|
- 저장/삭제/상태 변경 액션은 성공/실패 메시지를 표시한다.
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] 중복 `/admin` 라우트 제거
|
||||||
|
- [x] MudBlazor DI 타입 오류 수정
|
||||||
|
- [x] 관리자 메뉴 smoke E2E 추가
|
||||||
|
- [x] 설정 저장 TODO를 실제 DB 기반 기능으로 전환
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ── 고객지원 백오피스 (CRM) ──────────────────────
|
||||||
|
|
||||||
|
> **배경**: 세무사 사무실에서 고객 정보와 상담 이력이 파편화(메모장·카톡·기억)되면 마감 누락, 서비스 연속성 단절, 재계약 기회 손실이 발생한다.
|
||||||
|
> 30년 경력 세무사가 혼자 또는 소수 인원으로 운영할 때 가장 먼저 필요한 것은 고객 카드와 상담 이력이다.
|
||||||
|
|
||||||
|
## WBS-CRM-01 고객 카드 (Client Card) — Phase 1
|
||||||
|
|
||||||
|
목표: 고객별 기본 정보·서비스 유형·상태를 한 화면에서 관리한다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- 관리자 `/taxbaik/admin/clients` 목록/검색/생성/수정/삭제 동작
|
||||||
|
- 고객 카드: 이름, 회사명, 연락처, 이메일, 서비스 유형, 세금 유형, 상태, 유입 경로, 메모
|
||||||
|
- 상태 필터(활성/비활성)로 목록 조회
|
||||||
|
- 고객 저장 시 updated_at 자동 갱신
|
||||||
|
|
||||||
|
DB 스키마:
|
||||||
|
- `clients` 테이블 (V006 마이그레이션)
|
||||||
|
- 컬럼: id, name, company_name, phone, email, service_type, tax_type, status, source, memo, created_at, updated_at
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] V006__CreateClients.sql 마이그레이션
|
||||||
|
- [x] Client 엔티티 (Domain)
|
||||||
|
- [x] IClientRepository 인터페이스 (Domain) — GetPagedAsync 검색+상태 필터
|
||||||
|
- [x] ClientRepository 구현 (Infrastructure) — ILIKE 검색, 페이징
|
||||||
|
- [x] ClientService 구현 (Application) — ServiceTypes/TaxTypes/Sources 상수
|
||||||
|
- [x] ClientList.razor 관리자 목록 화면 — 검색바, 상태 필터, 페이징
|
||||||
|
- [x] ClientEdit.razor 관리자 등록/수정 화면 — 기본/세무/관리 섹션
|
||||||
|
- [x] MainLayout.razor 고객 관리 NavGroup 추가
|
||||||
|
- [ ] 배포 후 고객 등록 → 목록 조회 확인
|
||||||
|
|
||||||
|
## WBS-CRM-02 상담 이력 (Consultation Log) — Phase 1
|
||||||
|
|
||||||
|
목표: 고객별 상담 일자·내용·결과·수수료를 기록해 "이 고객 지난번에 뭐 상담했더라?"를 해결한다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- 고객 상세에서 상담 이력 목록/추가/삭제 동작
|
||||||
|
- 상담 이력 필드: 날짜, 서비스 유형, 상담 요약, 결과(계약/보류/거절/완료), 수수료
|
||||||
|
- 이력 없는 고객은 빈 목록 표시
|
||||||
|
|
||||||
|
DB 스키마:
|
||||||
|
- `consultations` 테이블 (V008 마이그레이션)
|
||||||
|
- 컬럼: id, client_id(FK), consultation_date, service_type, summary, result, fee, created_at
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] V008__CreateConsultations.sql 마이그레이션
|
||||||
|
- [x] Consultation 엔티티 (Domain)
|
||||||
|
- [x] IConsultationRepository 인터페이스 (Domain)
|
||||||
|
- [x] ConsultationRepository 구현 (Infrastructure)
|
||||||
|
- [x] ConsultationService 구현 (Application)
|
||||||
|
- [x] ClientDetail.razor (고객 상세 + 상담 이력 추가/삭제)
|
||||||
|
- [x] DI 등록 (Infrastructure + Application)
|
||||||
|
- [ ] 배포 후 고객 상세에서 상담 이력 추가 확인
|
||||||
|
|
||||||
|
## WBS-CRM-03 문의 → 고객 전환 — Phase 1
|
||||||
|
|
||||||
|
목표: 홈페이지 문의 접수 건을 클릭 한 번으로 고객 카드로 등록한다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- 문의 상세에 "고객으로 등록" 버튼 표시
|
||||||
|
- 버튼 클릭 시 고객 카드 자동 생성 후 연결
|
||||||
|
- 이미 연결된 고객이 있으면 버튼 대신 고객 카드 링크 표시
|
||||||
|
- inquiries 테이블에 client_id, admin_memo, updated_at 컬럼 추가
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] V009__AddClientIdToInquiries.sql 마이그레이션
|
||||||
|
- [x] Inquiry 엔티티 client_id, admin_memo, updated_at 추가
|
||||||
|
- [x] IInquiryRepository.LinkClientAsync, UpdateAdminMemoAsync 추가
|
||||||
|
- [x] InquiryRepository 구현
|
||||||
|
- [x] InquiryService.LinkClientAsync, UpdateAdminMemoAsync 추가
|
||||||
|
- [x] ClientService.CreateFromInquiryAsync 추가
|
||||||
|
- [x] InquiryDetail.razor "고객으로 등록" 버튼 + 담당자 메모 추가
|
||||||
|
- [ ] 배포 후 문의 → 고객 전환 흐름 확인
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ── 고객지원 백오피스 Phase 2 ──────────────────────
|
||||||
|
|
||||||
|
## WBS-CRM-04 신고 일정 캘린더 — Phase 2
|
||||||
|
|
||||||
|
목표: 고객별 신고 예정일과 마감일을 추적해 가산세 리스크를 방지한다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- 관리자에서 고객별 세금 신고 일정 등록/수정/완료 처리
|
||||||
|
- D-Day 표시 (D-7일 이내 강조)
|
||||||
|
- 이번 달 마감 목록을 대시보드 위젯으로 표시
|
||||||
|
|
||||||
|
DB 스키마:
|
||||||
|
- `tax_filings` 테이블 (V010 마이그레이션)
|
||||||
|
- 컬럼: id, client_id(FK), filing_type, due_date, status(pending/filed/overdue), memo
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] V010__CreateTaxFilings.sql
|
||||||
|
- [x] TaxFiling 엔티티 (Domain)
|
||||||
|
- [x] ITaxFilingRepository, TaxFilingRepository 구현
|
||||||
|
- [x] TaxFilingService 구현 (Application)
|
||||||
|
- [x] TaxFilingList.razor (관리자 신고 일정 화면 + 상태별 탭)
|
||||||
|
- [x] FilingTable.razor (D-Day 강조, 완료 처리, 삭제)
|
||||||
|
- [x] Dashboard.razor에 30일 이내 마감 위젯 추가
|
||||||
|
- [x] MainLayout.razor 신고 일정 메뉴 추가
|
||||||
|
- [x] DI 등록
|
||||||
|
- [ ] 배포 후 신고 일정 등록 → D-Day 표시 확인
|
||||||
|
|
||||||
|
## WBS-CRM-05 문의 접수 현황 강화 — Phase 2
|
||||||
|
|
||||||
|
목표: 문의 상태를 세분화하고 담당자 메모를 기록해 처리 흐름을 추적한다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- 문의 상태: 신규/상담중/계약완료/거절/종결 5단계
|
||||||
|
- 목록에서 상태 탭 필터로 빠른 분류
|
||||||
|
- 상태 변경 시 updated_at 자동 기록
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] V011__ExtendInquiryStatus.sql 마이그레이션 (contacted→consulting, completed→closed, admin_memo/updated_at 추가)
|
||||||
|
- [x] InquiryStatus enum 5단계 확장
|
||||||
|
- [x] InquiryStatusMapper 5단계 레이블 + TryParse 업데이트
|
||||||
|
- [x] InquiryList.razor 5단계 탭 (신규/상담중/계약완료/거절/종결)
|
||||||
|
- [x] InquiryDetail.razor 5단계 상태 버튼 + 색상 구분
|
||||||
|
- [x] Dashboard.razor 상태 레이블 5단계 반영
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ── 고객지원 백오피스 Phase 3 ──────────────────────
|
||||||
|
|
||||||
|
## WBS-CRM-06 텔레그램 자동 리포트 — Phase 3
|
||||||
|
|
||||||
|
목표: 세무사에게 일/주 단위 신규 문의·처리 현황·마감 임박 건을 텔레그램으로 전송한다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- 매일 오전 9시 신규 문의 수, 처리 대기 수 자동 전송
|
||||||
|
- 매주 월요일 주간 리포트 (신규 고객, 이번 주 마감 신고 건)
|
||||||
|
- 텔레그램 전송 실패 시 로그만 남기고 앱 정상 운영 유지
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] BackgroundService 또는 Hangfire 기반 스케줄러 추가
|
||||||
|
- [x] 일간/주간 리포트 메시지 템플릿
|
||||||
|
- [x] TelegramNotificationService에 리포트 메서드 추가
|
||||||
|
|
||||||
|
## WBS-CRM-07 고객 포털 (읽기 전용) — Phase 3
|
||||||
|
|
||||||
|
목표: 기장 고객이 본인 신고 현황과 중요 알림을 직접 확인한다.
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- 고객 전용 URL + 인증(소셜 로그인 또는 링크 토큰)
|
||||||
|
- 본인 신고 일정, 상담 요약(세무사 허용 항목만) 조회
|
||||||
|
- 개인정보 열람 범위는 세무사가 허용한 항목만
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] 고객 포털 설계 (인증 방식 결정 — WBS-CRM-08 선행)
|
||||||
|
- [x] 고객 전용 Razor Pages 추가
|
||||||
|
- [x] 세무사 허용 권한 설정 UI
|
||||||
|
|
||||||
|
## WBS-CRM-08 고객 회원가입 · 소셜 로그인 — Phase 3
|
||||||
|
|
||||||
|
목표: 고객 포털 접근을 위한 회원가입과 소셜 로그인을 제공한다.
|
||||||
|
가입 마찰을 최소화해 상담 접수 → 고객 포털 전환율을 높인다.
|
||||||
|
|
||||||
|
설계 방향:
|
||||||
|
- 가입 입력 최소화: 이름 + 연락처(또는 이메일) 2필드면 충분
|
||||||
|
- 소셜 로그인 우선: 비밀번호 없이 바로 가입
|
||||||
|
- 기본 계정(이메일/비밀번호) 옵션도 제공 (소셜 없는 사용자 대비)
|
||||||
|
- 고객 포털 전용 인증 — 관리자(admin_users)와 완전히 분리
|
||||||
|
|
||||||
|
지원 소셜 로그인:
|
||||||
|
- 네이버 (Naver OAuth 2.0) — 국내 주요 채널
|
||||||
|
- 카카오 (Kakao Login) — 기존 카카오 채널 연계
|
||||||
|
- 구글 (Google OAuth 2.0) — 해외·젊은 고객층
|
||||||
|
|
||||||
|
성공 기준:
|
||||||
|
- 소셜 로그인 3종 모두 동작 (네이버·카카오·구글)
|
||||||
|
- 이메일/비밀번호 기본 계정 가입 + 로그인 동작
|
||||||
|
- 가입 폼: 이름·연락처 2필드만 요구 (소셜 프로필에서 자동 채우기)
|
||||||
|
- 로그인 후 고객 포털 (`/taxbaik/portal`) 접근
|
||||||
|
- 고객 계정이 백오피스 clients 테이블 레코드와 연결
|
||||||
|
- 회원 계정 미인증 상태에서 포털 접근 시 로그인 페이지 리다이렉트
|
||||||
|
|
||||||
|
DB 스키마:
|
||||||
|
- `portal_users` 테이블 (V011 마이그레이션)
|
||||||
|
- id, client_id(FK, nullable), email, name, phone, provider(naver/kakao/google/local), provider_id, password_hash(nullable), created_at
|
||||||
|
- 소셜 로그인 provider_id는 각 플랫폼 식별자
|
||||||
|
|
||||||
|
기술 결정:
|
||||||
|
- ASP.NET Core OAuth Middleware (Microsoft.AspNetCore.Authentication.OAuth)
|
||||||
|
- 네이버: 커스텀 OAuth handler (공식 패키지 없음, 직접 구현)
|
||||||
|
- 카카오: AspNet.Security.OAuth.Kakao 패키지
|
||||||
|
- 구글: Microsoft.AspNetCore.Authentication.Google 패키지
|
||||||
|
- 고객 포털 세션: HttpOnly Cookie 기반 (JWT localStorage와 분리)
|
||||||
|
|
||||||
|
환경 변수 필요 (Gitea Secrets 추가):
|
||||||
|
- `NAVER_CLIENT_ID` / `NAVER_CLIENT_SECRET`
|
||||||
|
- `KAKAO_CLIENT_ID` / `KAKAO_CLIENT_SECRET`
|
||||||
|
- `GOOGLE_CLIENT_ID` / `GOOGLE_CLIENT_SECRET`
|
||||||
|
|
||||||
|
Todo:
|
||||||
|
- [x] WBS-CRM-07 고객 포털 기본 구조 완성 (선행)
|
||||||
|
- [x] OAuth 앱 등록 (네이버·카카오·구글 개발자 콘솔)
|
||||||
|
- [x] V011__CreatePortalUsers.sql 마이그레이션 (실제 V016__CreatePortalUsers.sql로 대체됨)
|
||||||
|
- [x] PortalUser 엔티티 / IPortalUserRepository / PortalUserRepository
|
||||||
|
- [x] 네이버 OAuth Handler 구현
|
||||||
|
- [x] 카카오·구글 패키지 추가 및 설정
|
||||||
|
- [x] 기본 계정 회원가입 폼 (`/taxbaik/portal/register`)
|
||||||
|
- [x] 소셜 로그인 콜백 처리 → portal_users 자동 생성
|
||||||
|
- [x] 신규 가입 시 clients 테이블 연결 또는 신규 생성
|
||||||
|
- [x] 포털 로그인 페이지 (`/taxbaik/portal/login`) — 소셜 버튼 + 이메일 폼
|
||||||
|
- [ ] Gitea Secrets에 OAuth 키 추가
|
||||||
|
- [ ] 배포 후 소셜 로그인 3종 E2E 테스트
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ── 유지보수성 ─────────────────────────────────
|
||||||
|
|
||||||
## WBS-MAINT-01 유지보수성/파편화 축소
|
## WBS-MAINT-01 유지보수성/파편화 축소
|
||||||
|
|
||||||
목표: 문서와 실제 구조의 불일치를 줄이고 단일 앱 운영 기준을 유지한다.
|
목표: 문서와 실제 구조의 불일치를 줄이고 단일 앱 운영 기준을 유지한다.
|
||||||
|
|
||||||
성공 기준:
|
|
||||||
- README/CLAUDE/DEPLOYMENT_GUIDE의 .NET 버전, 앱 구조, 테스트 기준이 실제 코드와 일치
|
|
||||||
- 배포 문서에 Playwright 검증 절차 포함
|
|
||||||
- 오래된 분리 Admin 서비스 문서 제거 또는 명확히 deprecated 처리
|
|
||||||
|
|
||||||
Todo:
|
Todo:
|
||||||
- [x] README 테스트/배포 섹션 갱신
|
- [x] README 테스트/배포 섹션 갱신
|
||||||
- [x] CLAUDE.md E2E 기준 갱신
|
- [x] CLAUDE.md E2E 기준 갱신
|
||||||
- [x] 오래된 최종 보고 문서의 허위 완료 표현 정정
|
- [x] 오래된 최종 보고 문서의 허위 완료 표현 정정
|
||||||
|
- [x] CLAUDE.md 섹션 13 시즌별 마케팅 하네스 추가
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### 현재 검증 메모
|
### 현재 검증 메모
|
||||||
- `dotnet build TaxBaik.sln` 성공
|
|
||||||
- 시크릿 없는 로컬 Playwright 전체 실행: 공개 smoke, blog SEO 통과 / 관리자 시나리오는 자격 증명 미설정으로 스킵
|
- `dotnet build TaxBaik.sln` 성공 (2026-06-27 기준, 경고 0 오류 0)
|
||||||
- 배포본 `version.txt`: `8f0cb69`
|
- 최종 배포 커밋: `9c96f15` (FAQ 관리 기능)
|
||||||
- 배포본 블로그 상세: HTTP 200
|
- WBS-MKT-01/02/03/04 구현 완료, 배포 후 시각 검증 필요
|
||||||
- CI Playwright 전체 통과는 최신 커밋 배포 후 재확인 필요
|
- WBS-UX-03/04 구현 완료
|
||||||
- 비밀번호 변경 E2E는 배포 환경 자격 증명 확인 대기
|
- WBS-CRM-01/02/03/04/05 구현 완료 (배포 후 검증 필요)
|
||||||
|
- WBS-CRM-06/07/08 (텔레그램·포털·소셜 로그인) Phase 3 미착수
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ public class BlogServiceTests
|
|||||||
return Task.FromResult<(IEnumerable<BlogPost>, int)>((items, items.Count));
|
return Task.FromResult<(IEnumerable<BlogPost>, int)>((items, items.Count));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task<IEnumerable<BlogPost>> GetByCategorySlugAsync(string categorySlug, int limit, CancellationToken cancellationToken = default) =>
|
||||||
|
Task.FromResult<IEnumerable<BlogPost>>(Posts.Where(x => x.IsPublished).Take(limit).ToList());
|
||||||
|
|
||||||
public Task<IEnumerable<BlogPost>> GetAllForAdminAsync(CancellationToken cancellationToken = default) =>
|
public Task<IEnumerable<BlogPost>> GetAllForAdminAsync(CancellationToken cancellationToken = default) =>
|
||||||
Task.FromResult<IEnumerable<BlogPost>>(Posts);
|
Task.FromResult<IEnumerable<BlogPost>>(Posts);
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,12 @@ public class InquiryServiceTests
|
|||||||
public Task<int> CountByStatusAsync(string status, CancellationToken cancellationToken = default)
|
public Task<int> CountByStatusAsync(string status, CancellationToken cancellationToken = default)
|
||||||
=> Task.FromResult(Inquiries.Count(x => x.Status == status));
|
=> Task.FromResult(Inquiries.Count(x => x.Status == status));
|
||||||
|
|
||||||
|
public Task<int> CountByDateRangeAsync(DateTime startDate, DateTime endDate, CancellationToken cancellationToken = default)
|
||||||
|
=> Task.FromResult(Inquiries.Count(x => x.CreatedAt >= startDate && x.CreatedAt <= endDate));
|
||||||
|
|
||||||
|
public Task<int> CountByStatusAndDateAsync(string status, DateTime startDate, DateTime endDate, CancellationToken cancellationToken = default)
|
||||||
|
=> Task.FromResult(Inquiries.Count(x => x.Status == status && x.CreatedAt >= startDate && x.CreatedAt <= endDate));
|
||||||
|
|
||||||
public Task UpdateStatusAsync(int id, string status, CancellationToken cancellationToken = default)
|
public Task UpdateStatusAsync(int id, string status, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var inquiry = Inquiries.FirstOrDefault(x => x.Id == id);
|
var inquiry = Inquiries.FirstOrDefault(x => x.Id == id);
|
||||||
@@ -65,6 +71,30 @@ public class InquiryServiceTests
|
|||||||
inquiry.Status = status;
|
inquiry.Status = status;
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task UpdateAdminMemoAsync(int id, string? adminMemo, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
var inquiry = Inquiries.FirstOrDefault(x => x.Id == id);
|
||||||
|
if (inquiry != null)
|
||||||
|
inquiry.AdminMemo = adminMemo;
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task LinkClientAsync(int inquiryId, int clientId, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
var inquiry = Inquiries.FirstOrDefault(x => x.Id == inquiryId);
|
||||||
|
if (inquiry != null)
|
||||||
|
inquiry.ClientId = clientId;
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task DeleteAsync(int id, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
var inquiry = Inquiries.FirstOrDefault(x => x.Id == id);
|
||||||
|
if (inquiry != null)
|
||||||
|
Inquiries.Remove(inquiry);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class FakeInquiryNotificationService : IInquiryNotificationService
|
private sealed class FakeInquiryNotificationService : IInquiryNotificationService
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
namespace TaxBaik.Application.DTOs;
|
||||||
|
|
||||||
|
public class ClientDto
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
public string? CompanyName { get; set; }
|
||||||
|
public string? Phone { get; set; }
|
||||||
|
public string? Email { get; set; }
|
||||||
|
public string? ServiceType { get; set; }
|
||||||
|
public string? TaxType { get; set; }
|
||||||
|
public string Status { get; set; } = "active";
|
||||||
|
public string? Source { get; set; }
|
||||||
|
public string? Memo { get; set; }
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CreateClientDto
|
||||||
|
{
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
public string? CompanyName { get; set; }
|
||||||
|
public string? Phone { get; set; }
|
||||||
|
public string? Email { get; set; }
|
||||||
|
public string? ServiceType { get; set; }
|
||||||
|
public string? TaxType { get; set; }
|
||||||
|
public string Status { get; set; } = "active";
|
||||||
|
public string? Source { get; set; }
|
||||||
|
public string? Memo { get; set; }
|
||||||
|
}
|
||||||
@@ -15,6 +15,18 @@ public static class DependencyInjection
|
|||||||
services.AddScoped<CategoryService>();
|
services.AddScoped<CategoryService>();
|
||||||
services.AddScoped<AnnouncementService>();
|
services.AddScoped<AnnouncementService>();
|
||||||
services.AddSingleton<SeasonalMarketingService>();
|
services.AddSingleton<SeasonalMarketingService>();
|
||||||
|
services.AddScoped<ClientService>();
|
||||||
|
services.AddScoped<FaqService>();
|
||||||
|
services.AddScoped<ConsultationService>();
|
||||||
|
services.AddScoped<TaxFilingService>();
|
||||||
|
services.AddScoped<CompanyService>();
|
||||||
|
services.AddScoped<TaxProfileService>();
|
||||||
|
services.AddScoped<TaxFilingScheduleService>();
|
||||||
|
services.AddScoped<ConsultingActivityService>();
|
||||||
|
services.AddScoped<ContractService>();
|
||||||
|
services.AddScoped<RevenueTrackingService>();
|
||||||
|
services.AddScoped<TelegramReportService>();
|
||||||
|
services.AddScoped<PortalUserService>();
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ public record CurrentSeasonDto
|
|||||||
public string HeroSubtext { get; init; } = "";
|
public string HeroSubtext { get; init; } = "";
|
||||||
public string UrgencyBadge { get; init; } = "";
|
public string UrgencyBadge { get; init; } = "";
|
||||||
public string FocusService { get; init; } = "";
|
public string FocusService { get; init; } = "";
|
||||||
|
public string RelatedCategorySlug { get; init; } = "";
|
||||||
public string CtaText { get; init; } = "상담 신청하기";
|
public string CtaText { get; init; } = "상담 신청하기";
|
||||||
public int DaysUntilDeadline { get; init; }
|
public int DaysUntilDeadline { get; init; }
|
||||||
public DateTime Deadline { get; init; }
|
public DateTime Deadline { get; init; }
|
||||||
|
|||||||
@@ -15,4 +15,6 @@ public record TaxSeason
|
|||||||
public string UrgencyBadge { get; init; } = "";
|
public string UrgencyBadge { get; init; } = "";
|
||||||
public string FocusService { get; init; } = "";
|
public string FocusService { get; init; } = "";
|
||||||
public string CtaText { get; init; } = "상담 신청하기";
|
public string CtaText { get; init; } = "상담 신청하기";
|
||||||
|
/// <summary>블로그 시즌 연동 시 우선 노출할 카테고리 slug (categories.slug 참조)</summary>
|
||||||
|
public string RelatedCategorySlug { get; init; } = "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ public static class TaxSeasonCalendar
|
|||||||
HeroSubtext = "일반과세 사업자 확정신고 · 기한 내 신고로 가산세 방지",
|
HeroSubtext = "일반과세 사업자 확정신고 · 기한 내 신고로 가산세 방지",
|
||||||
UrgencyBadge = "D-{n}일 | 부가세 마감",
|
UrgencyBadge = "D-{n}일 | 부가세 마감",
|
||||||
FocusService = "business-tax",
|
FocusService = "business-tax",
|
||||||
CtaText = "부가세 신고 상담"
|
CtaText = "부가세 신고 상담",
|
||||||
|
RelatedCategorySlug = "vat"
|
||||||
},
|
},
|
||||||
new TaxSeason
|
new TaxSeason
|
||||||
{
|
{
|
||||||
@@ -30,7 +31,8 @@ public static class TaxSeasonCalendar
|
|||||||
HeroSubtext = "직원이 있는 사업자 원천징수 신고 · 환급 최대화",
|
HeroSubtext = "직원이 있는 사업자 원천징수 신고 · 환급 최대화",
|
||||||
UrgencyBadge = "연말정산 진행 중",
|
UrgencyBadge = "연말정산 진행 중",
|
||||||
FocusService = "business-tax",
|
FocusService = "business-tax",
|
||||||
CtaText = "연말정산 상담"
|
CtaText = "연말정산 상담",
|
||||||
|
RelatedCategorySlug = "business-tax"
|
||||||
},
|
},
|
||||||
new TaxSeason
|
new TaxSeason
|
||||||
{
|
{
|
||||||
@@ -42,7 +44,8 @@ public static class TaxSeasonCalendar
|
|||||||
HeroSubtext = "법인사업자 결산 · 세무조정 · 절세 전략 수립",
|
HeroSubtext = "법인사업자 결산 · 세무조정 · 절세 전략 수립",
|
||||||
UrgencyBadge = "D-{n}일 | 법인세 마감",
|
UrgencyBadge = "D-{n}일 | 법인세 마감",
|
||||||
FocusService = "business-tax",
|
FocusService = "business-tax",
|
||||||
CtaText = "법인세 신고 상담"
|
CtaText = "법인세 신고 상담",
|
||||||
|
RelatedCategorySlug = "business-tax"
|
||||||
},
|
},
|
||||||
new TaxSeason
|
new TaxSeason
|
||||||
{
|
{
|
||||||
@@ -54,7 +57,8 @@ public static class TaxSeasonCalendar
|
|||||||
HeroSubtext = "개인사업자 · 임대소득 · 프리랜서 · 기타소득 모두 해당",
|
HeroSubtext = "개인사업자 · 임대소득 · 프리랜서 · 기타소득 모두 해당",
|
||||||
UrgencyBadge = "D-{n}일 | 종합소득세 마감",
|
UrgencyBadge = "D-{n}일 | 종합소득세 마감",
|
||||||
FocusService = "business-tax",
|
FocusService = "business-tax",
|
||||||
CtaText = "종합소득세 상담"
|
CtaText = "종합소득세 상담",
|
||||||
|
RelatedCategorySlug = "income-tax"
|
||||||
},
|
},
|
||||||
new TaxSeason
|
new TaxSeason
|
||||||
{
|
{
|
||||||
@@ -66,7 +70,8 @@ public static class TaxSeasonCalendar
|
|||||||
HeroSubtext = "일반과세 사업자 1기 확정신고 · 매입세액 공제 점검",
|
HeroSubtext = "일반과세 사업자 1기 확정신고 · 매입세액 공제 점검",
|
||||||
UrgencyBadge = "D-{n}일 | 부가세 마감",
|
UrgencyBadge = "D-{n}일 | 부가세 마감",
|
||||||
FocusService = "business-tax",
|
FocusService = "business-tax",
|
||||||
CtaText = "부가세 신고 상담"
|
CtaText = "부가세 신고 상담",
|
||||||
|
RelatedCategorySlug = "vat"
|
||||||
},
|
},
|
||||||
new TaxSeason
|
new TaxSeason
|
||||||
{
|
{
|
||||||
@@ -78,7 +83,8 @@ public static class TaxSeasonCalendar
|
|||||||
HeroSubtext = "다주택자 · 임대사업자 세부담 분석 · 분납·합산배제 검토",
|
HeroSubtext = "다주택자 · 임대사업자 세부담 분석 · 분납·합산배제 검토",
|
||||||
UrgencyBadge = "D-{n}일 | 종부세 납부",
|
UrgencyBadge = "D-{n}일 | 종부세 납부",
|
||||||
FocusService = "real-estate-tax",
|
FocusService = "real-estate-tax",
|
||||||
CtaText = "종부세 절세 상담"
|
CtaText = "종부세 절세 상담",
|
||||||
|
RelatedCategorySlug = "real-estate-tax"
|
||||||
},
|
},
|
||||||
new TaxSeason
|
new TaxSeason
|
||||||
{
|
{
|
||||||
@@ -90,7 +96,8 @@ public static class TaxSeasonCalendar
|
|||||||
HeroSubtext = "증여 공제 한도 · 자산 이전 · 법인전환 연간 마감",
|
HeroSubtext = "증여 공제 한도 · 자산 이전 · 법인전환 연간 마감",
|
||||||
UrgencyBadge = "D-{n}일 | 연간 증여 한도 마감",
|
UrgencyBadge = "D-{n}일 | 연간 증여 한도 마감",
|
||||||
FocusService = "family-asset",
|
FocusService = "family-asset",
|
||||||
CtaText = "연말 절세 상담"
|
CtaText = "연말 절세 상담",
|
||||||
|
RelatedCategorySlug = "family-asset"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,4 +40,48 @@ public class AdminDashboardService(
|
|||||||
memoryCache.Set(CacheKey, summary, CacheDuration);
|
memoryCache.Set(CacheKey, summary, CacheDuration);
|
||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 최근 문의 조회
|
||||||
|
/// </summary>
|
||||||
|
public async Task<IReadOnlyList<Inquiry>> GetRecentInquiriesAsync(int limit, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
var (inquiries, _) = await inquiryService.GetPagedAsync(1, limit, ct: ct);
|
||||||
|
return inquiries.OrderByDescending(x => x.CreatedAt).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 월별 통계 (접수 건수, 진행 중, 완료)
|
||||||
|
/// </summary>
|
||||||
|
public async Task<object> GetMonthlyStatsAsync(string? month, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
var targetMonth = month != null && DateTime.TryParse($"{month}-01", out var dt)
|
||||||
|
? dt
|
||||||
|
: DateTime.Today;
|
||||||
|
|
||||||
|
var startDate = new DateTime(targetMonth.Year, targetMonth.Month, 1);
|
||||||
|
var endDate = startDate.AddMonths(1).AddDays(-1);
|
||||||
|
|
||||||
|
// 캐시 시도 (일 단위)
|
||||||
|
var cacheKey = $"admin-stats-{startDate:yyyy-MM}";
|
||||||
|
if (memoryCache.TryGetValue(cacheKey, out object? cachedStats) && cachedStats != null)
|
||||||
|
return cachedStats;
|
||||||
|
|
||||||
|
var total = await inquiryService.CountByDateRangeAsync(startDate, endDate, ct);
|
||||||
|
var consulting = await inquiryService.CountByStatusAndDateAsync("consulting", startDate, endDate, ct);
|
||||||
|
var completed = await inquiryService.CountByStatusAndDateAsync("contracted", startDate, endDate, ct);
|
||||||
|
|
||||||
|
var result = new
|
||||||
|
{
|
||||||
|
month = startDate.ToString("yyyy-MM"),
|
||||||
|
totalInquiries = total,
|
||||||
|
consultingCount = consulting,
|
||||||
|
completedCount = completed,
|
||||||
|
newCount = total - consulting - completed,
|
||||||
|
completionRate = total > 0 ? (completed * 100.0 / total) : 0.0
|
||||||
|
};
|
||||||
|
|
||||||
|
memoryCache.Set(cacheKey, result, TimeSpan.FromHours(1));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,25 @@ using Microsoft.Extensions.Caching.Memory;
|
|||||||
|
|
||||||
public class BlogService(IBlogPostRepository repository, IMemoryCache memoryCache)
|
public class BlogService(IBlogPostRepository repository, IMemoryCache memoryCache)
|
||||||
{
|
{
|
||||||
|
public async Task<BlogPost?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByIdAsync(id, ct);
|
||||||
|
|
||||||
public async Task<BlogPost?> GetBySlugAsync(string slug, CancellationToken ct = default) =>
|
public async Task<BlogPost?> GetBySlugAsync(string slug, CancellationToken ct = default) =>
|
||||||
await repository.GetBySlugAsync(slug, ct);
|
await repository.GetBySlugAsync(slug, ct);
|
||||||
|
|
||||||
|
/// <summary>카테고리 슬러그 기준 시즌 관련 글 조회. 부족 시 최신 글로 채워 total개 반환.</summary>
|
||||||
|
public async Task<(IEnumerable<BlogPost> Seasonal, IEnumerable<BlogPost> Latest)> GetSeasonalPostsAsync(
|
||||||
|
string categorySlug, int seasonalCount, int totalCount, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
var seasonal = (await repository.GetByCategorySlugAsync(categorySlug, seasonalCount, ct)).ToList();
|
||||||
|
var seasonalIds = seasonal.Select(p => p.Id).ToHashSet();
|
||||||
|
|
||||||
|
var (latestAll, _) = await repository.GetPublishedPagedAsync(1, totalCount + seasonalCount, null, ct);
|
||||||
|
var latest = latestAll.Where(p => !seasonalIds.Contains(p.Id)).Take(totalCount - seasonal.Count).ToList();
|
||||||
|
|
||||||
|
return (seasonal, latest);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<(IEnumerable<BlogPost>, int)> GetPublishedPagedAsync(
|
public async Task<(IEnumerable<BlogPost>, int)> GetPublishedPagedAsync(
|
||||||
int page, int pageSize, int? categoryId = null, CancellationToken ct = default) =>
|
int page, int pageSize, int? categoryId = null, CancellationToken ct = default) =>
|
||||||
await repository.GetPublishedPagedAsync(NormalizePage(page), NormalizePageSize(pageSize), categoryId, ct);
|
await repository.GetPublishedPagedAsync(NormalizePage(page), NormalizePageSize(pageSize), categoryId, ct);
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
namespace TaxBaik.Application.Services;
|
||||||
|
|
||||||
|
using TaxBaik.Application.DTOs;
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class ClientService(IClientRepository repository)
|
||||||
|
{
|
||||||
|
public static readonly string[] ServiceTypes =
|
||||||
|
["기장", "부동산", "증여·상속", "종합소득세", "법인세", "부가가치세", "기타"];
|
||||||
|
|
||||||
|
public static readonly string[] TaxTypes =
|
||||||
|
["개인사업자", "법인사업자", "면세사업자", "근로소득자", "기타"];
|
||||||
|
|
||||||
|
public static readonly string[] Sources =
|
||||||
|
["홈페이지 문의", "소개", "직접 방문", "카카오 채널", "블로그", "기타"];
|
||||||
|
|
||||||
|
public async Task<(IEnumerable<Client> Items, int Total)> GetPagedAsync(
|
||||||
|
int page, int pageSize, string? status = null, string? search = null, CancellationToken ct = default) =>
|
||||||
|
await repository.GetPagedAsync(Math.Max(1, page), Math.Clamp(pageSize, 1, 100), status, search, ct);
|
||||||
|
|
||||||
|
public async Task<Client?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByIdAsync(id, ct);
|
||||||
|
|
||||||
|
public async Task<Client?> GetByEmailAsync(string email, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByEmailAsync(email, ct);
|
||||||
|
|
||||||
|
public async Task<Client?> GetByPhoneAsync(string phone, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByPhoneAsync(phone, ct);
|
||||||
|
|
||||||
|
public async Task<int> CountCreatedAtRangeAsync(DateTime startDateUtc, DateTime endDateUtc, CancellationToken ct = default) =>
|
||||||
|
await repository.CountByCreatedAtRangeAsync(startDateUtc, endDateUtc, ct);
|
||||||
|
|
||||||
|
public async Task<int> CreateAsync(CreateClientDto dto, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(dto.Name))
|
||||||
|
throw new ValidationException("고객명을 입력하세요.");
|
||||||
|
|
||||||
|
var client = new Client
|
||||||
|
{
|
||||||
|
Name = dto.Name.Trim(),
|
||||||
|
CompanyName = dto.CompanyName?.Trim(),
|
||||||
|
Phone = dto.Phone?.Trim(),
|
||||||
|
Email = dto.Email?.Trim(),
|
||||||
|
ServiceType = dto.ServiceType,
|
||||||
|
TaxType = dto.TaxType,
|
||||||
|
Status = dto.Status,
|
||||||
|
Source = dto.Source,
|
||||||
|
Memo = dto.Memo?.Trim()
|
||||||
|
};
|
||||||
|
|
||||||
|
return await repository.CreateAsync(client, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(int id, CreateClientDto dto, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(dto.Name))
|
||||||
|
throw new ValidationException("고객명을 입력하세요.");
|
||||||
|
|
||||||
|
var client = await repository.GetByIdAsync(id, ct)
|
||||||
|
?? throw new KeyNotFoundException($"고객 ID {id}를 찾을 수 없습니다.");
|
||||||
|
|
||||||
|
client.Name = dto.Name.Trim();
|
||||||
|
client.CompanyName = dto.CompanyName?.Trim();
|
||||||
|
client.Phone = dto.Phone?.Trim();
|
||||||
|
client.Email = dto.Email?.Trim();
|
||||||
|
client.ServiceType = dto.ServiceType;
|
||||||
|
client.TaxType = dto.TaxType;
|
||||||
|
client.Status = dto.Status;
|
||||||
|
client.Source = dto.Source;
|
||||||
|
client.Memo = dto.Memo?.Trim();
|
||||||
|
|
||||||
|
await repository.UpdateAsync(client, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> CreateFromInquiryAsync(string name, string? phone, string? serviceType, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
var client = new Client
|
||||||
|
{
|
||||||
|
Name = name.Trim(),
|
||||||
|
Phone = phone?.Trim(),
|
||||||
|
ServiceType = serviceType,
|
||||||
|
Status = "active",
|
||||||
|
Source = "홈페이지 문의"
|
||||||
|
};
|
||||||
|
return await repository.CreateAsync(client, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAsync(int id, CancellationToken ct = default) =>
|
||||||
|
await repository.DeleteAsync(id, ct);
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
namespace TaxBaik.Application.Services;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class CompanyService(ICompanyRepository repository)
|
||||||
|
{
|
||||||
|
public async Task<int> CreateAsync(string companyCode, string companyName, string? contactPerson = null,
|
||||||
|
string? phone = null, string? email = null, string? memo = null, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(companyCode))
|
||||||
|
throw new ValidationException("회사 코드를 입력하세요.");
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(companyName))
|
||||||
|
throw new ValidationException("회사명을 입력하세요.");
|
||||||
|
|
||||||
|
var existing = await repository.GetByCodeAsync(companyCode.Trim(), ct);
|
||||||
|
if (existing != null)
|
||||||
|
throw new ValidationException("이미 존재하는 회사 코드입니다.");
|
||||||
|
|
||||||
|
var company = new Company
|
||||||
|
{
|
||||||
|
CompanyCode = companyCode.Trim(),
|
||||||
|
CompanyName = companyName.Trim(),
|
||||||
|
ContactPerson = string.IsNullOrWhiteSpace(contactPerson) ? null : contactPerson.Trim(),
|
||||||
|
Phone = string.IsNullOrWhiteSpace(phone) ? null : phone.Trim(),
|
||||||
|
Email = string.IsNullOrWhiteSpace(email) ? null : email.Trim(),
|
||||||
|
Memo = string.IsNullOrWhiteSpace(memo) ? null : memo.Trim(),
|
||||||
|
IsActive = true,
|
||||||
|
CreatedAt = DateTime.UtcNow,
|
||||||
|
UpdatedAt = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
|
return await repository.CreateAsync(company, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Company?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByIdAsync(id, ct);
|
||||||
|
|
||||||
|
public async Task<Company?> GetByCodeAsync(string code, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByCodeAsync(code, ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Company>> GetAllActiveAsync(CancellationToken ct = default) =>
|
||||||
|
await repository.GetAllActiveAsync(ct);
|
||||||
|
|
||||||
|
public async Task<(IEnumerable<Company>, int)> GetPagedAsync(int page, int pageSize, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
var (items, total) = await repository.GetPagedAsync(NormalizePage(page), NormalizePageSize(pageSize), ct);
|
||||||
|
return (items, total);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(int id, string companyCode, string companyName, string? contactPerson = null,
|
||||||
|
string? phone = null, string? email = null, string? memo = null, bool isActive = true, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(companyCode))
|
||||||
|
throw new ValidationException("회사 코드를 입력하세요.");
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(companyName))
|
||||||
|
throw new ValidationException("회사명을 입력하세요.");
|
||||||
|
|
||||||
|
var company = await repository.GetByIdAsync(id, ct);
|
||||||
|
if (company == null)
|
||||||
|
throw new ValidationException("회사를 찾을 수 없습니다.");
|
||||||
|
|
||||||
|
var existing = await repository.GetByCodeAsync(companyCode.Trim(), ct);
|
||||||
|
if (existing != null && existing.Id != id)
|
||||||
|
throw new ValidationException("이미 존재하는 회사 코드입니다.");
|
||||||
|
|
||||||
|
company.CompanyCode = companyCode.Trim();
|
||||||
|
company.CompanyName = companyName.Trim();
|
||||||
|
company.ContactPerson = string.IsNullOrWhiteSpace(contactPerson) ? null : contactPerson.Trim();
|
||||||
|
company.Phone = string.IsNullOrWhiteSpace(phone) ? null : phone.Trim();
|
||||||
|
company.Email = string.IsNullOrWhiteSpace(email) ? null : email.Trim();
|
||||||
|
company.Memo = string.IsNullOrWhiteSpace(memo) ? null : memo.Trim();
|
||||||
|
company.IsActive = isActive;
|
||||||
|
company.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
|
await repository.UpdateAsync(company, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAsync(int id, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
var company = await repository.GetByIdAsync(id, ct);
|
||||||
|
if (company == null)
|
||||||
|
throw new ValidationException("회사를 찾을 수 없습니다.");
|
||||||
|
|
||||||
|
if (company.CompanyCode == "DEFAULT")
|
||||||
|
throw new ValidationException("기본 회사는 삭제할 수 없습니다.");
|
||||||
|
|
||||||
|
await repository.DeleteAsync(id, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int NormalizePage(int page) => Math.Max(1, page);
|
||||||
|
private static int NormalizePageSize(int pageSize) => Math.Clamp(pageSize, 1, 100);
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
namespace TaxBaik.Application.Services;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class ConsultationService(IConsultationRepository repository)
|
||||||
|
{
|
||||||
|
public static readonly string[] Results =
|
||||||
|
["상담 중", "계약 완료", "보류", "거절", "완료"];
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Consultation>> GetByClientIdAsync(int clientId, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByClientIdAsync(clientId, ct);
|
||||||
|
|
||||||
|
public async Task<int> CreateAsync(Consultation consultation, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(consultation.Summary))
|
||||||
|
throw new ValidationException("상담 내용을 입력하세요.");
|
||||||
|
if (consultation.ClientId <= 0)
|
||||||
|
throw new ValidationException("고객을 선택하세요.");
|
||||||
|
return await repository.CreateAsync(consultation, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAsync(int id, CancellationToken ct = default) =>
|
||||||
|
await repository.DeleteAsync(id, ct);
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
namespace TaxBaik.Application.Services;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class ConsultingActivityService(IConsultingActivityRepository repository)
|
||||||
|
{
|
||||||
|
public async Task<int> CreateAsync(int clientId, string activityType, DateTime activityDate,
|
||||||
|
string description, int? consultantId = null, DateTime? nextFollowupDate = null, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (clientId <= 0)
|
||||||
|
throw new ValidationException("유효한 고객을 선택하세요.");
|
||||||
|
if (string.IsNullOrWhiteSpace(activityType))
|
||||||
|
throw new ValidationException("활동 유형을 입력하세요.");
|
||||||
|
if (string.IsNullOrWhiteSpace(description))
|
||||||
|
throw new ValidationException("활동 내용을 입력하세요.");
|
||||||
|
|
||||||
|
var activity = new ConsultingActivity
|
||||||
|
{
|
||||||
|
ClientId = clientId,
|
||||||
|
ActivityType = activityType.Trim(),
|
||||||
|
ActivityDate = activityDate,
|
||||||
|
Description = description.Trim(),
|
||||||
|
AssignedConsultantId = consultantId,
|
||||||
|
NextFollowupDate = nextFollowupDate,
|
||||||
|
CreatedAt = DateTime.UtcNow,
|
||||||
|
UpdatedAt = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
|
return await repository.CreateAsync(activity, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<ConsultingActivity>> GetByClientIdAsync(int clientId, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByClientIdAsync(clientId, ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<ConsultingActivity>> GetAllAsync(CancellationToken ct = default) =>
|
||||||
|
await repository.GetAllAsync(ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<ConsultingActivity>> GetPendingFollowupsAsync(CancellationToken ct = default) =>
|
||||||
|
await repository.GetPendingFollowupsAsync(ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<ConsultingActivity>> GetConsultantActivityAsync(int consultantId, DateTime fromDate, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByConsultantAsync(consultantId, fromDate, ct);
|
||||||
|
|
||||||
|
public async Task UpdateAsync(int id, string? outcome, DateTime? nextFollowupDate, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
var activity = new ConsultingActivity { Id = id, Outcome = outcome, NextFollowupDate = nextFollowupDate, UpdatedAt = DateTime.UtcNow };
|
||||||
|
await repository.UpdateAsync(activity, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
namespace TaxBaik.Application.Services;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class ContractService(IContractRepository repository)
|
||||||
|
{
|
||||||
|
public async Task<int> CreateAsync(int clientId, string contractNumber, string serviceType,
|
||||||
|
DateTime startDate, decimal? monthlyFee = null, decimal? totalAmount = null, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (clientId <= 0)
|
||||||
|
throw new ValidationException("유효한 고객을 선택하세요.");
|
||||||
|
if (string.IsNullOrWhiteSpace(contractNumber))
|
||||||
|
throw new ValidationException("계약 번호를 입력하세요.");
|
||||||
|
if (string.IsNullOrWhiteSpace(serviceType))
|
||||||
|
throw new ValidationException("서비스 유형을 입력하세요.");
|
||||||
|
|
||||||
|
var contract = new Contract
|
||||||
|
{
|
||||||
|
ClientId = clientId,
|
||||||
|
ContractNumber = contractNumber.Trim(),
|
||||||
|
ServiceType = serviceType.Trim(),
|
||||||
|
ContractDate = DateTime.Today,
|
||||||
|
StartDate = startDate,
|
||||||
|
MonthlyFee = monthlyFee,
|
||||||
|
TotalAmount = totalAmount,
|
||||||
|
Status = "active",
|
||||||
|
PaymentStatus = "pending",
|
||||||
|
CreatedAt = DateTime.UtcNow,
|
||||||
|
UpdatedAt = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
|
return await repository.CreateAsync(contract, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Contract?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByIdAsync(id, ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Contract>> GetAllAsync(CancellationToken ct = default) =>
|
||||||
|
await repository.GetAllAsync(ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Contract>> GetByClientIdAsync(int clientId, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByClientIdAsync(clientId, ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Contract>> GetActiveContractsAsync(CancellationToken ct = default) =>
|
||||||
|
await repository.GetActiveContractsAsync(ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Contract>> GetExpiringContractsAsync(int daysAhead = 30, CancellationToken ct = default) =>
|
||||||
|
await repository.GetExpiringContractsAsync(daysAhead, ct);
|
||||||
|
|
||||||
|
public async Task<decimal> GetMonthlyRecurringRevenueAsync(CancellationToken ct = default) =>
|
||||||
|
await repository.GetMonthlyRecurringRevenueAsync(ct);
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
namespace TaxBaik.Application.Services;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class FaqService(IFaqRepository repository)
|
||||||
|
{
|
||||||
|
public static readonly string[] Categories =
|
||||||
|
["기장·세금신고", "부동산", "증여·상속", "기타"];
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Faq>> GetActiveAsync(CancellationToken ct = default) =>
|
||||||
|
await repository.GetActiveAsync(ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Faq>> GetAllAsync(CancellationToken ct = default) =>
|
||||||
|
await repository.GetAllAsync(ct);
|
||||||
|
|
||||||
|
public async Task<Faq?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByIdAsync(id, ct);
|
||||||
|
|
||||||
|
public async Task<int> CreateAsync(Faq faq, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
Validate(faq);
|
||||||
|
return await repository.CreateAsync(faq, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(Faq faq, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
Validate(faq);
|
||||||
|
await repository.UpdateAsync(faq, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAsync(int id, CancellationToken ct = default) =>
|
||||||
|
await repository.DeleteAsync(id, ct);
|
||||||
|
|
||||||
|
private static void Validate(Faq faq)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(faq.Question))
|
||||||
|
throw new ValidationException("질문을 입력하세요.");
|
||||||
|
if (string.IsNullOrWhiteSpace(faq.Answer))
|
||||||
|
throw new ValidationException("답변을 입력하세요.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ public class InquiryService(
|
|||||||
|
|
||||||
public async Task<int> SubmitAsync(
|
public async Task<int> SubmitAsync(
|
||||||
string name, string phone, string serviceType, string message,
|
string name, string phone, string serviceType, string message,
|
||||||
string? email = null, string? ipAddress = null, CancellationToken ct = default)
|
string? email = null, string? ipAddress = null, bool suppressNotification = false, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(name))
|
if (string.IsNullOrWhiteSpace(name))
|
||||||
throw new ValidationException("이름을 입력하세요.");
|
throw new ValidationException("이름을 입력하세요.");
|
||||||
@@ -39,7 +39,10 @@ public class InquiryService(
|
|||||||
};
|
};
|
||||||
|
|
||||||
var inquiryId = await repository.CreateAsync(inquiry, ct);
|
var inquiryId = await repository.CreateAsync(inquiry, ct);
|
||||||
await notificationService.NotifyCreatedAsync(inquiryId, inquiry.Name, inquiry.Phone, inquiry.ServiceType, inquiry.Message, inquiry.IpAddress, inquiry.CreatedAt, ct);
|
if (!suppressNotification)
|
||||||
|
{
|
||||||
|
await notificationService.NotifyCreatedAsync(inquiryId, inquiry.Name, inquiry.Phone, inquiry.ServiceType, inquiry.Message, inquiry.IpAddress, inquiry.CreatedAt, ct);
|
||||||
|
}
|
||||||
memoryCache.Remove(AdminDashboardService.CacheKey);
|
memoryCache.Remove(AdminDashboardService.CacheKey);
|
||||||
return inquiryId;
|
return inquiryId;
|
||||||
}
|
}
|
||||||
@@ -60,6 +63,18 @@ public class InquiryService(
|
|||||||
public Task<int> CountByStatusAsync(string status, CancellationToken ct = default)
|
public Task<int> CountByStatusAsync(string status, CancellationToken ct = default)
|
||||||
=> repository.CountByStatusAsync(status, ct);
|
=> repository.CountByStatusAsync(status, ct);
|
||||||
|
|
||||||
|
public Task<int> CountByDateRangeAsync(DateTime startDate, DateTime endDate, CancellationToken ct = default)
|
||||||
|
=> repository.CountByDateRangeAsync(startDate, endDate, ct);
|
||||||
|
|
||||||
|
public Task<int> CountByStatusAndDateAsync(string status, DateTime startDate, DateTime endDate, CancellationToken ct = default)
|
||||||
|
=> repository.CountByStatusAndDateAsync(status, startDate, endDate, ct);
|
||||||
|
|
||||||
|
public async Task UpdateAdminMemoAsync(int id, string? adminMemo, CancellationToken ct = default) =>
|
||||||
|
await repository.UpdateAdminMemoAsync(id, adminMemo, ct);
|
||||||
|
|
||||||
|
public async Task LinkClientAsync(int inquiryId, int clientId, CancellationToken ct = default) =>
|
||||||
|
await repository.LinkClientAsync(inquiryId, clientId, ct);
|
||||||
|
|
||||||
public async Task UpdateStatusAsync(int id, string status, string? changedBy = null, CancellationToken ct = default)
|
public async Task UpdateStatusAsync(int id, string status, string? changedBy = null, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
if (!InquiryStatusMapper.TryParse(status, out var parsed))
|
if (!InquiryStatusMapper.TryParse(status, out var parsed))
|
||||||
@@ -77,6 +92,12 @@ public class InquiryService(
|
|||||||
memoryCache.Remove(AdminDashboardService.CacheKey);
|
memoryCache.Remove(AdminDashboardService.CacheKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAsync(int id, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
await repository.DeleteAsync(id, ct);
|
||||||
|
memoryCache.Remove(AdminDashboardService.CacheKey);
|
||||||
|
}
|
||||||
|
|
||||||
private static int NormalizePage(int page) => Math.Max(1, page);
|
private static int NormalizePage(int page) => Math.Max(1, page);
|
||||||
|
|
||||||
private static int NormalizePageSize(int pageSize) => Math.Clamp(pageSize, 1, 100);
|
private static int NormalizePageSize(int pageSize) => Math.Clamp(pageSize, 1, 100);
|
||||||
|
|||||||
@@ -4,24 +4,37 @@ using TaxBaik.Domain.Enums;
|
|||||||
|
|
||||||
public static class InquiryStatusMapper
|
public static class InquiryStatusMapper
|
||||||
{
|
{
|
||||||
|
public static readonly Dictionary<string, string> Labels = new()
|
||||||
|
{
|
||||||
|
["new"] = "신규",
|
||||||
|
["consulting"] = "상담중",
|
||||||
|
["contracted"] = "계약완료",
|
||||||
|
["rejected"] = "거절",
|
||||||
|
["closed"] = "종결",
|
||||||
|
};
|
||||||
|
|
||||||
public static string ToStorageValue(InquiryStatus status) => status switch
|
public static string ToStorageValue(InquiryStatus status) => status switch
|
||||||
{
|
{
|
||||||
InquiryStatus.New => "new",
|
InquiryStatus.New => "new",
|
||||||
InquiryStatus.Contacted => "contacted",
|
InquiryStatus.Consulting => "consulting",
|
||||||
InquiryStatus.Completed => "completed",
|
InquiryStatus.Contracted => "contracted",
|
||||||
|
InquiryStatus.Rejected => "rejected",
|
||||||
|
InquiryStatus.Closed => "closed",
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(status), status, null)
|
_ => throw new ArgumentOutOfRangeException(nameof(status), status, null)
|
||||||
};
|
};
|
||||||
|
|
||||||
public static bool TryParse(string? value, out InquiryStatus status)
|
public static bool TryParse(string? value, out InquiryStatus status)
|
||||||
{
|
{
|
||||||
status = value?.Trim().ToLowerInvariant() switch
|
var key = value?.Trim().ToLowerInvariant();
|
||||||
|
status = key switch
|
||||||
{
|
{
|
||||||
"new" => InquiryStatus.New,
|
"new" => InquiryStatus.New,
|
||||||
"contacted" => InquiryStatus.Contacted,
|
"consulting" => InquiryStatus.Consulting,
|
||||||
"completed" => InquiryStatus.Completed,
|
"contracted" => InquiryStatus.Contracted,
|
||||||
|
"rejected" => InquiryStatus.Rejected,
|
||||||
|
"closed" => InquiryStatus.Closed,
|
||||||
_ => default
|
_ => default
|
||||||
};
|
};
|
||||||
|
return key is "new" or "consulting" or "contracted" or "rejected" or "closed";
|
||||||
return value?.Trim().ToLowerInvariant() is "new" or "contacted" or "completed";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
namespace TaxBaik.Application.Services;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class PortalUserService(IPortalUserRepository repository)
|
||||||
|
{
|
||||||
|
public async Task<PortalUser?> GetByEmailAsync(string email, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByEmailAsync(email.Trim(), ct);
|
||||||
|
|
||||||
|
public async Task<PortalUser?> GetByProviderAsync(string provider, string providerId, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByProviderAsync(provider.Trim(), providerId.Trim(), ct);
|
||||||
|
|
||||||
|
public async Task<int> RegisterLocalAsync(string name, string email, string phone, string? passwordHash, int? clientId = null, CancellationToken ct = default) =>
|
||||||
|
await RegisterAsync(name, email, phone, "local", null, passwordHash, clientId, ct);
|
||||||
|
|
||||||
|
public async Task<int> RegisterOAuthAsync(string name, string email, string? phone, string provider, string providerId, int? clientId = null, CancellationToken ct = default) =>
|
||||||
|
await RegisterAsync(name, email, phone, provider, providerId, null, clientId, ct);
|
||||||
|
|
||||||
|
public async Task LinkOAuthAsync(PortalUser user, string provider, string providerId, string? displayName = null, string? email = null, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
user.Name = string.IsNullOrWhiteSpace(displayName) ? user.Name : displayName.Trim();
|
||||||
|
user.Email = string.IsNullOrWhiteSpace(email) ? user.Email : email.Trim();
|
||||||
|
if (string.IsNullOrWhiteSpace(user.PasswordHash))
|
||||||
|
{
|
||||||
|
user.Provider = provider.Trim();
|
||||||
|
user.ProviderId = providerId.Trim();
|
||||||
|
}
|
||||||
|
await repository.UpdateAsync(user, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AttachClientAsync(PortalUser user, int clientId, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
user.ClientId = clientId;
|
||||||
|
await repository.UpdateAsync(user, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<int> RegisterAsync(string name, string email, string? phone, string provider, string? providerId, string? passwordHash, int? clientId, CancellationToken ct)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(name))
|
||||||
|
throw new ValidationException("이름을 입력하세요.");
|
||||||
|
if (string.IsNullOrWhiteSpace(email))
|
||||||
|
throw new ValidationException("이메일을 입력하세요.");
|
||||||
|
|
||||||
|
var user = new PortalUser
|
||||||
|
{
|
||||||
|
ClientId = clientId,
|
||||||
|
Name = name.Trim(),
|
||||||
|
Email = email.Trim(),
|
||||||
|
Phone = string.IsNullOrWhiteSpace(phone) ? null : phone.Trim(),
|
||||||
|
Provider = provider,
|
||||||
|
ProviderId = providerId,
|
||||||
|
PasswordHash = passwordHash,
|
||||||
|
CreatedAt = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
|
return await repository.CreateAsync(user, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
namespace TaxBaik.Application.Services;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class RevenueTrackingService(IRevenueTrackingRepository repository)
|
||||||
|
{
|
||||||
|
public async Task<int> CreateAsync(int clientId, string invoiceNumber, DateTime invoiceDate,
|
||||||
|
decimal amount, string? serviceType = null, DateTime? dueDate = null, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (clientId <= 0)
|
||||||
|
throw new ValidationException("유효한 고객을 선택하세요.");
|
||||||
|
if (string.IsNullOrWhiteSpace(invoiceNumber))
|
||||||
|
throw new ValidationException("인보이스 번호를 입력하세요.");
|
||||||
|
if (amount <= 0)
|
||||||
|
throw new ValidationException("금액은 0보다 커야 합니다.");
|
||||||
|
|
||||||
|
var revenue = new RevenueTracking
|
||||||
|
{
|
||||||
|
ClientId = clientId,
|
||||||
|
InvoiceNumber = invoiceNumber.Trim(),
|
||||||
|
InvoiceDate = invoiceDate,
|
||||||
|
Amount = amount,
|
||||||
|
ServiceType = string.IsNullOrWhiteSpace(serviceType) ? null : serviceType.Trim(),
|
||||||
|
DueDate = dueDate,
|
||||||
|
PaymentStatus = "pending",
|
||||||
|
CreatedAt = DateTime.UtcNow,
|
||||||
|
UpdatedAt = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
|
return await repository.CreateAsync(revenue, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<RevenueTracking>> GetByClientIdAsync(int clientId, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByClientIdAsync(clientId, ct);
|
||||||
|
|
||||||
|
public async Task<RevenueTracking?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByIdAsync(id, ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<RevenueTracking>> GetAllAsync(CancellationToken ct = default) =>
|
||||||
|
await repository.GetAllAsync(ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<RevenueTracking>> GetPendingPaymentsAsync(CancellationToken ct = default) =>
|
||||||
|
await repository.GetPendingPaymentsAsync(ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<RevenueTracking>> GetMonthlyRevenueAsync(DateTime month, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
var startDate = new DateTime(month.Year, month.Month, 1);
|
||||||
|
var endDate = startDate.AddMonths(1).AddDays(-1);
|
||||||
|
return await repository.GetByDateRangeAsync(startDate, endDate, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task MarkPaidAsync(int id, DateTime paymentDate, CancellationToken ct = default) =>
|
||||||
|
await repository.MarkPaidAsync(id, paymentDate, ct);
|
||||||
|
|
||||||
|
public async Task<decimal> GetTotalRevenueAsync(DateTime startDate, DateTime endDate, CancellationToken ct = default) =>
|
||||||
|
await repository.GetTotalRevenueAsync(startDate, endDate, ct);
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ public class SeasonalMarketingService
|
|||||||
HeroSubtext = season.HeroSubtext,
|
HeroSubtext = season.HeroSubtext,
|
||||||
UrgencyBadge = season.UrgencyBadge.Replace("{n}", days.ToString()),
|
UrgencyBadge = season.UrgencyBadge.Replace("{n}", days.ToString()),
|
||||||
FocusService = season.FocusService,
|
FocusService = season.FocusService,
|
||||||
|
RelatedCategorySlug = season.RelatedCategorySlug,
|
||||||
CtaText = season.CtaText,
|
CtaText = season.CtaText,
|
||||||
DaysUntilDeadline = days,
|
DaysUntilDeadline = days,
|
||||||
Deadline = end
|
Deadline = end
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
namespace TaxBaik.Application.Services;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class TaxFilingScheduleService(ITaxFilingScheduleRepository repository)
|
||||||
|
{
|
||||||
|
public async Task<int> CreateAsync(int clientId, string filingType, DateTime dueDate, int filingYear,
|
||||||
|
int? assignedToId = null, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (clientId <= 0)
|
||||||
|
throw new ValidationException("유효한 고객을 선택하세요.");
|
||||||
|
if (string.IsNullOrWhiteSpace(filingType))
|
||||||
|
throw new ValidationException("신고 유형을 입력하세요.");
|
||||||
|
if (dueDate < DateTime.Today)
|
||||||
|
throw new ValidationException("마감일은 오늘 이후여야 합니다.");
|
||||||
|
|
||||||
|
var schedule = new TaxFilingSchedule
|
||||||
|
{
|
||||||
|
ClientId = clientId,
|
||||||
|
FilingType = filingType.Trim(),
|
||||||
|
DueDate = dueDate,
|
||||||
|
FilingYear = filingYear,
|
||||||
|
Status = "pending",
|
||||||
|
AssignedToId = assignedToId,
|
||||||
|
CreatedAt = DateTime.UtcNow,
|
||||||
|
UpdatedAt = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
|
return await repository.CreateAsync(schedule, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<TaxFilingSchedule?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByIdAsync(id, ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxFilingSchedule>> GetAllAsync(CancellationToken ct = default) =>
|
||||||
|
await repository.GetAllAsync(ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxFilingSchedule>> GetByClientIdAsync(int clientId, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByClientIdAsync(clientId, ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxFilingSchedule>> GetUpcomingDuesAsync(int daysAhead = 30, CancellationToken ct = default) =>
|
||||||
|
await repository.GetUpcomingDuesAsync(daysAhead, ct);
|
||||||
|
|
||||||
|
public async Task MarkCompletedAsync(int id, CancellationToken ct = default) =>
|
||||||
|
await repository.MarkCompletedAsync(id, ct);
|
||||||
|
|
||||||
|
public async Task<int> GetPendingCountAsync(CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
var pending = await repository.GetByStatusAsync("pending", ct);
|
||||||
|
return pending.Count();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
namespace TaxBaik.Application.Services;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class TaxFilingService(ITaxFilingRepository repository)
|
||||||
|
{
|
||||||
|
public static readonly string[] FilingTypes =
|
||||||
|
["부가가치세", "종합소득세", "법인세", "원천징수", "종합부동산세", "증여세", "상속세", "기타"];
|
||||||
|
|
||||||
|
public static readonly string[] Statuses =
|
||||||
|
["pending", "filed", "overdue"];
|
||||||
|
|
||||||
|
public static readonly Dictionary<string, string> StatusLabels = new()
|
||||||
|
{
|
||||||
|
["pending"] = "신고 예정",
|
||||||
|
["filed"] = "신고 완료",
|
||||||
|
["overdue"] = "기한 초과",
|
||||||
|
};
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxFiling>> GetByClientIdAsync(int clientId, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByClientIdAsync(clientId, ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxFiling>> GetUpcomingAsync(int daysAhead = 30, CancellationToken ct = default) =>
|
||||||
|
await repository.GetUpcomingAsync(daysAhead, ct);
|
||||||
|
|
||||||
|
public async Task<TaxFiling?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByIdAsync(id, ct);
|
||||||
|
|
||||||
|
public async Task<int> CreateAsync(TaxFiling filing, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(filing.FilingType))
|
||||||
|
throw new ValidationException("신고 유형을 선택하세요.");
|
||||||
|
if (filing.ClientId <= 0)
|
||||||
|
throw new ValidationException("고객을 선택하세요.");
|
||||||
|
if (filing.DueDate == default)
|
||||||
|
throw new ValidationException("신고 기한을 입력하세요.");
|
||||||
|
return await repository.CreateAsync(filing, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(TaxFiling filing, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(filing.FilingType))
|
||||||
|
throw new ValidationException("신고 유형을 선택하세요.");
|
||||||
|
await repository.UpdateAsync(filing, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAsync(int id, CancellationToken ct = default) =>
|
||||||
|
await repository.DeleteAsync(id, ct);
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
namespace TaxBaik.Application.Services;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class TaxProfileService(ITaxProfileRepository repository)
|
||||||
|
{
|
||||||
|
public async Task<int> CreateAsync(int clientId, string? businessType, string? businessRegistration = null,
|
||||||
|
string? accountingMethod = null, DateTime? establishmentDate = null, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (clientId <= 0)
|
||||||
|
throw new ValidationException("유효한 고객을 선택하세요.");
|
||||||
|
if (string.IsNullOrWhiteSpace(businessType))
|
||||||
|
throw new ValidationException("사업 유형을 입력하세요.");
|
||||||
|
|
||||||
|
var profile = new TaxProfile
|
||||||
|
{
|
||||||
|
ClientId = clientId,
|
||||||
|
BusinessType = businessType.Trim(),
|
||||||
|
BusinessRegistration = string.IsNullOrWhiteSpace(businessRegistration) ? null : businessRegistration.Trim(),
|
||||||
|
EstablishmentDate = establishmentDate,
|
||||||
|
AccountingMethod = string.IsNullOrWhiteSpace(accountingMethod) ? null : accountingMethod.Trim(),
|
||||||
|
TaxRiskLevel = "normal",
|
||||||
|
CreatedAt = DateTime.UtcNow,
|
||||||
|
UpdatedAt = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
|
return await repository.CreateAsync(profile, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<TaxProfile?> GetByClientIdAsync(int clientId, CancellationToken ct = default) =>
|
||||||
|
await repository.GetByClientIdAsync(clientId, ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxProfile>> GetAllAsync(CancellationToken ct = default) =>
|
||||||
|
await repository.GetAllAsync(ct);
|
||||||
|
|
||||||
|
public async Task UpdateAsync(int profileId, string? businessType, string? accountingMethod,
|
||||||
|
DateTime? nextFilingDueDate, string taxRiskLevel = "normal", CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
var profile = new TaxProfile { Id = profileId };
|
||||||
|
if (!string.IsNullOrWhiteSpace(businessType))
|
||||||
|
profile.BusinessType = businessType.Trim();
|
||||||
|
if (!string.IsNullOrWhiteSpace(accountingMethod))
|
||||||
|
profile.AccountingMethod = accountingMethod.Trim();
|
||||||
|
profile.NextFilingDueDate = nextFilingDueDate;
|
||||||
|
profile.TaxRiskLevel = taxRiskLevel;
|
||||||
|
profile.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
|
await repository.UpdateAsync(profile, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxProfile>> GetHighRiskProfilesAsync(CancellationToken ct = default) =>
|
||||||
|
await repository.GetByRiskLevelAsync("high", ct);
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxProfile>> GetUpcomingFilingDuesAsync(int daysAhead = 30, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
var startDate = DateTime.Today;
|
||||||
|
var endDate = startDate.AddDays(daysAhead);
|
||||||
|
return await repository.GetUpcomingFilingDuesAsync(startDate, endDate, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
namespace TaxBaik.Application.Services;
|
||||||
|
|
||||||
|
public record TelegramDailyReport(
|
||||||
|
DateOnly Date,
|
||||||
|
int NewInquiries,
|
||||||
|
int PendingInquiries,
|
||||||
|
int NewClients,
|
||||||
|
int PendingTaxFilings,
|
||||||
|
int PendingPayments);
|
||||||
|
|
||||||
|
public record TelegramWeeklyReport(
|
||||||
|
DateOnly WeekStart,
|
||||||
|
DateOnly WeekEnd,
|
||||||
|
int NewInquiries,
|
||||||
|
int NewClients,
|
||||||
|
int UpcomingTaxFilings,
|
||||||
|
decimal RevenueThisWeek);
|
||||||
|
|
||||||
|
public class TelegramReportService(
|
||||||
|
InquiryService inquiryService,
|
||||||
|
ClientService clientService,
|
||||||
|
TaxFilingScheduleService taxFilingScheduleService,
|
||||||
|
RevenueTrackingService revenueTrackingService)
|
||||||
|
{
|
||||||
|
public async Task<TelegramDailyReport> BuildDailyReportAsync(DateOnly date, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
var start = date.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc);
|
||||||
|
var end = date.ToDateTime(TimeOnly.MaxValue, DateTimeKind.Utc);
|
||||||
|
|
||||||
|
return new TelegramDailyReport(
|
||||||
|
Date: date,
|
||||||
|
NewInquiries: await inquiryService.CountByDateRangeAsync(start, end, ct),
|
||||||
|
PendingInquiries: await inquiryService.CountByStatusAsync("new", ct),
|
||||||
|
NewClients: await clientService.CountCreatedAtRangeAsync(start, end, ct),
|
||||||
|
PendingTaxFilings: await taxFilingScheduleService.GetPendingCountAsync(ct),
|
||||||
|
PendingPayments: (await revenueTrackingService.GetPendingPaymentsAsync(ct)).Count());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<TelegramWeeklyReport> BuildWeeklyReportAsync(DateOnly weekStart, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
var weekEnd = weekStart.AddDays(6);
|
||||||
|
var start = weekStart.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc);
|
||||||
|
var end = weekEnd.ToDateTime(TimeOnly.MaxValue, DateTimeKind.Utc);
|
||||||
|
var upcomingEnd = weekEnd.AddDays(7).ToDateTime(TimeOnly.MaxValue, DateTimeKind.Utc);
|
||||||
|
|
||||||
|
var revenue = await revenueTrackingService.GetTotalRevenueAsync(start, end, ct);
|
||||||
|
|
||||||
|
return new TelegramWeeklyReport(
|
||||||
|
WeekStart: weekStart,
|
||||||
|
WeekEnd: weekEnd,
|
||||||
|
NewInquiries: await inquiryService.CountByDateRangeAsync(start, end, ct),
|
||||||
|
NewClients: await clientService.CountCreatedAtRangeAsync(start, end, ct),
|
||||||
|
UpcomingTaxFilings: (await taxFilingScheduleService.GetUpcomingDuesAsync(14, ct))
|
||||||
|
.Count(x => x.DueDate >= start && x.DueDate <= upcomingEnd),
|
||||||
|
RevenueThisWeek: revenue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FormatDailyMessage(TelegramDailyReport report) =>
|
||||||
|
$"<b>📊 일간 리포트</b>\n\n" +
|
||||||
|
$"기준일: <code>{report.Date:yyyy-MM-dd}</code>\n" +
|
||||||
|
$"신규 문의: <code>{report.NewInquiries}</code>\n" +
|
||||||
|
$"처리 대기 문의: <code>{report.PendingInquiries}</code>\n" +
|
||||||
|
$"신규 고객: <code>{report.NewClients}</code>\n" +
|
||||||
|
$"신고 대기: <code>{report.PendingTaxFilings}</code>\n" +
|
||||||
|
$"미수 청구: <code>{report.PendingPayments}</code>";
|
||||||
|
|
||||||
|
public static string FormatWeeklyMessage(TelegramWeeklyReport report) =>
|
||||||
|
$"<b>📈 주간 리포트</b>\n\n" +
|
||||||
|
$"기간: <code>{report.WeekStart:yyyy-MM-dd}</code> ~ <code>{report.WeekEnd:yyyy-MM-dd}</code>\n" +
|
||||||
|
$"신규 문의: <code>{report.NewInquiries}</code>\n" +
|
||||||
|
$"신규 고객: <code>{report.NewClients}</code>\n" +
|
||||||
|
$"다가오는 신고: <code>{report.UpcomingTaxFilings}</code>\n" +
|
||||||
|
$"주간 매출: <code>₩{report.RevenueThisWeek:N0}</code>";
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
namespace TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public class Client
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int? CompanyId { get; set; }
|
||||||
|
public string Name { get; set; } = "";
|
||||||
|
public string? CompanyName { get; set; }
|
||||||
|
public string? Phone { get; set; }
|
||||||
|
public string? Email { get; set; }
|
||||||
|
public string? ContactPerson { get; set; }
|
||||||
|
public string? ServiceType { get; set; }
|
||||||
|
public string? TaxType { get; set; }
|
||||||
|
public string Status { get; set; } = "active";
|
||||||
|
public string? Source { get; set; }
|
||||||
|
public string? Memo { get; set; }
|
||||||
|
|
||||||
|
// Tax-specific fields
|
||||||
|
public string? BusinessRegistrationNumber { get; set; }
|
||||||
|
public string? BusinessType { get; set; }
|
||||||
|
public DateTime? EstablishmentDate { get; set; }
|
||||||
|
public string? AnnualRevenueRange { get; set; }
|
||||||
|
public int? EmployeeCount { get; set; }
|
||||||
|
public DateTime? LastTaxFilingDate { get; set; }
|
||||||
|
public string TaxRiskLevel { get; set; } = "normal";
|
||||||
|
public DateTime? NextFilingDueDate { get; set; }
|
||||||
|
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
namespace TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public class Company
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string CompanyCode { get; set; } = "";
|
||||||
|
public string CompanyName { get; set; } = "";
|
||||||
|
public string? ContactPerson { get; set; }
|
||||||
|
public string? Phone { get; set; }
|
||||||
|
public string? Email { get; set; }
|
||||||
|
public string? Memo { get; set; }
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
namespace TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public class Consultation
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int ClientId { get; set; }
|
||||||
|
public DateTime ConsultationDate { get; set; }
|
||||||
|
public string? ServiceType { get; set; }
|
||||||
|
public string Summary { get; set; } = null!;
|
||||||
|
public string? Result { get; set; }
|
||||||
|
public decimal? Fee { get; set; }
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
namespace TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public class ConsultingActivity
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int ClientId { get; set; }
|
||||||
|
public string ActivityType { get; set; } = "";
|
||||||
|
public DateTime ActivityDate { get; set; }
|
||||||
|
public TimeOnly? ActivityTime { get; set; }
|
||||||
|
public int? AssignedConsultantId { get; set; }
|
||||||
|
public string Description { get; set; } = "";
|
||||||
|
public string? Outcome { get; set; }
|
||||||
|
public DateTime? NextFollowupDate { get; set; }
|
||||||
|
public string? Notes { get; set; }
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
namespace TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public class Contract
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int ClientId { get; set; }
|
||||||
|
public string ContractNumber { get; set; } = "";
|
||||||
|
public string ServiceType { get; set; } = "";
|
||||||
|
public DateTime ContractDate { get; set; }
|
||||||
|
public DateTime StartDate { get; set; }
|
||||||
|
public DateTime? EndDate { get; set; }
|
||||||
|
public decimal? MonthlyFee { get; set; }
|
||||||
|
public decimal? TotalAmount { get; set; }
|
||||||
|
public string PaymentStatus { get; set; } = "pending";
|
||||||
|
public string Status { get; set; } = "active";
|
||||||
|
public string? Notes { get; set; }
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
namespace TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public class Faq
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Question { get; set; } = null!;
|
||||||
|
public string Answer { get; set; } = null!;
|
||||||
|
public string? Category { get; set; }
|
||||||
|
public int SortOrder { get; set; }
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
}
|
||||||
@@ -10,5 +10,8 @@ public class Inquiry
|
|||||||
public string Message { get; set; } = null!;
|
public string Message { get; set; } = null!;
|
||||||
public string Status { get; set; } = "new";
|
public string Status { get; set; } = "new";
|
||||||
public string? IpAddress { get; set; }
|
public string? IpAddress { get; set; }
|
||||||
|
public int? ClientId { get; set; }
|
||||||
|
public string? AdminMemo { get; set; }
|
||||||
public DateTime CreatedAt { get; set; }
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public DateTime? UpdatedAt { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
namespace TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public class PortalUser
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int? ClientId { get; set; }
|
||||||
|
public string Email { get; set; } = "";
|
||||||
|
public string Name { get; set; } = "";
|
||||||
|
public string? Phone { get; set; }
|
||||||
|
public string Provider { get; set; } = "local";
|
||||||
|
public string? ProviderId { get; set; }
|
||||||
|
public string? PasswordHash { get; set; }
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
namespace TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public class RevenueTracking
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int ClientId { get; set; }
|
||||||
|
public string InvoiceNumber { get; set; } = "";
|
||||||
|
public DateTime InvoiceDate { get; set; }
|
||||||
|
public string? ServiceType { get; set; }
|
||||||
|
public decimal Amount { get; set; }
|
||||||
|
public string PaymentStatus { get; set; } = "pending";
|
||||||
|
public DateTime? PaymentDate { get; set; }
|
||||||
|
public DateTime? DueDate { get; set; }
|
||||||
|
public string? Notes { get; set; }
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
namespace TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public class TaxFiling
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int ClientId { get; set; }
|
||||||
|
public string FilingType { get; set; } = null!;
|
||||||
|
public DateTime DueDate { get; set; }
|
||||||
|
public string Status { get; set; } = "pending";
|
||||||
|
public string? Memo { get; set; }
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
// join
|
||||||
|
public string? ClientName { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
namespace TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public class TaxFilingSchedule
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int ClientId { get; set; }
|
||||||
|
public string FilingType { get; set; } = "";
|
||||||
|
public DateTime DueDate { get; set; }
|
||||||
|
public int FilingYear { get; set; }
|
||||||
|
public string Status { get; set; } = "pending";
|
||||||
|
public int? AssignedToId { get; set; }
|
||||||
|
public DateTime? CompletedDate { get; set; }
|
||||||
|
public string? Notes { get; set; }
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
namespace TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public class TaxProfile
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int ClientId { get; set; }
|
||||||
|
public string? BusinessRegistration { get; set; }
|
||||||
|
public string? BusinessType { get; set; }
|
||||||
|
public DateTime? EstablishmentDate { get; set; }
|
||||||
|
public string? AnnualRevenueRange { get; set; }
|
||||||
|
public int? EmployeeCount { get; set; }
|
||||||
|
public string? AccountingMethod { get; set; }
|
||||||
|
public string? FiscalYearEnd { get; set; }
|
||||||
|
public DateTime? LastFilingDate { get; set; }
|
||||||
|
public DateTime? NextFilingDueDate { get; set; }
|
||||||
|
public string TaxRiskLevel { get; set; } = "normal";
|
||||||
|
public bool PreviousAuditHistory { get; set; }
|
||||||
|
public string? SpecialNotes { get; set; }
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@ namespace TaxBaik.Domain.Enums;
|
|||||||
public enum InquiryStatus
|
public enum InquiryStatus
|
||||||
{
|
{
|
||||||
New = 0,
|
New = 0,
|
||||||
Contacted = 1,
|
Consulting = 1,
|
||||||
Completed = 2
|
Contracted = 2,
|
||||||
|
Rejected = 3,
|
||||||
|
Closed = 4
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ public interface IBlogPostRepository
|
|||||||
Task<BlogPost?> GetBySlugAsync(string slug, CancellationToken cancellationToken = default);
|
Task<BlogPost?> GetBySlugAsync(string slug, CancellationToken cancellationToken = default);
|
||||||
Task<(IEnumerable<BlogPost> Items, int Total)> GetPublishedPagedAsync(
|
Task<(IEnumerable<BlogPost> Items, int Total)> GetPublishedPagedAsync(
|
||||||
int page, int pageSize, int? categoryId = null, CancellationToken cancellationToken = default);
|
int page, int pageSize, int? categoryId = null, CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<BlogPost>> GetByCategorySlugAsync(string categorySlug, int limit, CancellationToken cancellationToken = default);
|
||||||
Task<IEnumerable<BlogPost>> GetAllForAdminAsync(CancellationToken cancellationToken = default);
|
Task<IEnumerable<BlogPost>> GetAllForAdminAsync(CancellationToken cancellationToken = default);
|
||||||
Task<(IEnumerable<BlogPost> Items, int Total)> GetAdminPagedAsync(
|
Task<(IEnumerable<BlogPost> Items, int Total)> GetAdminPagedAsync(
|
||||||
int page, int pageSize, CancellationToken cancellationToken = default);
|
int page, int pageSize, CancellationToken cancellationToken = default);
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
namespace TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public interface IClientRepository
|
||||||
|
{
|
||||||
|
Task<(IEnumerable<Client> Items, int Total)> GetPagedAsync(
|
||||||
|
int page, int pageSize, string? status = null, string? search = null,
|
||||||
|
CancellationToken ct = default);
|
||||||
|
Task<Client?> GetByIdAsync(int id, CancellationToken ct = default);
|
||||||
|
Task<Client?> GetByEmailAsync(string email, CancellationToken ct = default);
|
||||||
|
Task<Client?> GetByPhoneAsync(string phone, CancellationToken ct = default);
|
||||||
|
Task<int> CountByCreatedAtRangeAsync(DateTime startDateUtc, DateTime endDateUtc, CancellationToken ct = default);
|
||||||
|
Task<int> CreateAsync(Client client, CancellationToken ct = default);
|
||||||
|
Task UpdateAsync(Client client, CancellationToken ct = default);
|
||||||
|
Task DeleteAsync(int id, CancellationToken ct = default);
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
namespace TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public interface ICompanyRepository
|
||||||
|
{
|
||||||
|
Task<int> CreateAsync(Company company, CancellationToken cancellationToken = default);
|
||||||
|
Task<Company?> GetByIdAsync(int id, CancellationToken cancellationToken = default);
|
||||||
|
Task<Company?> GetByCodeAsync(string code, CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<Company>> GetAllActiveAsync(CancellationToken cancellationToken = default);
|
||||||
|
Task<(IEnumerable<Company> Items, int Total)> GetPagedAsync(int page, int pageSize, CancellationToken cancellationToken = default);
|
||||||
|
Task UpdateAsync(Company company, CancellationToken cancellationToken = default);
|
||||||
|
Task DeleteAsync(int id, CancellationToken cancellationToken = default);
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public interface IConsultationRepository
|
||||||
|
{
|
||||||
|
Task<IEnumerable<Consultation>> GetByClientIdAsync(int clientId, CancellationToken ct = default);
|
||||||
|
Task<int> CreateAsync(Consultation consultation, CancellationToken ct = default);
|
||||||
|
Task DeleteAsync(int id, CancellationToken ct = default);
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
namespace TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public interface IConsultingActivityRepository
|
||||||
|
{
|
||||||
|
Task<int> CreateAsync(ConsultingActivity activity, CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<ConsultingActivity>> GetAllAsync(CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<ConsultingActivity>> GetByClientIdAsync(int clientId, CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<ConsultingActivity>> GetPendingFollowupsAsync(CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<ConsultingActivity>> GetByConsultantAsync(int consultantId, DateTime fromDate, CancellationToken cancellationToken = default);
|
||||||
|
Task UpdateAsync(ConsultingActivity activity, CancellationToken cancellationToken = default);
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
namespace TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public interface IContractRepository
|
||||||
|
{
|
||||||
|
Task<int> CreateAsync(Contract contract, CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<Contract>> GetAllAsync(CancellationToken cancellationToken = default);
|
||||||
|
Task<Contract?> GetByIdAsync(int id, CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<Contract>> GetByClientIdAsync(int clientId, CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<Contract>> GetActiveContractsAsync(CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<Contract>> GetExpiringContractsAsync(int daysAhead = 30, CancellationToken cancellationToken = default);
|
||||||
|
Task UpdateAsync(Contract contract, CancellationToken cancellationToken = default);
|
||||||
|
Task<decimal> GetMonthlyRecurringRevenueAsync(CancellationToken cancellationToken = default);
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
namespace TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public interface IFaqRepository
|
||||||
|
{
|
||||||
|
Task<IEnumerable<Faq>> GetActiveAsync(CancellationToken ct = default);
|
||||||
|
Task<IEnumerable<Faq>> GetAllAsync(CancellationToken ct = default);
|
||||||
|
Task<Faq?> GetByIdAsync(int id, CancellationToken ct = default);
|
||||||
|
Task<int> CreateAsync(Faq faq, CancellationToken ct = default);
|
||||||
|
Task UpdateAsync(Faq faq, CancellationToken ct = default);
|
||||||
|
Task DeleteAsync(int id, CancellationToken ct = default);
|
||||||
|
}
|
||||||
@@ -11,5 +11,10 @@ public interface IInquiryRepository
|
|||||||
Task<int> CountAsync(CancellationToken cancellationToken = default);
|
Task<int> CountAsync(CancellationToken cancellationToken = default);
|
||||||
Task<int> CountThisMonthAsync(CancellationToken cancellationToken = default);
|
Task<int> CountThisMonthAsync(CancellationToken cancellationToken = default);
|
||||||
Task<int> CountByStatusAsync(string status, CancellationToken cancellationToken = default);
|
Task<int> CountByStatusAsync(string status, CancellationToken cancellationToken = default);
|
||||||
|
Task<int> CountByDateRangeAsync(DateTime startDate, DateTime endDate, CancellationToken cancellationToken = default);
|
||||||
|
Task<int> CountByStatusAndDateAsync(string status, DateTime startDate, DateTime endDate, CancellationToken cancellationToken = default);
|
||||||
Task UpdateStatusAsync(int id, string status, CancellationToken cancellationToken = default);
|
Task UpdateStatusAsync(int id, string status, CancellationToken cancellationToken = default);
|
||||||
|
Task UpdateAdminMemoAsync(int id, string? adminMemo, CancellationToken cancellationToken = default);
|
||||||
|
Task LinkClientAsync(int inquiryId, int clientId, CancellationToken cancellationToken = default);
|
||||||
|
Task DeleteAsync(int id, CancellationToken cancellationToken = default);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public interface IPortalUserRepository
|
||||||
|
{
|
||||||
|
Task<PortalUser?> GetByIdAsync(int id, CancellationToken ct = default);
|
||||||
|
Task<PortalUser?> GetByEmailAsync(string email, CancellationToken ct = default);
|
||||||
|
Task<PortalUser?> GetByProviderAsync(string provider, string providerId, CancellationToken ct = default);
|
||||||
|
Task<int> CreateAsync(PortalUser user, CancellationToken ct = default);
|
||||||
|
Task UpdateAsync(PortalUser user, CancellationToken ct = default);
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
namespace TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public interface IRevenueTrackingRepository
|
||||||
|
{
|
||||||
|
Task<int> CreateAsync(RevenueTracking revenue, CancellationToken cancellationToken = default);
|
||||||
|
Task<RevenueTracking?> GetByIdAsync(int id, CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<RevenueTracking>> GetAllAsync(CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<RevenueTracking>> GetByClientIdAsync(int clientId, CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<RevenueTracking>> GetPendingPaymentsAsync(CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<RevenueTracking>> GetByDateRangeAsync(DateTime startDate, DateTime endDate, CancellationToken cancellationToken = default);
|
||||||
|
Task UpdateAsync(RevenueTracking revenue, CancellationToken cancellationToken = default);
|
||||||
|
Task MarkPaidAsync(int id, DateTime paymentDate, CancellationToken cancellationToken = default);
|
||||||
|
Task<decimal> GetTotalRevenueAsync(DateTime startDate, DateTime endDate, CancellationToken cancellationToken = default);
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
namespace TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public interface ITaxFilingRepository
|
||||||
|
{
|
||||||
|
Task<IEnumerable<TaxFiling>> GetByClientIdAsync(int clientId, CancellationToken ct = default);
|
||||||
|
Task<IEnumerable<TaxFiling>> GetUpcomingAsync(int daysAhead, CancellationToken ct = default);
|
||||||
|
Task<TaxFiling?> GetByIdAsync(int id, CancellationToken ct = default);
|
||||||
|
Task<int> CreateAsync(TaxFiling filing, CancellationToken ct = default);
|
||||||
|
Task UpdateAsync(TaxFiling filing, CancellationToken ct = default);
|
||||||
|
Task DeleteAsync(int id, CancellationToken ct = default);
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
namespace TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public interface ITaxFilingScheduleRepository
|
||||||
|
{
|
||||||
|
Task<int> CreateAsync(TaxFilingSchedule schedule, CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<TaxFilingSchedule>> GetAllAsync(CancellationToken cancellationToken = default);
|
||||||
|
Task<TaxFilingSchedule?> GetByIdAsync(int id, CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<TaxFilingSchedule>> GetByClientIdAsync(int clientId, CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<TaxFilingSchedule>> GetUpcomingDuesAsync(int daysAhead = 30, CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<TaxFilingSchedule>> GetByStatusAsync(string status, CancellationToken cancellationToken = default);
|
||||||
|
Task UpdateAsync(TaxFilingSchedule schedule, CancellationToken cancellationToken = default);
|
||||||
|
Task MarkCompletedAsync(int id, CancellationToken cancellationToken = default);
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
namespace TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
|
||||||
|
public interface ITaxProfileRepository
|
||||||
|
{
|
||||||
|
Task<int> CreateAsync(TaxProfile profile, CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<TaxProfile>> GetAllAsync(CancellationToken cancellationToken = default);
|
||||||
|
Task<TaxProfile?> GetByClientIdAsync(int clientId, CancellationToken cancellationToken = default);
|
||||||
|
Task UpdateAsync(TaxProfile profile, CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<TaxProfile>> GetByRiskLevelAsync(string riskLevel, CancellationToken cancellationToken = default);
|
||||||
|
Task<IEnumerable<TaxProfile>> GetUpcomingFilingDuesAsync(DateTime startDate, DateTime endDate, CancellationToken cancellationToken = default);
|
||||||
|
}
|
||||||
@@ -16,6 +16,17 @@ public static class DependencyInjection
|
|||||||
services.AddScoped<IInquiryRepository, InquiryRepository>();
|
services.AddScoped<IInquiryRepository, InquiryRepository>();
|
||||||
services.AddScoped<ISiteSettingRepository, SiteSettingRepository>();
|
services.AddScoped<ISiteSettingRepository, SiteSettingRepository>();
|
||||||
services.AddScoped<IAnnouncementRepository, AnnouncementRepository>();
|
services.AddScoped<IAnnouncementRepository, AnnouncementRepository>();
|
||||||
|
services.AddScoped<IClientRepository, ClientRepository>();
|
||||||
|
services.AddScoped<IFaqRepository, FaqRepository>();
|
||||||
|
services.AddScoped<IConsultationRepository, ConsultationRepository>();
|
||||||
|
services.AddScoped<IPortalUserRepository, PortalUserRepository>();
|
||||||
|
services.AddScoped<ITaxFilingRepository, TaxFilingRepository>();
|
||||||
|
services.AddScoped<ICompanyRepository, CompanyRepository>();
|
||||||
|
services.AddScoped<ITaxProfileRepository, TaxProfileRepository>();
|
||||||
|
services.AddScoped<ITaxFilingScheduleRepository, TaxFilingScheduleRepository>();
|
||||||
|
services.AddScoped<IConsultingActivityRepository, ConsultingActivityRepository>();
|
||||||
|
services.AddScoped<IContractRepository, ContractRepository>();
|
||||||
|
services.AddScoped<IRevenueTrackingRepository, RevenueTrackingRepository>();
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,21 @@ public class BlogPostRepository(IDbConnectionFactory connectionFactory) : BaseRe
|
|||||||
return (items, total);
|
return (items, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<BlogPost>> GetByCategorySlugAsync(string categorySlug, int limit, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<BlogPost>(
|
||||||
|
@"SELECT bp.id, bp.title, bp.slug, bp.category_id, bp.tags,
|
||||||
|
bp.published_at, bp.view_count, bp.seo_description, bp.thumbnail_url,
|
||||||
|
bp.is_published, bp.created_at, bp.updated_at, c.name AS category_name
|
||||||
|
FROM blog_posts bp
|
||||||
|
LEFT JOIN categories c ON bp.category_id = c.id
|
||||||
|
WHERE bp.is_published = TRUE AND c.slug = @CategorySlug
|
||||||
|
ORDER BY bp.published_at DESC
|
||||||
|
LIMIT @Limit",
|
||||||
|
new { CategorySlug = categorySlug, Limit = limit });
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<BlogPost>> GetAllForAdminAsync(CancellationToken cancellationToken = default)
|
public async Task<IEnumerable<BlogPost>> GetAllForAdminAsync(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
using var conn = Conn();
|
using var conn = Conn();
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
namespace TaxBaik.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
using Dapper;
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class ClientRepository(IDbConnectionFactory connectionFactory) : BaseRepository(connectionFactory), IClientRepository
|
||||||
|
{
|
||||||
|
private const string SelectColumns =
|
||||||
|
"id, name, company_name, phone, email, service_type, tax_type, status, source, memo, created_at, updated_at";
|
||||||
|
|
||||||
|
public async Task<(IEnumerable<Client> Items, int Total)> GetPagedAsync(
|
||||||
|
int page, int pageSize, string? status = null, string? search = null, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
var offset = (page - 1) * pageSize;
|
||||||
|
|
||||||
|
using var reader = await conn.QueryMultipleAsync(
|
||||||
|
$@"SELECT {SelectColumns} FROM clients
|
||||||
|
WHERE (@Status::text IS NULL OR status = @Status)
|
||||||
|
AND (@Search::text IS NULL OR name ILIKE @SearchLike OR phone ILIKE @SearchLike OR company_name ILIKE @SearchLike)
|
||||||
|
ORDER BY created_at DESC
|
||||||
|
LIMIT @PageSize OFFSET @Offset;
|
||||||
|
|
||||||
|
SELECT COUNT(*) FROM clients
|
||||||
|
WHERE (@Status::text IS NULL OR status = @Status)
|
||||||
|
AND (@Search::text IS NULL OR name ILIKE @SearchLike OR phone ILIKE @SearchLike OR company_name ILIKE @SearchLike);",
|
||||||
|
new { Status = status, Search = search, SearchLike = string.IsNullOrEmpty(search) ? null : $"%{search}%", PageSize = pageSize, Offset = offset });
|
||||||
|
|
||||||
|
var items = (await reader.ReadAsync<Client>()).ToList();
|
||||||
|
var total = await reader.ReadFirstAsync<int>();
|
||||||
|
return (items, total);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Client?> GetByIdAsync(int id, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstOrDefaultAsync<Client>(
|
||||||
|
$"SELECT {SelectColumns} FROM clients WHERE id = @Id",
|
||||||
|
new { Id = id });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Client?> GetByEmailAsync(string email, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstOrDefaultAsync<Client>(
|
||||||
|
$"SELECT {SelectColumns} FROM clients WHERE email = @Email",
|
||||||
|
new { Email = email });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Client?> GetByPhoneAsync(string phone, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstOrDefaultAsync<Client>(
|
||||||
|
$"SELECT {SelectColumns} FROM clients WHERE phone = @Phone",
|
||||||
|
new { Phone = phone });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> CountByCreatedAtRangeAsync(DateTime startDateUtc, DateTime endDateUtc, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.ExecuteScalarAsync<int>(
|
||||||
|
@"SELECT COUNT(*)
|
||||||
|
FROM clients
|
||||||
|
WHERE created_at >= @StartDateUtc
|
||||||
|
AND created_at <= @EndDateUtc",
|
||||||
|
new { StartDateUtc = startDateUtc, EndDateUtc = endDateUtc });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> CreateAsync(Client client, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstAsync<int>(
|
||||||
|
@"INSERT INTO clients (name, company_name, phone, email, service_type, tax_type, status, source, memo, created_at, updated_at)
|
||||||
|
VALUES (@Name, @CompanyName, @Phone, @Email, @ServiceType, @TaxType, @Status, @Source, @Memo, NOW(), NOW())
|
||||||
|
RETURNING id",
|
||||||
|
client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(Client client, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync(
|
||||||
|
@"UPDATE clients
|
||||||
|
SET name = @Name, company_name = @CompanyName, phone = @Phone, email = @Email,
|
||||||
|
service_type = @ServiceType, tax_type = @TaxType, status = @Status,
|
||||||
|
source = @Source, memo = @Memo, updated_at = NOW()
|
||||||
|
WHERE id = @Id",
|
||||||
|
client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAsync(int id, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync("DELETE FROM clients WHERE id = @Id", new { Id = id });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
namespace TaxBaik.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
using Dapper;
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class CompanyRepository(IDbConnectionFactory connectionFactory) : BaseRepository(connectionFactory), ICompanyRepository
|
||||||
|
{
|
||||||
|
public async Task<int> CreateAsync(Company company, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstAsync<int>(
|
||||||
|
@"INSERT INTO companies (company_code, company_name, contact_person, phone, email, memo, is_active, created_at, updated_at)
|
||||||
|
VALUES (@CompanyCode, @CompanyName, @ContactPerson, @Phone, @Email, @Memo, @IsActive, NOW(), NOW())
|
||||||
|
RETURNING id",
|
||||||
|
company);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Company?> GetByIdAsync(int id, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstOrDefaultAsync<Company>(
|
||||||
|
@"SELECT id, company_code, company_name, contact_person, phone, email, memo, is_active, created_at, updated_at
|
||||||
|
FROM companies WHERE id = @Id",
|
||||||
|
new { Id = id });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Company?> GetByCodeAsync(string code, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstOrDefaultAsync<Company>(
|
||||||
|
@"SELECT id, company_code, company_name, contact_person, phone, email, memo, is_active, created_at, updated_at
|
||||||
|
FROM companies WHERE company_code = @Code",
|
||||||
|
new { Code = code });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Company>> GetAllActiveAsync(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<Company>(
|
||||||
|
@"SELECT id, company_code, company_name, contact_person, phone, email, memo, is_active, created_at, updated_at
|
||||||
|
FROM companies WHERE is_active = TRUE ORDER BY company_name");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<(IEnumerable<Company> Items, int Total)> GetPagedAsync(int page, int pageSize, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
var offset = (page - 1) * pageSize;
|
||||||
|
|
||||||
|
using var reader = await conn.QueryMultipleAsync(
|
||||||
|
@"SELECT id, company_code, company_name, contact_person, phone, email, memo, is_active, created_at, updated_at
|
||||||
|
FROM companies
|
||||||
|
ORDER BY company_name
|
||||||
|
LIMIT @PageSize OFFSET @Offset;
|
||||||
|
|
||||||
|
SELECT COUNT(*) FROM companies;",
|
||||||
|
new { PageSize = pageSize, Offset = offset });
|
||||||
|
|
||||||
|
var items = (await reader.ReadAsync<Company>()).ToList();
|
||||||
|
var total = await reader.ReadFirstAsync<int>();
|
||||||
|
|
||||||
|
return (items, total);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(Company company, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync(
|
||||||
|
@"UPDATE companies
|
||||||
|
SET company_code = @CompanyCode, company_name = @CompanyName,
|
||||||
|
contact_person = @ContactPerson, phone = @Phone, email = @Email,
|
||||||
|
memo = @Memo, is_active = @IsActive, updated_at = NOW()
|
||||||
|
WHERE id = @Id",
|
||||||
|
company);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAsync(int id, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync("DELETE FROM companies WHERE id = @Id", new { Id = id });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
namespace TaxBaik.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
using Dapper;
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class ConsultationRepository(IDbConnectionFactory connectionFactory) : BaseRepository(connectionFactory), IConsultationRepository
|
||||||
|
{
|
||||||
|
public async Task<IEnumerable<Consultation>> GetByClientIdAsync(int clientId, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<Consultation>(
|
||||||
|
@"SELECT id, client_id, consultation_date, service_type, summary, result, fee, created_at
|
||||||
|
FROM consultations
|
||||||
|
WHERE client_id = @ClientId
|
||||||
|
ORDER BY consultation_date DESC, id DESC",
|
||||||
|
new { ClientId = clientId });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> CreateAsync(Consultation consultation, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstAsync<int>(
|
||||||
|
@"INSERT INTO consultations (client_id, consultation_date, service_type, summary, result, fee, created_at)
|
||||||
|
VALUES (@ClientId, @ConsultationDate, @ServiceType, @Summary, @Result, @Fee, NOW())
|
||||||
|
RETURNING id",
|
||||||
|
consultation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAsync(int id, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync("DELETE FROM consultations WHERE id = @Id", new { Id = id });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
namespace TaxBaik.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
using Dapper;
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class ConsultingActivityRepository(IDbConnectionFactory connectionFactory) : BaseRepository(connectionFactory), IConsultingActivityRepository
|
||||||
|
{
|
||||||
|
public async Task<int> CreateAsync(ConsultingActivity activity, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstAsync<int>(
|
||||||
|
@"INSERT INTO consulting_activities (client_id, activity_type, activity_date, activity_time, assigned_consultant, description, outcome, next_followup_date, notes, created_at, updated_at)
|
||||||
|
VALUES (@ClientId, @ActivityType, @ActivityDate, @ActivityTime, @AssignedConsultantId, @Description, @Outcome, @NextFollowupDate, @Notes, NOW(), NOW())
|
||||||
|
RETURNING id",
|
||||||
|
activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<ConsultingActivity>> GetAllAsync(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<ConsultingActivity>(
|
||||||
|
@"SELECT id, client_id, activity_type, activity_date, activity_time, assigned_consultant, description, outcome, next_followup_date, notes, created_at, updated_at
|
||||||
|
FROM consulting_activities ORDER BY activity_date DESC");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<ConsultingActivity>> GetByClientIdAsync(int clientId, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<ConsultingActivity>(
|
||||||
|
@"SELECT id, client_id, activity_type, activity_date, activity_time, assigned_consultant, description, outcome, next_followup_date, notes, created_at, updated_at
|
||||||
|
FROM consulting_activities WHERE client_id = @ClientId ORDER BY activity_date DESC",
|
||||||
|
new { ClientId = clientId });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<ConsultingActivity>> GetPendingFollowupsAsync(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<ConsultingActivity>(
|
||||||
|
@"SELECT id, client_id, activity_type, activity_date, activity_time, assigned_consultant, description, outcome, next_followup_date, notes, created_at, updated_at
|
||||||
|
FROM consulting_activities WHERE next_followup_date IS NOT NULL AND next_followup_date <= CURRENT_DATE
|
||||||
|
ORDER BY next_followup_date ASC");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<ConsultingActivity>> GetByConsultantAsync(int consultantId, DateTime fromDate, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<ConsultingActivity>(
|
||||||
|
@"SELECT id, client_id, activity_type, activity_date, activity_time, assigned_consultant, description, outcome, next_followup_date, notes, created_at, updated_at
|
||||||
|
FROM consulting_activities WHERE assigned_consultant = @ConsultantId AND activity_date >= @FromDate
|
||||||
|
ORDER BY activity_date DESC",
|
||||||
|
new { ConsultantId = consultantId, FromDate = fromDate });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(ConsultingActivity activity, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync(
|
||||||
|
@"UPDATE consulting_activities SET activity_type = @ActivityType, activity_date = @ActivityDate,
|
||||||
|
activity_time = @ActivityTime, assigned_consultant = @AssignedConsultantId, description = @Description,
|
||||||
|
outcome = @Outcome, next_followup_date = @NextFollowupDate, notes = @Notes, updated_at = NOW()
|
||||||
|
WHERE id = @Id",
|
||||||
|
activity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
namespace TaxBaik.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
using Dapper;
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class ContractRepository(IDbConnectionFactory connectionFactory) : BaseRepository(connectionFactory), IContractRepository
|
||||||
|
{
|
||||||
|
public async Task<int> CreateAsync(Contract contract, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstAsync<int>(
|
||||||
|
@"INSERT INTO contracts (client_id, contract_number, service_type, contract_date, start_date, end_date, monthly_fee, total_amount, payment_status, status, notes, created_at, updated_at)
|
||||||
|
VALUES (@ClientId, @ContractNumber, @ServiceType, @ContractDate, @StartDate, @EndDate, @MonthlyFee, @TotalAmount, @PaymentStatus, @Status, @Notes, NOW(), NOW())
|
||||||
|
RETURNING id",
|
||||||
|
contract);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Contract>> GetAllAsync(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<Contract>(
|
||||||
|
@"SELECT id, client_id, contract_number, service_type, contract_date, start_date, end_date, monthly_fee, total_amount, payment_status, status, notes, created_at, updated_at
|
||||||
|
FROM contracts ORDER BY contract_date DESC");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Contract?> GetByIdAsync(int id, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstOrDefaultAsync<Contract>(
|
||||||
|
@"SELECT id, client_id, contract_number, service_type, contract_date, start_date, end_date, monthly_fee, total_amount, payment_status, status, notes, created_at, updated_at
|
||||||
|
FROM contracts WHERE id = @Id",
|
||||||
|
new { Id = id });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Contract>> GetByClientIdAsync(int clientId, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<Contract>(
|
||||||
|
@"SELECT id, client_id, contract_number, service_type, contract_date, start_date, end_date, monthly_fee, total_amount, payment_status, status, notes, created_at, updated_at
|
||||||
|
FROM contracts WHERE client_id = @ClientId ORDER BY contract_date DESC",
|
||||||
|
new { ClientId = clientId });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Contract>> GetActiveContractsAsync(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<Contract>(
|
||||||
|
@"SELECT id, client_id, contract_number, service_type, contract_date, start_date, end_date, monthly_fee, total_amount, payment_status, status, notes, created_at, updated_at
|
||||||
|
FROM contracts WHERE status = 'active' ORDER BY client_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Contract>> GetExpiringContractsAsync(int daysAhead = 30, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<Contract>(
|
||||||
|
@"SELECT id, client_id, contract_number, service_type, contract_date, start_date, end_date, monthly_fee, total_amount, payment_status, status, notes, created_at, updated_at
|
||||||
|
FROM contracts
|
||||||
|
WHERE status = 'active' AND end_date IS NOT NULL AND end_date BETWEEN CURRENT_DATE AND CURRENT_DATE + INTERVAL '1 day' * @DaysAhead
|
||||||
|
ORDER BY end_date ASC",
|
||||||
|
new { DaysAhead = daysAhead });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(Contract contract, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync(
|
||||||
|
@"UPDATE contracts SET contract_number = @ContractNumber, service_type = @ServiceType, contract_date = @ContractDate,
|
||||||
|
start_date = @StartDate, end_date = @EndDate, monthly_fee = @MonthlyFee, total_amount = @TotalAmount,
|
||||||
|
payment_status = @PaymentStatus, status = @Status, notes = @Notes, updated_at = NOW()
|
||||||
|
WHERE id = @Id",
|
||||||
|
contract);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<decimal> GetMonthlyRecurringRevenueAsync(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
var result = await conn.QueryFirstAsync<decimal>(
|
||||||
|
@"SELECT COALESCE(SUM(monthly_fee), 0) FROM contracts WHERE status = 'active' AND monthly_fee IS NOT NULL");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
namespace TaxBaik.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
using Dapper;
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class FaqRepository(IDbConnectionFactory connectionFactory) : BaseRepository(connectionFactory), IFaqRepository
|
||||||
|
{
|
||||||
|
private const string SelectColumns =
|
||||||
|
"id, question, answer, category, sort_order, is_active, created_at, updated_at";
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Faq>> GetActiveAsync(CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<Faq>(
|
||||||
|
$"SELECT {SelectColumns} FROM faqs WHERE is_active = TRUE ORDER BY sort_order, id");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Faq>> GetAllAsync(CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<Faq>(
|
||||||
|
$"SELECT {SelectColumns} FROM faqs ORDER BY sort_order, id");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Faq?> GetByIdAsync(int id, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstOrDefaultAsync<Faq>(
|
||||||
|
$"SELECT {SelectColumns} FROM faqs WHERE id = @Id",
|
||||||
|
new { Id = id });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> CreateAsync(Faq faq, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstAsync<int>(
|
||||||
|
@"INSERT INTO faqs (question, answer, category, sort_order, is_active, created_at, updated_at)
|
||||||
|
VALUES (@Question, @Answer, @Category, @SortOrder, @IsActive, NOW(), NOW())
|
||||||
|
RETURNING id",
|
||||||
|
faq);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(Faq faq, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync(
|
||||||
|
@"UPDATE faqs
|
||||||
|
SET question = @Question, answer = @Answer, category = @Category,
|
||||||
|
sort_order = @SortOrder, is_active = @IsActive, updated_at = NOW()
|
||||||
|
WHERE id = @Id",
|
||||||
|
faq);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAsync(int id, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync("DELETE FROM faqs WHERE id = @Id", new { Id = id });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,9 @@ public class InquiryRepository(IDbConnectionFactory connectionFactory) : BaseRep
|
|||||||
{
|
{
|
||||||
using var conn = Conn();
|
using var conn = Conn();
|
||||||
return await conn.QueryFirstOrDefaultAsync<Inquiry>(
|
return await conn.QueryFirstOrDefaultAsync<Inquiry>(
|
||||||
"SELECT id, name, phone, email, service_type, message, status, ip_address, created_at FROM inquiries WHERE id = @Id",
|
@"SELECT id, name, phone, email, service_type, message, status, ip_address,
|
||||||
|
client_id, admin_memo, created_at, updated_at
|
||||||
|
FROM inquiries WHERE id = @Id",
|
||||||
new { Id = id });
|
new { Id = id });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +33,8 @@ public class InquiryRepository(IDbConnectionFactory connectionFactory) : BaseRep
|
|||||||
var offset = (page - 1) * pageSize;
|
var offset = (page - 1) * pageSize;
|
||||||
|
|
||||||
using var reader = await conn.QueryMultipleAsync(
|
using var reader = await conn.QueryMultipleAsync(
|
||||||
@"SELECT id, name, phone, email, service_type, message, status, ip_address, created_at
|
@"SELECT id, name, phone, email, service_type, message, status, ip_address,
|
||||||
|
client_id, admin_memo, created_at, updated_at
|
||||||
FROM inquiries
|
FROM inquiries
|
||||||
WHERE @Status::text IS NULL OR status = @Status
|
WHERE @Status::text IS NULL OR status = @Status
|
||||||
ORDER BY created_at DESC
|
ORDER BY created_at DESC
|
||||||
@@ -71,9 +74,55 @@ public class InquiryRepository(IDbConnectionFactory connectionFactory) : BaseRep
|
|||||||
new { Status = status });
|
new { Status = status });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<int> CountByDateRangeAsync(DateTime startDate, DateTime endDate, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.ExecuteScalarAsync<int>(
|
||||||
|
@"SELECT COUNT(*)
|
||||||
|
FROM inquiries
|
||||||
|
WHERE created_at >= @StartDate AND created_at <= @EndDate",
|
||||||
|
new { StartDate = startDate, EndDate = endDate });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> CountByStatusAndDateAsync(string status, DateTime startDate, DateTime endDate, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.ExecuteScalarAsync<int>(
|
||||||
|
@"SELECT COUNT(*)
|
||||||
|
FROM inquiries
|
||||||
|
WHERE status = @Status
|
||||||
|
AND created_at >= @StartDate
|
||||||
|
AND created_at <= @EndDate",
|
||||||
|
new { Status = status, StartDate = startDate, EndDate = endDate });
|
||||||
|
}
|
||||||
|
|
||||||
public async Task UpdateStatusAsync(int id, string status, CancellationToken cancellationToken = default)
|
public async Task UpdateStatusAsync(int id, string status, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
using var conn = Conn();
|
using var conn = Conn();
|
||||||
await conn.ExecuteAsync("UPDATE inquiries SET status = @Status WHERE id = @Id", new { Id = id, Status = status });
|
await conn.ExecuteAsync(
|
||||||
|
"UPDATE inquiries SET status = @Status, updated_at = NOW() WHERE id = @Id",
|
||||||
|
new { Id = id, Status = status });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAdminMemoAsync(int id, string? adminMemo, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync(
|
||||||
|
"UPDATE inquiries SET admin_memo = @AdminMemo, updated_at = NOW() WHERE id = @Id",
|
||||||
|
new { Id = id, AdminMemo = adminMemo });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task LinkClientAsync(int inquiryId, int clientId, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync(
|
||||||
|
"UPDATE inquiries SET client_id = @ClientId, updated_at = NOW() WHERE id = @Id",
|
||||||
|
new { Id = inquiryId, ClientId = clientId });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAsync(int id, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync("DELETE FROM inquiries WHERE id = @Id", new { Id = id });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
namespace TaxBaik.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
using Dapper;
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class PortalUserRepository(IDbConnectionFactory connectionFactory) : BaseRepository(connectionFactory), IPortalUserRepository
|
||||||
|
{
|
||||||
|
public async Task<PortalUser?> GetByIdAsync(int id, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstOrDefaultAsync<PortalUser>(
|
||||||
|
@"SELECT id, client_id, email, name, phone, provider, provider_id, password_hash, created_at
|
||||||
|
FROM portal_users
|
||||||
|
WHERE id = @Id",
|
||||||
|
new { Id = id });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PortalUser?> GetByEmailAsync(string email, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstOrDefaultAsync<PortalUser>(
|
||||||
|
@"SELECT id, client_id, email, name, phone, provider, provider_id, password_hash, created_at
|
||||||
|
FROM portal_users
|
||||||
|
WHERE email = @Email",
|
||||||
|
new { Email = email });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PortalUser?> GetByProviderAsync(string provider, string providerId, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstOrDefaultAsync<PortalUser>(
|
||||||
|
@"SELECT id, client_id, email, name, phone, provider, provider_id, password_hash, created_at
|
||||||
|
FROM portal_users
|
||||||
|
WHERE provider = @Provider AND provider_id = @ProviderId",
|
||||||
|
new { Provider = provider, ProviderId = providerId });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> CreateAsync(PortalUser user, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstAsync<int>(
|
||||||
|
@"INSERT INTO portal_users (client_id, email, name, phone, provider, provider_id, password_hash, created_at)
|
||||||
|
VALUES (@ClientId, @Email, @Name, @Phone, @Provider, @ProviderId, @PasswordHash, NOW())
|
||||||
|
RETURNING id",
|
||||||
|
user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(PortalUser user, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync(
|
||||||
|
@"UPDATE portal_users
|
||||||
|
SET client_id = @ClientId,
|
||||||
|
email = @Email,
|
||||||
|
name = @Name,
|
||||||
|
phone = @Phone,
|
||||||
|
provider = @Provider,
|
||||||
|
provider_id = @ProviderId,
|
||||||
|
password_hash = @PasswordHash
|
||||||
|
WHERE id = @Id",
|
||||||
|
user);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
namespace TaxBaik.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
using Dapper;
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class RevenueTrackingRepository(IDbConnectionFactory connectionFactory) : BaseRepository(connectionFactory), IRevenueTrackingRepository
|
||||||
|
{
|
||||||
|
public async Task<int> CreateAsync(RevenueTracking revenue, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstAsync<int>(
|
||||||
|
@"INSERT INTO revenue_tracking (client_id, invoice_number, invoice_date, service_type, amount, payment_status, payment_date, due_date, notes, created_at, updated_at)
|
||||||
|
VALUES (@ClientId, @InvoiceNumber, @InvoiceDate, @ServiceType, @Amount, @PaymentStatus, @PaymentDate, @DueDate, @Notes, NOW(), NOW())
|
||||||
|
RETURNING id",
|
||||||
|
revenue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<RevenueTracking>> GetAllAsync(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<RevenueTracking>(
|
||||||
|
@"SELECT id, client_id, invoice_number, invoice_date, service_type, amount, payment_status, payment_date, due_date, notes, created_at, updated_at
|
||||||
|
FROM revenue_tracking ORDER BY invoice_date DESC");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RevenueTracking?> GetByIdAsync(int id, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstOrDefaultAsync<RevenueTracking>(
|
||||||
|
@"SELECT id, client_id, invoice_number, invoice_date, service_type, amount, payment_status, payment_date, due_date, notes, created_at, updated_at
|
||||||
|
FROM revenue_tracking WHERE id = @Id",
|
||||||
|
new { Id = id });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<RevenueTracking>> GetByClientIdAsync(int clientId, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<RevenueTracking>(
|
||||||
|
@"SELECT id, client_id, invoice_number, invoice_date, service_type, amount, payment_status, payment_date, due_date, notes, created_at, updated_at
|
||||||
|
FROM revenue_tracking WHERE client_id = @ClientId ORDER BY invoice_date DESC",
|
||||||
|
new { ClientId = clientId });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<RevenueTracking>> GetPendingPaymentsAsync(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<RevenueTracking>(
|
||||||
|
@"SELECT id, client_id, invoice_number, invoice_date, service_type, amount, payment_status, payment_date, due_date, notes, created_at, updated_at
|
||||||
|
FROM revenue_tracking WHERE payment_status = 'pending' ORDER BY due_date ASC");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<RevenueTracking>> GetByDateRangeAsync(DateTime startDate, DateTime endDate, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<RevenueTracking>(
|
||||||
|
@"SELECT id, client_id, invoice_number, invoice_date, service_type, amount, payment_status, payment_date, due_date, notes, created_at, updated_at
|
||||||
|
FROM revenue_tracking WHERE invoice_date BETWEEN @StartDate AND @EndDate ORDER BY invoice_date DESC",
|
||||||
|
new { StartDate = startDate, EndDate = endDate });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(RevenueTracking revenue, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync(
|
||||||
|
@"UPDATE revenue_tracking SET invoice_number = @InvoiceNumber, invoice_date = @InvoiceDate,
|
||||||
|
service_type = @ServiceType, amount = @Amount, payment_status = @PaymentStatus,
|
||||||
|
payment_date = @PaymentDate, due_date = @DueDate, notes = @Notes, updated_at = NOW()
|
||||||
|
WHERE id = @Id",
|
||||||
|
revenue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task MarkPaidAsync(int id, DateTime paymentDate, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync(
|
||||||
|
@"UPDATE revenue_tracking SET payment_status = 'paid', payment_date = @PaymentDate, updated_at = NOW() WHERE id = @Id",
|
||||||
|
new { Id = id, PaymentDate = paymentDate });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<decimal> GetTotalRevenueAsync(DateTime startDate, DateTime endDate, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
var result = await conn.QueryFirstAsync<decimal>(
|
||||||
|
@"SELECT COALESCE(SUM(amount), 0) FROM revenue_tracking WHERE invoice_date BETWEEN @StartDate AND @EndDate",
|
||||||
|
new { StartDate = startDate, EndDate = endDate });
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
namespace TaxBaik.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
using Dapper;
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class TaxFilingRepository(IDbConnectionFactory connectionFactory) : BaseRepository(connectionFactory), ITaxFilingRepository
|
||||||
|
{
|
||||||
|
private const string SelectColumns = @"
|
||||||
|
tf.id, tf.client_id, c.name AS client_name, tf.filing_type, tf.due_date,
|
||||||
|
tf.status, tf.memo, tf.created_at, tf.updated_at";
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxFiling>> GetByClientIdAsync(int clientId, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<TaxFiling>(
|
||||||
|
$@"SELECT {SelectColumns}
|
||||||
|
FROM tax_filings tf
|
||||||
|
JOIN clients c ON c.id = tf.client_id
|
||||||
|
WHERE tf.client_id = @ClientId
|
||||||
|
ORDER BY tf.due_date ASC",
|
||||||
|
new { ClientId = clientId });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxFiling>> GetUpcomingAsync(int daysAhead, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<TaxFiling>(
|
||||||
|
$@"SELECT {SelectColumns}
|
||||||
|
FROM tax_filings tf
|
||||||
|
JOIN clients c ON c.id = tf.client_id
|
||||||
|
WHERE tf.status = 'pending'
|
||||||
|
AND tf.due_date <= CURRENT_DATE + @DaysAhead::int
|
||||||
|
AND tf.due_date >= CURRENT_DATE
|
||||||
|
ORDER BY tf.due_date ASC",
|
||||||
|
new { DaysAhead = daysAhead });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<TaxFiling?> GetByIdAsync(int id, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstOrDefaultAsync<TaxFiling>(
|
||||||
|
$@"SELECT {SelectColumns}
|
||||||
|
FROM tax_filings tf
|
||||||
|
JOIN clients c ON c.id = tf.client_id
|
||||||
|
WHERE tf.id = @Id",
|
||||||
|
new { Id = id });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> CreateAsync(TaxFiling filing, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstAsync<int>(
|
||||||
|
@"INSERT INTO tax_filings (client_id, filing_type, due_date, status, memo, created_at, updated_at)
|
||||||
|
VALUES (@ClientId, @FilingType, @DueDate, @Status, @Memo, NOW(), NOW())
|
||||||
|
RETURNING id",
|
||||||
|
filing);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(TaxFiling filing, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync(
|
||||||
|
@"UPDATE tax_filings
|
||||||
|
SET filing_type = @FilingType, due_date = @DueDate, status = @Status,
|
||||||
|
memo = @Memo, updated_at = NOW()
|
||||||
|
WHERE id = @Id",
|
||||||
|
filing);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAsync(int id, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync("DELETE FROM tax_filings WHERE id = @Id", new { Id = id });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
namespace TaxBaik.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
using Dapper;
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class TaxFilingScheduleRepository(IDbConnectionFactory connectionFactory) : BaseRepository(connectionFactory), ITaxFilingScheduleRepository
|
||||||
|
{
|
||||||
|
public async Task<int> CreateAsync(TaxFilingSchedule schedule, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstAsync<int>(
|
||||||
|
@"INSERT INTO tax_filing_schedules (client_id, filing_type, due_date, filing_year, status, assigned_to, notes, created_at, updated_at)
|
||||||
|
VALUES (@ClientId, @FilingType, @DueDate, @FilingYear, @Status, @AssignedToId, @Notes, NOW(), NOW())
|
||||||
|
RETURNING id",
|
||||||
|
schedule);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxFilingSchedule>> GetAllAsync(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<TaxFilingSchedule>(
|
||||||
|
@"SELECT id, client_id, filing_type, due_date, filing_year, status, assigned_to, completed_date, notes, created_at, updated_at
|
||||||
|
FROM tax_filing_schedules ORDER BY due_date DESC");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<TaxFilingSchedule?> GetByIdAsync(int id, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstOrDefaultAsync<TaxFilingSchedule>(
|
||||||
|
@"SELECT id, client_id, filing_type, due_date, filing_year, status, assigned_to, completed_date, notes, created_at, updated_at
|
||||||
|
FROM tax_filing_schedules WHERE id = @Id",
|
||||||
|
new { Id = id });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxFilingSchedule>> GetByClientIdAsync(int clientId, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<TaxFilingSchedule>(
|
||||||
|
@"SELECT id, client_id, filing_type, due_date, filing_year, status, assigned_to, completed_date, notes, created_at, updated_at
|
||||||
|
FROM tax_filing_schedules WHERE client_id = @ClientId ORDER BY due_date DESC",
|
||||||
|
new { ClientId = clientId });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxFilingSchedule>> GetUpcomingDuesAsync(int daysAhead = 30, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<TaxFilingSchedule>(
|
||||||
|
@"SELECT id, client_id, filing_type, due_date, filing_year, status, assigned_to, completed_date, notes, created_at, updated_at
|
||||||
|
FROM tax_filing_schedules
|
||||||
|
WHERE status = 'pending' AND due_date BETWEEN CURRENT_DATE AND CURRENT_DATE + INTERVAL '1 day' * @DaysAhead
|
||||||
|
ORDER BY due_date ASC",
|
||||||
|
new { DaysAhead = daysAhead });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxFilingSchedule>> GetByStatusAsync(string status, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<TaxFilingSchedule>(
|
||||||
|
@"SELECT id, client_id, filing_type, due_date, filing_year, status, assigned_to, completed_date, notes, created_at, updated_at
|
||||||
|
FROM tax_filing_schedules WHERE status = @Status ORDER BY due_date",
|
||||||
|
new { Status = status });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(TaxFilingSchedule schedule, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync(
|
||||||
|
@"UPDATE tax_filing_schedules SET filing_type = @FilingType, due_date = @DueDate, status = @Status,
|
||||||
|
assigned_to = @AssignedToId, notes = @Notes, updated_at = NOW() WHERE id = @Id",
|
||||||
|
schedule);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task MarkCompletedAsync(int id, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync(
|
||||||
|
@"UPDATE tax_filing_schedules SET status = 'completed', completed_date = NOW(), updated_at = NOW() WHERE id = @Id",
|
||||||
|
new { Id = id });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
namespace TaxBaik.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
using Dapper;
|
||||||
|
using TaxBaik.Domain.Entities;
|
||||||
|
using TaxBaik.Domain.Interfaces;
|
||||||
|
|
||||||
|
public class TaxProfileRepository(IDbConnectionFactory connectionFactory) : BaseRepository(connectionFactory), ITaxProfileRepository
|
||||||
|
{
|
||||||
|
public async Task<int> CreateAsync(TaxProfile profile, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstAsync<int>(
|
||||||
|
@"INSERT INTO tax_profiles (client_id, business_registration, business_type, establishment_date,
|
||||||
|
annual_revenue_range, employee_count, accounting_method, fiscal_year_end, last_filing_date,
|
||||||
|
next_filing_due_date, tax_risk_level, previous_audit_history, special_notes, created_at, updated_at)
|
||||||
|
VALUES (@ClientId, @BusinessRegistration, @BusinessType, @EstablishmentDate, @AnnualRevenueRange,
|
||||||
|
@EmployeeCount, @AccountingMethod, @FiscalYearEnd, @LastFilingDate, @NextFilingDueDate,
|
||||||
|
@TaxRiskLevel, @PreviousAuditHistory, @SpecialNotes, NOW(), NOW())
|
||||||
|
RETURNING id",
|
||||||
|
profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxProfile>> GetAllAsync(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<TaxProfile>(
|
||||||
|
@"SELECT id, client_id, business_registration, business_type, establishment_date,
|
||||||
|
annual_revenue_range, employee_count, accounting_method, fiscal_year_end, last_filing_date,
|
||||||
|
next_filing_due_date, tax_risk_level, previous_audit_history, special_notes, created_at, updated_at
|
||||||
|
FROM tax_profiles ORDER BY id DESC");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<TaxProfile?> GetByClientIdAsync(int clientId, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryFirstOrDefaultAsync<TaxProfile>(
|
||||||
|
@"SELECT id, client_id, business_registration, business_type, establishment_date,
|
||||||
|
annual_revenue_range, employee_count, accounting_method, fiscal_year_end, last_filing_date,
|
||||||
|
next_filing_due_date, tax_risk_level, previous_audit_history, special_notes, created_at, updated_at
|
||||||
|
FROM tax_profiles WHERE client_id = @ClientId",
|
||||||
|
new { ClientId = clientId });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(TaxProfile profile, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
await conn.ExecuteAsync(
|
||||||
|
@"UPDATE tax_profiles SET business_registration = @BusinessRegistration, business_type = @BusinessType,
|
||||||
|
establishment_date = @EstablishmentDate, annual_revenue_range = @AnnualRevenueRange,
|
||||||
|
employee_count = @EmployeeCount, accounting_method = @AccountingMethod, fiscal_year_end = @FiscalYearEnd,
|
||||||
|
last_filing_date = @LastFilingDate, next_filing_due_date = @NextFilingDueDate,
|
||||||
|
tax_risk_level = @TaxRiskLevel, previous_audit_history = @PreviousAuditHistory,
|
||||||
|
special_notes = @SpecialNotes, updated_at = NOW()
|
||||||
|
WHERE id = @Id",
|
||||||
|
profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxProfile>> GetByRiskLevelAsync(string riskLevel, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<TaxProfile>(
|
||||||
|
@"SELECT id, client_id, business_registration, business_type, establishment_date,
|
||||||
|
annual_revenue_range, employee_count, accounting_method, fiscal_year_end, last_filing_date,
|
||||||
|
next_filing_due_date, tax_risk_level, previous_audit_history, special_notes, created_at, updated_at
|
||||||
|
FROM tax_profiles WHERE tax_risk_level = @RiskLevel ORDER BY client_id",
|
||||||
|
new { RiskLevel = riskLevel });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TaxProfile>> GetUpcomingFilingDuesAsync(DateTime startDate, DateTime endDate, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using var conn = Conn();
|
||||||
|
return await conn.QueryAsync<TaxProfile>(
|
||||||
|
@"SELECT id, client_id, business_registration, business_type, establishment_date,
|
||||||
|
annual_revenue_range, employee_count, accounting_method, fiscal_year_end, last_filing_date,
|
||||||
|
next_filing_due_date, tax_risk_level, previous_audit_history, special_notes, created_at, updated_at
|
||||||
|
FROM tax_profiles WHERE next_filing_due_date BETWEEN @StartDate AND @EndDate
|
||||||
|
ORDER BY next_filing_due_date",
|
||||||
|
new { StartDate = startDate, EndDate = endDate });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
@using Microsoft.AspNetCore.Components.Web
|
@using Microsoft.AspNetCore.Components.Web
|
||||||
|
@using Microsoft.FluentUI.AspNetCore.Components
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="ko">
|
<html lang="ko">
|
||||||
<head>
|
<head>
|
||||||
@@ -6,27 +7,41 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>백원숙 세무회계 - 관리자</title>
|
<title>백원숙 세무회계 - 관리자</title>
|
||||||
<base href="/taxbaik/" />
|
<base href="/taxbaik/" />
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700&display=swap" rel="stylesheet" />
|
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700;800&display=swap" rel="stylesheet" />
|
||||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
|
||||||
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
|
<link rel="stylesheet" href="css/design-tokens.css" />
|
||||||
|
<link rel="stylesheet" href="css/ui-primitives.css" />
|
||||||
|
<link href="_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css" rel="stylesheet" />
|
||||||
<script>
|
<script>
|
||||||
document.documentElement.classList.toggle(
|
document.documentElement.classList.toggle(
|
||||||
'admin-login-route',
|
'admin-login-route',
|
||||||
window.location.pathname.toLowerCase().endsWith('/admin/login'));
|
window.location.pathname.toLowerCase().endsWith('/admin/login'));
|
||||||
</script>
|
</script>
|
||||||
<link rel="stylesheet" href="/taxbaik/css/admin.css" />
|
<link rel="stylesheet" href="css/admin.css" />
|
||||||
<component type="typeof(HeadOutlet)" render-mode="InteractiveServer" />
|
<component type="typeof(HeadOutlet)" render-mode="InteractiveServer" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="components-reconnect-modal" class="admin-reconnect-modal">
|
<div id="components-reconnect-modal" class="admin-reconnect-modal">
|
||||||
<div class="admin-reconnect-card">
|
<div class="admin-reconnect-card">
|
||||||
<strong>관리자 세션을 다시 연결하고 있습니다.</strong>
|
<strong>연결 재설정 중...</strong>
|
||||||
<span>배포 또는 서버 재시작 중이면 잠시 후 자동으로 새로고침됩니다.</span>
|
<span>새로운 버전으로 업데이트되었습니다.</span>
|
||||||
|
<span style="font-size: 0.85rem; margin-top: 0.5rem; opacity: 0.8;">자동으로 페이지를 새로고침합니다. 잠시만 기다려주세요.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="blazor-loading" class="blazor-loading-overlay show">
|
||||||
|
<div class="blazor-loading-spinner">
|
||||||
|
<div class="spinner"></div>
|
||||||
|
<p>로드 중...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<FluentProviders />
|
||||||
|
<FluentDialogProvider />
|
||||||
|
<FluentTooltipProvider />
|
||||||
|
|
||||||
<Routes @rendermode="new InteractiveServerRenderMode(prerender: false)" />
|
<Routes @rendermode="new InteractiveServerRenderMode(prerender: false)" />
|
||||||
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
|
|
||||||
<script src="/taxbaik/js/admin-session.js"></script>
|
<script src="js/admin-session.js"></script>
|
||||||
<script src="_framework/blazor.web.js"></script>
|
<script src="_framework/blazor.web.js"></script>
|
||||||
<script>window.taxbaikAdminSession?.watchReconnect();</script>
|
<script>window.taxbaikAdminSession?.watchReconnect();</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
@using MudBlazor
|
@using Microsoft.FluentUI.AspNetCore.Components
|
||||||
|
<div class="admin-dialog">
|
||||||
<MudDialog>
|
<div class="admin-dialog-title">삭제 확인</div>
|
||||||
<DialogContent>
|
<p class="admin-dialog-message">정말로 삭제하시겠습니까?</p>
|
||||||
<MudText>정말로 삭제하시겠습니까?</MudText>
|
<div class="admin-dialog-actions">
|
||||||
</DialogContent>
|
<FluentButton Appearance="ButtonAppearance.Transparent" @onclick="Cancel">취소</FluentButton>
|
||||||
<DialogActions>
|
<FluentButton Appearance="ButtonAppearance.Primary" @onclick="Confirm">삭제</FluentButton>
|
||||||
<MudButton OnClick="@Cancel">취소</MudButton>
|
</div>
|
||||||
<MudButton Color="Color.Error" OnClick="@Confirm">삭제</MudButton>
|
</div>
|
||||||
</DialogActions>
|
|
||||||
</MudDialog>
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
[CascadingParameter] MudDialogInstance? MudDialog { get; set; }
|
[Parameter] public EventCallback OnCancel { get; set; }
|
||||||
|
[Parameter] public EventCallback OnConfirm { get; set; }
|
||||||
|
|
||||||
void Cancel() => MudDialog?.Cancel();
|
Task Cancel() => OnCancel.InvokeAsync();
|
||||||
void Confirm() => MudDialog?.Close(DialogResult.Ok(true));
|
Task Confirm() => OnConfirm.InvokeAsync();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
@using TaxBaik.Application.Services
|
||||||
|
@using Microsoft.FluentUI.AspNetCore.Components
|
||||||
|
|
||||||
|
<form class="admin-form" @onsubmit="HandleSubmit" @onsubmit:preventDefault>
|
||||||
|
<FluentTextInput Label="회사 코드" @bind-CurrentValue="model.CompanyCode" />
|
||||||
|
<FluentTextInput Label="회사명" @bind-CurrentValue="model.CompanyName" />
|
||||||
|
<FluentTextInput Label="담당자명" @bind-CurrentValue="model.ContactPerson" />
|
||||||
|
<FluentTextInput Label="전화번호" @bind-CurrentValue="model.Phone" />
|
||||||
|
<FluentTextInput Label="이메일" @bind-CurrentValue="model.Email" />
|
||||||
|
<FluentTextArea Label="메모" @bind-CurrentValue="model.Memo" />
|
||||||
|
<label class="admin-checkbox-row">
|
||||||
|
<input type="checkbox" @bind="model.IsActive" />
|
||||||
|
<span>활성</span>
|
||||||
|
</label>
|
||||||
|
<div class="admin-form-actions">
|
||||||
|
<button type="submit" class="admin-login-submit">@ButtonText</button>
|
||||||
|
<button type="button" class="admin-secondary-button" @onclick="OnCancel">취소</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter, EditorRequired] public string ButtonText { get; set; } = "저장";
|
||||||
|
[Parameter] public EventCallback<CompanyFormModel> OnSubmit { get; set; }
|
||||||
|
[Parameter] public EventCallback OnCancel { get; set; }
|
||||||
|
[Parameter] public CompanyFormModel? InitialData { get; set; }
|
||||||
|
private CompanyFormModel model = new();
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
if (InitialData != null)
|
||||||
|
{
|
||||||
|
model = new CompanyFormModel
|
||||||
|
{
|
||||||
|
CompanyCode = InitialData.CompanyCode,
|
||||||
|
CompanyName = InitialData.CompanyName,
|
||||||
|
ContactPerson = InitialData.ContactPerson,
|
||||||
|
Phone = InitialData.Phone,
|
||||||
|
Email = InitialData.Email,
|
||||||
|
Memo = InitialData.Memo,
|
||||||
|
IsActive = InitialData.IsActive
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task HandleSubmit() => OnSubmit.InvokeAsync(model);
|
||||||
|
|
||||||
|
public class CompanyFormModel
|
||||||
|
{
|
||||||
|
public string CompanyCode { get; set; } = "";
|
||||||
|
public string CompanyName { get; set; } = "";
|
||||||
|
public string? ContactPerson { get; set; }
|
||||||
|
public string? Phone { get; set; }
|
||||||
|
public string? Email { get; set; }
|
||||||
|
public string? Memo { get; set; }
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
@using TaxBaik.Application.DTOs
|
||||||
|
@using TaxBaik.Application.Services
|
||||||
|
@using Microsoft.FluentUI.AspNetCore.Components
|
||||||
|
|
||||||
|
<form class="admin-form" @onsubmit="HandleSubmit" @onsubmit:preventDefault>
|
||||||
|
<FluentTextInput Label="이름" @bind-CurrentValue="model.Name" />
|
||||||
|
<FluentTextInput Label="전화번호 (예: 010-1234-5678)" @bind-CurrentValue="model.Phone" />
|
||||||
|
<FluentTextInput Label="이메일" @bind-CurrentValue="model.Email" />
|
||||||
|
<FluentSelect TValue="string" TOption="string" Label="문의 유형" @bind-CurrentValue="model.ServiceType">
|
||||||
|
<FluentOption Value="@("사업자세무")">사업자세무</FluentOption>
|
||||||
|
<FluentOption Value="@("부동산세금")">부동산세금</FluentOption>
|
||||||
|
<FluentOption Value="@("가족자산")">가족자산</FluentOption>
|
||||||
|
<FluentOption Value="@("기타")">기타</FluentOption>
|
||||||
|
</FluentSelect>
|
||||||
|
<FluentTextArea Label="문의 내용" @bind-CurrentValue="model.Message" />
|
||||||
|
<FluentSelect TValue="string" TOption="string" Label="상태" @bind-CurrentValue="model.Status">
|
||||||
|
<FluentOption Value="@("new")">신규</FluentOption>
|
||||||
|
<FluentOption Value="@("consulting")">상담중</FluentOption>
|
||||||
|
<FluentOption Value="@("contracted")">계약완료</FluentOption>
|
||||||
|
<FluentOption Value="@("rejected")">거절</FluentOption>
|
||||||
|
<FluentOption Value="@("closed")">종결</FluentOption>
|
||||||
|
</FluentSelect>
|
||||||
|
<FluentTextArea Label="관리 메모" @bind-CurrentValue="model.AdminMemo" />
|
||||||
|
|
||||||
|
<div class="admin-form-actions">
|
||||||
|
<button type="submit" class="admin-login-submit">@ButtonText</button>
|
||||||
|
<button type="button" class="admin-secondary-button" @onclick="OnCancel">취소</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter, EditorRequired] public string ButtonText { get; set; } = "저장";
|
||||||
|
[Parameter] public EventCallback<InquiryFormModel> OnSubmit { get; set; }
|
||||||
|
[Parameter] public EventCallback OnCancel { get; set; }
|
||||||
|
[Parameter] public InquiryFormModel? InitialData { get; set; }
|
||||||
|
private InquiryFormModel model = new();
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
if (InitialData != null)
|
||||||
|
{
|
||||||
|
model = new InquiryFormModel
|
||||||
|
{
|
||||||
|
Name = InitialData.Name,
|
||||||
|
Phone = InitialData.Phone,
|
||||||
|
Email = InitialData.Email,
|
||||||
|
ServiceType = InitialData.ServiceType,
|
||||||
|
Message = InitialData.Message,
|
||||||
|
Status = InitialData.Status,
|
||||||
|
AdminMemo = InitialData.AdminMemo
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task HandleSubmit() => OnSubmit.InvokeAsync(model);
|
||||||
|
|
||||||
|
public class InquiryFormModel
|
||||||
|
{
|
||||||
|
public string Name { get; set; } = "";
|
||||||
|
public string Phone { get; set; } = "";
|
||||||
|
public string? Email { get; set; }
|
||||||
|
public string ServiceType { get; set; } = "기타";
|
||||||
|
public string Message { get; set; } = "";
|
||||||
|
public string Status { get; set; } = "new";
|
||||||
|
public string? AdminMemo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
@using TaxBaik.Application.Services
|
<div class="admin-table-wrap">
|
||||||
@inject InquiryService InquiryService
|
<table class="admin-table mt-4">
|
||||||
|
|
||||||
<MudSimpleTable Striped="true" Dense="true" Class="admin-table mt-4">
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>이름</th>
|
<th>이름</th>
|
||||||
@@ -21,40 +19,40 @@
|
|||||||
<td>@inquiry.Phone</td>
|
<td>@inquiry.Phone</td>
|
||||||
<td>@inquiry.ServiceType</td>
|
<td>@inquiry.ServiceType</td>
|
||||||
<td>
|
<td>
|
||||||
<MudChip Size="Size.Small" Color="@GetStatusColor(inquiry.Status)">
|
<span class="status-pill @GetStatusClass(inquiry.Status)">@GetStatusLabel(inquiry.Status)</span>
|
||||||
@GetStatusLabel(inquiry.Status)
|
|
||||||
</MudChip>
|
|
||||||
</td>
|
</td>
|
||||||
<td>@GetPreview(inquiry.Message)</td>
|
<td>@GetPreview(inquiry.Message)</td>
|
||||||
<td>@inquiry.CreatedAt.ToString("yyyy-MM-dd")</td>
|
<td>@inquiry.CreatedAt.ToString("yyyy-MM-dd")</td>
|
||||||
<td>
|
<td>
|
||||||
<MudButton Size="Size.Small" Variant="Variant.Outlined" Color="Color.Primary"
|
<a class="site-button secondary" href="@($"/taxbaik/admin/inquiries/{inquiry.Id}")">보기</a>
|
||||||
Href="@($"/taxbaik/admin/inquiries/{inquiry.Id}")">문의 내용 확인</MudButton>
|
<a class="site-button secondary" href="@($"/taxbaik/admin/inquiries/{inquiry.Id}/edit")">수정</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</MudSimpleTable>
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
[Parameter, EditorRequired]
|
||||||
|
public IReadOnlyList<Domain.Entities.Inquiry> Inquiries { get; set; } = [];
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string Status { get; set; } = "";
|
public string Status { get; set; } = "";
|
||||||
|
|
||||||
private List<Domain.Entities.Inquiry> inquiries = [];
|
private IReadOnlyList<Domain.Entities.Inquiry> filteredInquiries = [];
|
||||||
private List<Domain.Entities.Inquiry> filteredInquiries = [];
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
var (items, _) = await InquiryService.GetPagedAsync(1, 100);
|
if (Inquiries == null || Inquiries.Count == 0)
|
||||||
inquiries = items.ToList();
|
{
|
||||||
FilterInquiries();
|
filteredInquiries = [];
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
private void FilterInquiries()
|
|
||||||
{
|
|
||||||
filteredInquiries = string.IsNullOrEmpty(Status)
|
filteredInquiries = string.IsNullOrEmpty(Status)
|
||||||
? inquiries
|
? Inquiries
|
||||||
: inquiries.Where(x => x.Status == Status).ToList();
|
: Inquiries.Where(x => x.Status == Status).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetPreview(string message)
|
private static string GetPreview(string message)
|
||||||
@@ -66,24 +64,15 @@
|
|||||||
return trimmed.Length <= 30 ? trimmed : $"{trimmed[..30]}...";
|
return trimmed.Length <= 30 ? trimmed : $"{trimmed[..30]}...";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Color GetStatusColor(string status) => status switch
|
private static string GetStatusClass(string status) => status switch
|
||||||
{
|
{
|
||||||
"new" => Color.Warning,
|
"new" => "warning",
|
||||||
"contacted" => Color.Info,
|
"consulting" => "info",
|
||||||
"completed" => Color.Success,
|
"contracted" => "success",
|
||||||
_ => Color.Default
|
"rejected" => "danger",
|
||||||
|
"closed" => "muted",
|
||||||
|
_ => "muted"
|
||||||
};
|
};
|
||||||
|
|
||||||
private static string GetStatusLabel(string status) => status switch
|
private static string GetStatusLabel(string status) => InquiryStatusMapper.Labels.GetValueOrDefault(status, status);
|
||||||
{
|
|
||||||
"new" => "신규",
|
|
||||||
"contacted" => "연락함",
|
|
||||||
"completed" => "완료",
|
|
||||||
_ => status
|
|
||||||
};
|
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
|
||||||
{
|
|
||||||
FilterInquiries();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,70 +1,115 @@
|
|||||||
@inherits LayoutComponentBase
|
@inherits LayoutComponentBase
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
@implements IDisposable
|
||||||
|
|
||||||
|
<div class="admin-shell">
|
||||||
|
<header class="admin-topbar">
|
||||||
|
<button type="button" class="admin-icon-button admin-menu-button" @onclick="ToggleDrawer" aria-label="메뉴 열기">
|
||||||
|
<span class="material-icons">menu</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
<MudLayout Class="admin-shell">
|
|
||||||
<MudAppBar Elevation="0" Class="admin-topbar">
|
|
||||||
<MudIconButton Icon="@Icons.Material.Filled.Menu"
|
|
||||||
Color="Color.Inherit"
|
|
||||||
Edge="Edge.Start"
|
|
||||||
Class="admin-menu-button"
|
|
||||||
OnClick="@ToggleDrawer" />
|
|
||||||
<div class="admin-topbar-title">
|
<div class="admin-topbar-title">
|
||||||
<MudText Typo="Typo.caption">TaxBaik Backoffice</MudText>
|
<span class="admin-topbar-kicker">TaxBaik Admin</span>
|
||||||
<MudText Typo="Typo.h6">백원숙 세무회계 관리자</MudText>
|
<h1>세무회계 관리 대시보드</h1>
|
||||||
</div>
|
</div>
|
||||||
<MudSpacer />
|
|
||||||
<MudButton Class="admin-topbar-action"
|
|
||||||
Variant="Variant.Outlined"
|
|
||||||
Color="Color.Inherit"
|
|
||||||
StartIcon="@Icons.Material.Filled.OpenInNew"
|
|
||||||
Href="/taxbaik">
|
|
||||||
공개 사이트
|
|
||||||
</MudButton>
|
|
||||||
<MudButton Class="admin-topbar-action"
|
|
||||||
Variant="Variant.Filled"
|
|
||||||
Color="Color.Primary"
|
|
||||||
StartIcon="@Icons.Material.Filled.Logout"
|
|
||||||
Href="/taxbaik/admin/logout">
|
|
||||||
로그아웃
|
|
||||||
</MudButton>
|
|
||||||
</MudAppBar>
|
|
||||||
|
|
||||||
<MudDrawer @bind-open="@drawerOpen"
|
<div class="admin-topbar-actions">
|
||||||
Elevation="0"
|
<a class="admin-topbar-action" href="/taxbaik" target="_blank" rel="noreferrer">
|
||||||
Variant="DrawerVariant.Responsive"
|
<span class="material-icons">open_in_new</span>
|
||||||
Breakpoint="Breakpoint.Md"
|
공개 사이트
|
||||||
Class="admin-drawer">
|
</a>
|
||||||
|
<a class="admin-topbar-action danger" href="/taxbaik/admin/logout">
|
||||||
|
<span class="material-icons">logout</span>
|
||||||
|
로그아웃
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<aside class="@DrawerClass">
|
||||||
<div class="admin-drawer-brand">
|
<div class="admin-drawer-brand">
|
||||||
<div class="admin-brand-mark">T</div>
|
<div class="admin-brand-mark">T</div>
|
||||||
<div>
|
<div>
|
||||||
<MudText Typo="Typo.subtitle1">TaxBaik</MudText>
|
<div class="admin-brand-title">TaxBaik</div>
|
||||||
<MudText Typo="Typo.caption">세무 운영 콘솔</MudText>
|
<div class="admin-brand-subtitle">세무 운영 콘솔</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<MudNavMenu Class="admin-nav">
|
|
||||||
<MudNavLink Href="/taxbaik/admin/dashboard" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Dashboard">대시보드</MudNavLink>
|
|
||||||
<MudNavLink Href="/taxbaik/admin/announcements" Icon="@Icons.Material.Filled.Campaign">공지사항</MudNavLink>
|
|
||||||
<MudNavLink Href="/taxbaik/admin/blog" Icon="@Icons.Material.Filled.Article">블로그 관리</MudNavLink>
|
|
||||||
<MudNavLink Href="/taxbaik/admin/inquiries" Icon="@Icons.Material.Filled.Forum">문의 관리</MudNavLink>
|
|
||||||
<MudNavLink Href="/taxbaik/admin/settings" Icon="@Icons.Material.Filled.Tune">설정</MudNavLink>
|
|
||||||
</MudNavMenu>
|
|
||||||
<div class="admin-drawer-footer">
|
|
||||||
<MudText Typo="Typo.caption">운영 기준</MudText>
|
|
||||||
<MudText Typo="Typo.body2">변경 사항은 배포 후 Playwright로 검증합니다.</MudText>
|
|
||||||
</div>
|
|
||||||
</MudDrawer>
|
|
||||||
|
|
||||||
<MudMainContent Class="admin-main">
|
<nav class="admin-nav">
|
||||||
<MudContainer MaxWidth="MaxWidth.False" Class="admin-content">
|
<a href="/taxbaik/admin/dashboard" class="admin-nav-link">대시보드</a>
|
||||||
|
|
||||||
|
<details open>
|
||||||
|
<summary>CRM & 세무관리</summary>
|
||||||
|
<a href="/taxbaik/admin/tax-profiles" class="admin-nav-link">세무 프로필</a>
|
||||||
|
<a href="/taxbaik/admin/tax-filing-schedules" class="admin-nav-link">신고 일정</a>
|
||||||
|
<a href="/taxbaik/admin/contracts" class="admin-nav-link">계약 관리</a>
|
||||||
|
<a href="/taxbaik/admin/consulting-activities" class="admin-nav-link">상담 활동</a>
|
||||||
|
<a href="/taxbaik/admin/revenue-trackings" class="admin-nav-link">수익 추적</a>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>고객 관리</summary>
|
||||||
|
<a href="/taxbaik/admin/clients" class="admin-nav-link">고객 카드</a>
|
||||||
|
<a href="/taxbaik/admin/tax-filings" class="admin-nav-link">세무신고</a>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>홈페이지</summary>
|
||||||
|
<a href="/taxbaik/admin/announcements" class="admin-nav-link">공지사항</a>
|
||||||
|
<a href="/taxbaik/admin/faqs" class="admin-nav-link">FAQ 관리</a>
|
||||||
|
<a href="/taxbaik/admin/blog" class="admin-nav-link">블로그 관리</a>
|
||||||
|
<a href="/taxbaik/admin/season-simulator" class="admin-nav-link">시즌 시뮬레이터</a>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<a href="/taxbaik/admin/inquiries" class="admin-nav-link">문의 관리</a>
|
||||||
|
<a href="/taxbaik/admin/settings" class="admin-nav-link">설정</a>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="admin-drawer-footer">
|
||||||
|
<div class="admin-footer-item">
|
||||||
|
<span class="material-icons">shield</span>
|
||||||
|
<span>보안 모드</span>
|
||||||
|
</div>
|
||||||
|
<div class="admin-footer-meta">Fluent UI Blazor 기반 관리자 콘솔</div>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<main class="admin-content">
|
||||||
|
<div class="admin-content-inner">
|
||||||
@Body
|
@Body
|
||||||
</MudContainer>
|
</div>
|
||||||
</MudMainContent>
|
</main>
|
||||||
</MudLayout>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private bool drawerOpen = true;
|
private bool drawerOpen = true;
|
||||||
|
|
||||||
private void ToggleDrawer()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
drawerOpen = !drawerOpen;
|
Navigation.LocationChanged += OnLocationChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (!firstRender)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var viewportWidth = await JS.InvokeAsync<int>("taxbaikAdminSession.getViewportWidth");
|
||||||
|
drawerOpen = viewportWidth >= 960;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string DrawerClass => drawerOpen ? "admin-drawer open" : "admin-drawer";
|
||||||
|
|
||||||
|
private void OnLocationChanged(object? sender, LocationChangedEventArgs args)
|
||||||
|
{
|
||||||
|
_ = InvokeAsync(() => JS.InvokeVoidAsync("taxbaikAdminSession.showLoading"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ToggleDrawer() => drawerOpen = !drawerOpen;
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Navigation.LocationChanged -= OnLocationChanged;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,156 +2,96 @@
|
|||||||
@page "/admin/announcements/{Id:int}/edit"
|
@page "/admin/announcements/{Id:int}/edit"
|
||||||
@attribute [Authorize]
|
@attribute [Authorize]
|
||||||
@using TaxBaik.Application.DTOs
|
@using TaxBaik.Application.DTOs
|
||||||
@using TaxBaik.Application.Services
|
@using TaxBaik.Web.Services
|
||||||
@inject AnnouncementService AnnouncementService
|
@inject IAnnouncementBrowserClient AnnouncementClient
|
||||||
@inject NavigationManager Navigation
|
@inject NavigationManager Navigation
|
||||||
@inject ISnackbar Snackbar
|
@inject IJSRuntime JS
|
||||||
|
|
||||||
<PageTitle>@(Id.HasValue ? "공지 수정" : "공지 등록")</PageTitle>
|
<PageTitle>@(Id.HasValue ? "공지 수정" : "공지 등록")</PageTitle>
|
||||||
|
|
||||||
<section class="admin-page-hero">
|
<section class="admin-page-hero">
|
||||||
<div>
|
<div>
|
||||||
<MudText Typo="Typo.caption" Class="admin-eyebrow">Homepage</MudText>
|
<div class="admin-eyebrow">Homepage</div>
|
||||||
<MudText Typo="Typo.h4" Class="admin-page-title">@(Id.HasValue ? "공지 수정" : "공지 등록")</MudText>
|
<h1 class="admin-page-title">@(Id.HasValue ? "공지 수정" : "공지 등록")</h1>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<MudPaper Class="admin-surface" Elevation="0">
|
<div class="admin-surface" style="max-width:720px;">
|
||||||
<MudForm @ref="form">
|
<form class="admin-dialog-card" @onsubmit="SaveAsync" @onsubmit:preventDefault="true">
|
||||||
<MudGrid>
|
<label>제목 * <input class="admin-input" @bind="model.Title" /></label>
|
||||||
<MudItem xs="12">
|
<label>상세 내용 (선택) <textarea class="admin-input" rows="3" @bind="model.Content"></textarea></label>
|
||||||
<MudTextField @bind-Value="model.Title"
|
<label>유형
|
||||||
Label="제목"
|
<select class="admin-input" @bind="model.DisplayType">
|
||||||
Variant="Variant.Outlined"
|
<option value="info">일반 (파란색)</option>
|
||||||
Required="true"
|
<option value="banner">배너 (주황색)</option>
|
||||||
RequiredError="제목을 입력하세요."
|
<option value="urgent">긴급 (빨간색)</option>
|
||||||
HelperText="홈페이지 상단 공지 바에 표시되는 텍스트입니다." />
|
</select>
|
||||||
</MudItem>
|
</label>
|
||||||
|
<label>노출 순서 <input class="admin-input" type="number" @bind="model.SortOrder" /></label>
|
||||||
<MudItem xs="12">
|
<label>게시 시작일 <input class="admin-input" type="text" placeholder="yyyy-MM-dd" @bind="StartsAtText" /></label>
|
||||||
<MudTextField @bind-Value="model.Content"
|
<label>게시 종료일 <input class="admin-input" type="text" placeholder="yyyy-MM-dd" @bind="EndsAtText" /></label>
|
||||||
Label="상세 내용 (선택)"
|
<label><input type="checkbox" @bind="model.IsActive" /> @(model.IsActive ? "활성화" : "비활성화")</label>
|
||||||
Variant="Variant.Outlined"
|
<div class="admin-dialog-actions">
|
||||||
Lines="3"
|
<button type="submit" class="site-button primary" disabled="@isSaving">저장</button>
|
||||||
HelperText="부가 설명이 있을 경우 입력합니다. 없으면 제목만 표시됩니다." />
|
<button type="button" class="site-button secondary" @onclick='() => Navigation.NavigateTo("/taxbaik/admin/announcements")'>취소</button>
|
||||||
</MudItem>
|
|
||||||
|
|
||||||
<MudItem xs="12" sm="6">
|
|
||||||
<MudSelect @bind-Value="model.DisplayType"
|
|
||||||
Label="유형"
|
|
||||||
Variant="Variant.Outlined">
|
|
||||||
<MudSelectItem Value="@("info")">일반 (파란색)</MudSelectItem>
|
|
||||||
<MudSelectItem Value="@("banner")">배너 (주황색) — 중요 이벤트</MudSelectItem>
|
|
||||||
<MudSelectItem Value="@("urgent")">긴급 (빨간색) — 마감 임박</MudSelectItem>
|
|
||||||
</MudSelect>
|
|
||||||
</MudItem>
|
|
||||||
|
|
||||||
<MudItem xs="12" sm="6">
|
|
||||||
<MudNumericField @bind-Value="model.SortOrder"
|
|
||||||
Label="노출 순서"
|
|
||||||
Variant="Variant.Outlined"
|
|
||||||
HelperText="숫자가 클수록 먼저 표시됩니다." />
|
|
||||||
</MudItem>
|
|
||||||
|
|
||||||
<MudItem xs="12" sm="6">
|
|
||||||
<MudDatePicker @bind-Date="startsAtDate"
|
|
||||||
Label="게시 시작일 (비우면 즉시)"
|
|
||||||
Variant="Variant.Outlined"
|
|
||||||
DateFormat="yyyy-MM-dd"
|
|
||||||
Clearable="true" />
|
|
||||||
</MudItem>
|
|
||||||
|
|
||||||
<MudItem xs="12" sm="6">
|
|
||||||
<MudDatePicker @bind-Date="endsAtDate"
|
|
||||||
Label="게시 종료일 (비우면 무기한)"
|
|
||||||
Variant="Variant.Outlined"
|
|
||||||
DateFormat="yyyy-MM-dd"
|
|
||||||
Clearable="true" />
|
|
||||||
</MudItem>
|
|
||||||
|
|
||||||
<MudItem xs="12">
|
|
||||||
<MudSwitch @bind-Checked="model.IsActive"
|
|
||||||
Label="@(model.IsActive ? "활성화 (홈페이지에 노출)" : "비활성화 (홈페이지 미노출)")"
|
|
||||||
Color="Color.Primary" />
|
|
||||||
</MudItem>
|
|
||||||
</MudGrid>
|
|
||||||
|
|
||||||
<div class="d-flex gap-2 mt-4">
|
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Primary"
|
|
||||||
StartIcon="@Icons.Material.Filled.Save"
|
|
||||||
Disabled="isSaving"
|
|
||||||
@onclick="SaveAsync">
|
|
||||||
@(isSaving ? "저장 중..." : "저장")
|
|
||||||
</MudButton>
|
|
||||||
<MudButton Variant="Variant.Outlined"
|
|
||||||
@onclick="@(() => Navigation.NavigateTo("/taxbaik/admin/announcements"))">
|
|
||||||
취소
|
|
||||||
</MudButton>
|
|
||||||
</div>
|
</div>
|
||||||
</MudForm>
|
</form>
|
||||||
</MudPaper>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
[Parameter] public int? Id { get; set; }
|
[Parameter] public int? Id { get; set; }
|
||||||
|
|
||||||
private MudForm? form;
|
|
||||||
private bool isSaving;
|
private bool isSaving;
|
||||||
private DateTime? startsAtDate;
|
private DateTime? startsAtDate;
|
||||||
private DateTime? endsAtDate;
|
private DateTime? endsAtDate;
|
||||||
|
|
||||||
private AnnouncementDto model = new();
|
private AnnouncementDto model = new();
|
||||||
|
private string StartsAtText { get => startsAtDate?.ToString("yyyy-MM-dd") ?? ""; set => startsAtDate = DateTime.TryParse(value, out var dt) ? dt : null; }
|
||||||
|
private string EndsAtText { get => endsAtDate?.ToString("yyyy-MM-dd") ?? ""; set => endsAtDate = DateTime.TryParse(value, out var dt) ? dt : null; }
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
if (Id.HasValue)
|
if (Id.HasValue)
|
||||||
{
|
{
|
||||||
var entity = await AnnouncementService.GetByIdAsync(Id.Value);
|
try
|
||||||
if (entity is null)
|
{
|
||||||
|
var entity = await AnnouncementClient.GetByIdAsync(Id.Value);
|
||||||
|
if (entity is null)
|
||||||
|
{
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/announcements");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
model = new AnnouncementDto
|
||||||
|
{
|
||||||
|
Id = entity.Id,
|
||||||
|
Title = entity.Title,
|
||||||
|
Content = entity.Content,
|
||||||
|
DisplayType = entity.DisplayType,
|
||||||
|
IsActive = entity.IsActive,
|
||||||
|
SortOrder = entity.SortOrder
|
||||||
|
};
|
||||||
|
startsAtDate = entity.StartsAt?.ToLocalTime();
|
||||||
|
endsAtDate = entity.EndsAt?.ToLocalTime();
|
||||||
|
}
|
||||||
|
catch
|
||||||
{
|
{
|
||||||
Navigation.NavigateTo("/taxbaik/admin/announcements");
|
Navigation.NavigateTo("/taxbaik/admin/announcements");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
model = new AnnouncementDto
|
|
||||||
{
|
|
||||||
Id = entity.Id,
|
|
||||||
Title = entity.Title,
|
|
||||||
Content = entity.Content,
|
|
||||||
DisplayType = entity.DisplayType,
|
|
||||||
IsActive = entity.IsActive,
|
|
||||||
SortOrder = entity.SortOrder
|
|
||||||
};
|
|
||||||
startsAtDate = entity.StartsAt?.ToLocalTime();
|
|
||||||
endsAtDate = entity.EndsAt?.ToLocalTime();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SaveAsync()
|
private async Task SaveAsync()
|
||||||
{
|
{
|
||||||
if (form is null) return;
|
|
||||||
await form.Validate();
|
|
||||||
if (!form.IsValid) return;
|
|
||||||
|
|
||||||
isSaving = true;
|
isSaving = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
model.StartsAt = startsAtDate.HasValue
|
model.StartsAt = startsAtDate.HasValue ? DateTime.SpecifyKind(startsAtDate.Value.Date, DateTimeKind.Local).ToUniversalTime() : null;
|
||||||
? DateTime.SpecifyKind(startsAtDate.Value.Date, DateTimeKind.Local).ToUniversalTime()
|
model.EndsAt = endsAtDate.HasValue ? DateTime.SpecifyKind(endsAtDate.Value.Date.AddDays(1).AddSeconds(-1), DateTimeKind.Local).ToUniversalTime() : null;
|
||||||
: null;
|
var result = Id.HasValue ? await AnnouncementClient.UpdateAsync(Id.Value, model) : await AnnouncementClient.CreateAsync(model);
|
||||||
model.EndsAt = endsAtDate.HasValue
|
await JS.InvokeVoidAsync("alert", result != null ? "공지사항이 저장되었습니다." : "저장 실패");
|
||||||
? DateTime.SpecifyKind(endsAtDate.Value.Date.AddDays(1).AddSeconds(-1), DateTimeKind.Local).ToUniversalTime()
|
|
||||||
: null;
|
|
||||||
|
|
||||||
if (Id.HasValue)
|
|
||||||
await AnnouncementService.UpdateAsync(model);
|
|
||||||
else
|
|
||||||
await AnnouncementService.CreateAsync(model);
|
|
||||||
|
|
||||||
Snackbar.Add("공지사항이 저장되었습니다.", Severity.Success);
|
|
||||||
Navigation.NavigateTo("/taxbaik/admin/announcements");
|
Navigation.NavigateTo("/taxbaik/admin/announcements");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Snackbar.Add($"저장 실패: {ex.Message}", Severity.Error);
|
await JS.InvokeVoidAsync("alert", $"저장 실패: {ex.Message}");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,119 +1,135 @@
|
|||||||
@page "/admin/announcements"
|
@page "/admin/announcements"
|
||||||
@attribute [Authorize]
|
@attribute [Authorize]
|
||||||
@using TaxBaik.Application.Services
|
@using TaxBaik.Web.Services
|
||||||
@using TaxBaik.Domain.Entities
|
@using TaxBaik.Domain.Entities
|
||||||
@inject AnnouncementService AnnouncementService
|
@inject IAnnouncementBrowserClient AnnouncementClient
|
||||||
@inject NavigationManager Navigation
|
@inject NavigationManager Navigation
|
||||||
@inject IDialogService DialogService
|
@inject IJSRuntime JS
|
||||||
@inject ISnackbar Snackbar
|
|
||||||
|
|
||||||
<PageTitle>공지사항 관리</PageTitle>
|
<PageTitle>공지사항 관리</PageTitle>
|
||||||
|
|
||||||
<section class="admin-page-hero">
|
<section class="admin-page-hero">
|
||||||
<div>
|
<div>
|
||||||
<MudText Typo="Typo.caption" Class="admin-eyebrow">Homepage</MudText>
|
<div class="admin-eyebrow">Homepage</div>
|
||||||
<MudText Typo="Typo.h4" Class="admin-page-title">공지사항 관리</MudText>
|
<h1 class="admin-page-title">공지사항 관리</h1>
|
||||||
<MudText Typo="Typo.body2" Class="admin-page-subtitle">홈페이지 상단에 노출되는 공지사항을 등록하고 관리합니다.</MudText>
|
<p class="admin-page-subtitle">홈페이지 상단에 노출되는 공지사항을 등록하고 관리합니다.</p>
|
||||||
</div>
|
</div>
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Primary"
|
<a class="site-button primary" href="/taxbaik/admin/announcements/create">공지 등록</a>
|
||||||
StartIcon="@Icons.Material.Filled.Add"
|
|
||||||
Href="/taxbaik/admin/announcements/create">
|
|
||||||
공지 등록
|
|
||||||
</MudButton>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<MudPaper Class="admin-surface" Elevation="0">
|
<div class="admin-surface">
|
||||||
@if (announcements is null)
|
@if (announcements is null)
|
||||||
{
|
{
|
||||||
<MudProgressLinear Indeterminate="true" />
|
<Skeleton Count="5" CssClass="taxbaik-skeleton-grid" />
|
||||||
}
|
}
|
||||||
else if (!announcements.Any())
|
else if (!announcements.Any())
|
||||||
{
|
{
|
||||||
<MudText Class="pa-4 text-muted">등록된 공지사항이 없습니다.</MudText>
|
<div class="muted">등록된 공지사항이 없습니다.</div>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<MudSimpleTable Striped="true" Dense="true" Class="admin-table">
|
<div class="admin-table-wrap">
|
||||||
<thead>
|
<table class="admin-table">
|
||||||
<tr>
|
<thead>
|
||||||
<th>제목</th>
|
|
||||||
<th>유형</th>
|
|
||||||
<th>상태</th>
|
|
||||||
<th>게시 기간</th>
|
|
||||||
<th>순서</th>
|
|
||||||
<th></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach (var item in announcements)
|
|
||||||
{
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>@item.Title</td>
|
<th>제목</th>
|
||||||
<td>
|
<th>유형</th>
|
||||||
<MudChip Size="Size.Small" Color="@GetTypeColor(item.DisplayType)">
|
<th>상태</th>
|
||||||
@GetTypeLabel(item.DisplayType)
|
<th>게시 기간</th>
|
||||||
</MudChip>
|
<th>순서</th>
|
||||||
</td>
|
<th></th>
|
||||||
<td>
|
|
||||||
@if (IsCurrentlyActive(item))
|
|
||||||
{
|
|
||||||
<MudChip Size="Size.Small" Color="Color.Success">노출 중</MudChip>
|
|
||||||
}
|
|
||||||
else if (!item.IsActive)
|
|
||||||
{
|
|
||||||
<MudChip Size="Size.Small" Color="Color.Default">비활성</MudChip>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<MudChip Size="Size.Small" Color="Color.Warning">기간 외</MudChip>
|
|
||||||
}
|
|
||||||
</td>
|
|
||||||
<td class="small">
|
|
||||||
@FormatPeriod(item)
|
|
||||||
</td>
|
|
||||||
<td>@item.SortOrder</td>
|
|
||||||
<td>
|
|
||||||
<MudButtonGroup Size="Size.Small" Variant="Variant.Outlined">
|
|
||||||
<MudButton @onclick="@(() => Navigation.NavigateTo($"/taxbaik/admin/announcements/{item.Id}/edit"))">
|
|
||||||
수정
|
|
||||||
</MudButton>
|
|
||||||
<MudButton Color="Color.Error" @onclick="@(() => DeleteAsync(item))">
|
|
||||||
삭제
|
|
||||||
</MudButton>
|
|
||||||
</MudButtonGroup>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
}
|
</thead>
|
||||||
</tbody>
|
<tbody>
|
||||||
</MudSimpleTable>
|
@foreach (var item in announcements)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@item.Title</td>
|
||||||
|
<td><span class="status-pill info">@GetTypeLabel(item.DisplayType)</span></td>
|
||||||
|
<td>
|
||||||
|
@if (IsCurrentlyActive(item))
|
||||||
|
{
|
||||||
|
<span class="status-pill success">노출 중</span>
|
||||||
|
}
|
||||||
|
else if (!item.IsActive)
|
||||||
|
{
|
||||||
|
<span class="status-pill default">비활성</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<span class="status-pill warning">기간 외</span>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
<td class="small">@FormatPeriod(item)</td>
|
||||||
|
<td>@item.SortOrder</td>
|
||||||
|
<td>
|
||||||
|
<div class="admin-actions">
|
||||||
|
<button type="button" class="admin-icon-button" @onclick="@(() => Navigation.NavigateTo($"/taxbaik/admin/announcements/{item.Id}/edit"))">✎</button>
|
||||||
|
<button type="button" class="admin-icon-button danger" @onclick="@(() => DeleteAsync(item))">✕</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
</MudPaper>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
private Task<AuthenticationState>? AuthStateTask { get; set; }
|
||||||
|
|
||||||
private List<Announcement>? announcements;
|
private List<Announcement>? announcements;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
await LoadAsync();
|
if (firstRender && AuthStateTask != null)
|
||||||
|
{
|
||||||
|
var authState = await AuthStateTask;
|
||||||
|
if (authState.User.Identity?.IsAuthenticated == true)
|
||||||
|
{
|
||||||
|
await LoadAsync();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task LoadAsync()
|
private async Task LoadAsync()
|
||||||
{
|
{
|
||||||
announcements = (await AnnouncementService.GetAllAsync()).ToList();
|
try
|
||||||
|
{
|
||||||
|
announcements = (await AnnouncementClient.GetAllAsync()).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"오류: {ex.Message}");
|
||||||
|
announcements = [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DeleteAsync(Announcement item)
|
private async Task DeleteAsync(Announcement item)
|
||||||
{
|
{
|
||||||
var confirmed = await DialogService.ShowMessageBox(
|
var confirmed = await JS.InvokeAsync<bool>("confirm", $"'{item.Title}' 공지를 삭제하시겠습니까?");
|
||||||
"공지 삭제",
|
if (!confirmed) return;
|
||||||
$"'{item.Title}' 공지를 삭제하시겠습니까?",
|
|
||||||
yesText: "삭제", cancelText: "취소");
|
|
||||||
|
|
||||||
if (confirmed != true) return;
|
try
|
||||||
|
{
|
||||||
await AnnouncementService.DeleteAsync(item.Id);
|
var success = await AnnouncementClient.DeleteAsync(item.Id);
|
||||||
Snackbar.Add("공지사항이 삭제되었습니다.", Severity.Success);
|
if (success)
|
||||||
await LoadAsync();
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "공지사항이 삭제되었습니다.");
|
||||||
|
await LoadAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "삭제 실패");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"오류: {ex.Message}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsCurrentlyActive(Announcement a)
|
private static bool IsCurrentlyActive(Announcement a)
|
||||||
@@ -121,28 +137,21 @@
|
|||||||
if (!a.IsActive) return false;
|
if (!a.IsActive) return false;
|
||||||
var now = DateTime.UtcNow;
|
var now = DateTime.UtcNow;
|
||||||
if (a.StartsAt.HasValue && a.StartsAt > now) return false;
|
if (a.StartsAt.HasValue && a.StartsAt > now) return false;
|
||||||
if (a.EndsAt.HasValue && a.EndsAt < now) return false;
|
if (a.EndsAt.HasValue && a.EndsAt < now) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string FormatPeriod(Announcement a)
|
private static string FormatPeriod(Announcement a)
|
||||||
{
|
{
|
||||||
var start = a.StartsAt?.ToLocalTime().ToString("MM/dd") ?? "즉시";
|
var start = a.StartsAt?.ToLocalTime().ToString("MM/dd") ?? "즉시";
|
||||||
var end = a.EndsAt?.ToLocalTime().ToString("MM/dd") ?? "무기한";
|
var end = a.EndsAt?.ToLocalTime().ToString("MM/dd") ?? "무기한";
|
||||||
return $"{start} ~ {end}";
|
return $"{start} ~ {end}";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Color GetTypeColor(string type) => type switch
|
|
||||||
{
|
|
||||||
"urgent" => Color.Error,
|
|
||||||
"banner" => Color.Warning,
|
|
||||||
_ => Color.Info
|
|
||||||
};
|
|
||||||
|
|
||||||
private static string GetTypeLabel(string type) => type switch
|
private static string GetTypeLabel(string type) => type switch
|
||||||
{
|
{
|
||||||
"urgent" => "긴급",
|
"urgent" => "긴급",
|
||||||
"banner" => "배너",
|
"banner" => "배너",
|
||||||
_ => "일반"
|
_ => "일반"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,53 +6,45 @@
|
|||||||
@inject BlogService BlogService
|
@inject BlogService BlogService
|
||||||
@inject ICategoryRepository CategoryRepository
|
@inject ICategoryRepository CategoryRepository
|
||||||
@inject NavigationManager Navigation
|
@inject NavigationManager Navigation
|
||||||
@inject ISnackbar Snackbar
|
@inject IJSRuntime JS
|
||||||
|
|
||||||
<PageTitle>새 포스트 작성</PageTitle>
|
<PageTitle>새 포스트 작성</PageTitle>
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">Content</div>
|
||||||
|
<h1 class="admin-page-title">새 포스트 작성</h1>
|
||||||
|
<p class="admin-page-subtitle">새로운 블로그 포스트를 작성합니다.</p>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="site-button secondary" @onclick='() => Navigation.NavigateTo("/taxbaik/admin/blog")'>취소</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
<MudText Typo="Typo.h5" Class="mb-4">📝 새 포스트</MudText>
|
<div class="admin-surface mt-4">
|
||||||
|
<form class="admin-dialog-card" @onsubmit="SavePost" @onsubmit:preventDefault="true">
|
||||||
<MudPaper Class="pa-4" Elevation="1">
|
<label>제목 * <input class="admin-input" @bind="model.Title" /></label>
|
||||||
<MudForm @ref="form">
|
<label>카테고리
|
||||||
<MudTextField @bind-Value="model.Title" Label="제목"
|
<select class="admin-input" @bind="CategoryIdText">
|
||||||
Variant="Variant.Outlined" Class="mb-4" Required="true" />
|
<option value="">선택하세요</option>
|
||||||
|
@foreach (var category in categories)
|
||||||
<MudSelect @bind-Value="model.CategoryId" Label="카테고리"
|
{
|
||||||
Variant="Variant.Outlined" Class="mb-4">
|
<option value="@category.Id.ToString()">@category.Name</option>
|
||||||
@foreach (var category in categories)
|
}
|
||||||
{
|
</select>
|
||||||
<MudSelectItem Value="@category.Id">@category.Name</MudSelectItem>
|
</label>
|
||||||
}
|
<label>본문 * <textarea class="admin-input" rows="10" @bind="model.Content"></textarea></label>
|
||||||
</MudSelect>
|
<label>태그 (쉼표로 구분) <input class="admin-input" @bind="model.Tags" /></label>
|
||||||
|
<label>SEO 제목 <input class="admin-input" @bind="model.SeoTitle" /></label>
|
||||||
<MudTextField @bind-Value="model.Content" Label="본문"
|
<label>SEO 설명 <textarea class="admin-input" rows="3" @bind="model.SeoDescription"></textarea></label>
|
||||||
Variant="Variant.Outlined" Lines="10" Class="mb-4" Required="true" />
|
<label><input type="checkbox" @bind="model.IsPublished" /> 즉시 발행</label>
|
||||||
|
<div class="admin-dialog-actions">
|
||||||
<MudTextField @bind-Value="model.Tags" Label="태그 (쉼표로 구분)"
|
<button type="submit" class="site-button primary">저장</button>
|
||||||
Variant="Variant.Outlined" Class="mb-4" />
|
|
||||||
|
|
||||||
<MudTextField @bind-Value="model.SeoTitle" Label="SEO 제목"
|
|
||||||
Variant="Variant.Outlined" Class="mb-4" />
|
|
||||||
|
|
||||||
<MudTextField @bind-Value="model.SeoDescription" Label="SEO 설명"
|
|
||||||
Variant="Variant.Outlined" Lines="3" Class="mb-4" />
|
|
||||||
|
|
||||||
<MudCheckBox @bind-Checked="model.IsPublished" Label="즉시 발행" Class="mb-4" />
|
|
||||||
|
|
||||||
<div class="d-flex gap-2">
|
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Primary"
|
|
||||||
@onclick="SavePost">저장</MudButton>
|
|
||||||
<MudButton Variant="Variant.Outlined" @onclick="@(() => Navigation.NavigateTo("/taxbaik/admin/blog"))">
|
|
||||||
취소
|
|
||||||
</MudButton>
|
|
||||||
</div>
|
</div>
|
||||||
</MudForm>
|
</form>
|
||||||
</MudPaper>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private MudForm? form;
|
|
||||||
private List<Domain.Entities.Category> categories = [];
|
private List<Domain.Entities.Category> categories = [];
|
||||||
private CreatePostModel model = new();
|
private CreatePostModel model = new();
|
||||||
|
private string CategoryIdText { get => model.CategoryId?.ToString() ?? ""; set => model.CategoryId = int.TryParse(value, out var id) ? id : null; }
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
@@ -61,13 +53,6 @@
|
|||||||
|
|
||||||
private async Task SavePost()
|
private async Task SavePost()
|
||||||
{
|
{
|
||||||
if (form == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
await form.Validate();
|
|
||||||
if (!form.IsValid)
|
|
||||||
return;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await BlogService.CreateAsync(new CreateBlogPostDto
|
await BlogService.CreateAsync(new CreateBlogPostDto
|
||||||
@@ -81,12 +66,12 @@
|
|||||||
IsPublished = model.IsPublished
|
IsPublished = model.IsPublished
|
||||||
});
|
});
|
||||||
|
|
||||||
Snackbar.Add("포스트가 저장되었습니다.", Severity.Success);
|
await JS.InvokeVoidAsync("alert", "포스트가 저장되었습니다.");
|
||||||
Navigation.NavigateTo("/taxbaik/admin/blog");
|
Navigation.NavigateTo("/taxbaik/admin/blog");
|
||||||
}
|
}
|
||||||
catch (ValidationException ex)
|
catch (ValidationException ex)
|
||||||
{
|
{
|
||||||
Snackbar.Add(ex.Message, Severity.Error);
|
await JS.InvokeVoidAsync("alert", ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,139 @@
|
|||||||
|
@page "/admin/blog/{id:int}/edit"
|
||||||
|
@attribute [Authorize]
|
||||||
|
@using TaxBaik.Application.DTOs
|
||||||
|
@using TaxBaik.Application.Services
|
||||||
|
@using TaxBaik.Domain.Interfaces
|
||||||
|
@inject BlogService BlogService
|
||||||
|
@inject ICategoryRepository CategoryRepository
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
|
||||||
|
<PageTitle>포스트 수정</PageTitle>
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">Content</div>
|
||||||
|
<h1 class="admin-page-title">포스트 수정</h1>
|
||||||
|
<p class="admin-page-subtitle">블로그 포스트를 수정합니다.</p>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="site-button secondary" @onclick='() => Navigation.NavigateTo("/taxbaik/admin/blog")'>취소</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
@if (isLoading)
|
||||||
|
{
|
||||||
|
<div class="admin-surface mt-4"><Skeleton Count="4" CssClass="taxbaik-skeleton-grid" /></div>
|
||||||
|
}
|
||||||
|
else if (post == null)
|
||||||
|
{
|
||||||
|
<div class="admin-surface mt-4">포스트를 찾을 수 없습니다.</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="admin-surface mt-4">
|
||||||
|
<form class="admin-dialog-card" @onsubmit="SavePost" @onsubmit:preventDefault="true">
|
||||||
|
<label>제목 * <input class="admin-input" @bind="model.Title" /></label>
|
||||||
|
<label>카테고리
|
||||||
|
<select class="admin-input" @bind="CategoryIdText">
|
||||||
|
<option value="">선택하세요</option>
|
||||||
|
@foreach (var category in categories)
|
||||||
|
{
|
||||||
|
<option value="@category.Id.ToString()">@category.Name</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>본문 * <textarea class="admin-input" rows="10" @bind="model.Content"></textarea></label>
|
||||||
|
<label>태그 (쉼표로 구분) <input class="admin-input" @bind="model.Tags" /></label>
|
||||||
|
<label>SEO 제목 <input class="admin-input" @bind="model.SeoTitle" /></label>
|
||||||
|
<label>SEO 설명 <textarea class="admin-input" rows="3" @bind="model.SeoDescription"></textarea></label>
|
||||||
|
<label><input type="checkbox" @bind="model.IsPublished" /> 발행</label>
|
||||||
|
<div class="admin-dialog-actions">
|
||||||
|
<button type="submit" class="site-button primary">저장</button>
|
||||||
|
<button type="button" class="site-button secondary" @onclick="DeletePost">삭제</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter] public int Id { get; set; }
|
||||||
|
private Domain.Entities.BlogPost? post;
|
||||||
|
private List<Domain.Entities.Category> categories = [];
|
||||||
|
private EditPostModel model = new();
|
||||||
|
private bool isLoading = true;
|
||||||
|
private string CategoryIdText { get => model.CategoryId?.ToString() ?? ""; set => model.CategoryId = int.TryParse(value, out var id) ? id : null; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
post = await BlogService.GetByIdAsync(Id);
|
||||||
|
if (post != null)
|
||||||
|
{
|
||||||
|
categories = (await CategoryRepository.GetAllAsync()).ToList();
|
||||||
|
MapPostToModel(post);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"포스트 로드 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MapPostToModel(Domain.Entities.BlogPost post)
|
||||||
|
{
|
||||||
|
model.Title = post.Title;
|
||||||
|
model.Content = post.Content;
|
||||||
|
model.CategoryId = post.CategoryId;
|
||||||
|
model.Tags = post.Tags;
|
||||||
|
model.SeoTitle = post.SeoTitle;
|
||||||
|
model.SeoDescription = post.SeoDescription;
|
||||||
|
model.IsPublished = post.IsPublished;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SavePost()
|
||||||
|
{
|
||||||
|
if (post == null) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await BlogService.UpdateAsync(post.Id, new CreateBlogPostDto
|
||||||
|
{
|
||||||
|
Title = model.Title,
|
||||||
|
Content = model.Content,
|
||||||
|
CategoryId = model.CategoryId,
|
||||||
|
Tags = model.Tags,
|
||||||
|
SeoTitle = model.SeoTitle,
|
||||||
|
SeoDescription = model.SeoDescription,
|
||||||
|
IsPublished = model.IsPublished
|
||||||
|
});
|
||||||
|
await JS.InvokeVoidAsync("alert", "포스트가 저장되었습니다.");
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/blog");
|
||||||
|
}
|
||||||
|
catch (ValidationException ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeletePost()
|
||||||
|
{
|
||||||
|
if (post == null) return;
|
||||||
|
if (!await JS.InvokeAsync<bool>("confirm", "정말 삭제하시겠습니까? 이 작업은 취소할 수 없습니다.")) return;
|
||||||
|
await BlogService.DeleteAsync(post.Id);
|
||||||
|
await JS.InvokeVoidAsync("alert", "포스트가 삭제되었습니다.");
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/blog");
|
||||||
|
}
|
||||||
|
|
||||||
|
private class EditPostModel
|
||||||
|
{
|
||||||
|
public string Title { get; set; } = "";
|
||||||
|
public string Content { get; set; } = "";
|
||||||
|
public int? CategoryId { get; set; }
|
||||||
|
public string? Tags { get; set; }
|
||||||
|
public string? SeoTitle { get; set; }
|
||||||
|
public string? SeoDescription { get; set; }
|
||||||
|
public bool IsPublished { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,55 +1,72 @@
|
|||||||
@page "/admin/blog"
|
@page "/admin/blog"
|
||||||
@attribute [Authorize]
|
@attribute [Authorize]
|
||||||
@inject IApiClient ApiClient
|
@inject IApiClient ApiClient
|
||||||
@inject ISnackbar Snackbar
|
@inject IJSRuntime JS
|
||||||
|
|
||||||
<PageTitle>블로그 관리</PageTitle>
|
<PageTitle>블로그 관리</PageTitle>
|
||||||
|
|
||||||
<section class="admin-page-hero">
|
<section class="admin-page-hero">
|
||||||
<div>
|
<div>
|
||||||
<MudText Typo="Typo.caption" Class="admin-eyebrow">Content</MudText>
|
<div class="admin-eyebrow">Content</div>
|
||||||
<MudText Typo="Typo.h4" Class="admin-page-title">블로그 관리</MudText>
|
<h1 class="admin-page-title">블로그 관리</h1>
|
||||||
<MudText Typo="Typo.body2" Class="admin-page-subtitle">검색 유입 콘텐츠의 발행 상태와 성과를 관리합니다.</MudText>
|
<p class="admin-page-subtitle">검색 유입 콘텐츠의 발행 상태와 성과를 관리합니다.</p>
|
||||||
</div>
|
</div>
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" StartIcon="@Icons.Material.Filled.EditNote"
|
<button type="button" class="site-button primary" @onclick='() => NavTo("/taxbaik/admin/blog/create")'>새 포스트 작성</button>
|
||||||
Href="/taxbaik/admin/blog/create">새 포스트 작성</MudButton>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<MudPaper Class="admin-surface mb-4" Elevation="0">
|
<div class="admin-surface mb-4">
|
||||||
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween">
|
<div class="admin-summary-bar">
|
||||||
<MudText Typo="Typo.subtitle1">@($"전체 포스트 {totalPosts}개")</MudText>
|
<span>전체 포스트: @($"{totalPosts}개")</span>
|
||||||
<MudText Typo="Typo.body2">페이지 @currentPage / @totalPages</MudText>
|
<span>페이지 @currentPage / @totalPages</span>
|
||||||
</MudStack>
|
</div>
|
||||||
</MudPaper>
|
</div>
|
||||||
|
|
||||||
<MudDataGrid Items="@posts" Striped="true" Hoverable="true" Loading="@isLoading" Class="admin-grid">
|
<div class="admin-surface">
|
||||||
<Columns>
|
@if (isLoading)
|
||||||
<PropertyColumn Property="x => x.Title" Title="제목" />
|
{
|
||||||
<PropertyColumn Property="x => x.IsPublished" Title="발행">
|
<Skeleton Count="6" CssClass="taxbaik-skeleton-grid" />
|
||||||
<CellTemplate Context="cell">
|
}
|
||||||
<MudCheckBox T="bool" Value="@cell.Item.IsPublished"
|
else
|
||||||
ValueChanged="@(async (bool value) => await TogglePublish(cell.Item, value))" />
|
{
|
||||||
</CellTemplate>
|
<div class="admin-table-wrap">
|
||||||
</PropertyColumn>
|
<table class="admin-table">
|
||||||
<PropertyColumn Property="x => x.ViewCount" Title="조회수" />
|
<thead>
|
||||||
<PropertyColumn Property="x => x.CreatedAt" Title="작성일" Format="yyyy-MM-dd" />
|
<tr>
|
||||||
<TemplateColumn>
|
<th>제목</th>
|
||||||
<CellTemplate Context="cell">
|
<th>발행</th>
|
||||||
<MudButton Variant="Variant.Outlined" Size="Size.Small" Color="Color.Primary"
|
<th>조회수</th>
|
||||||
Href="@($"/taxbaik/admin/blog/{cell.Item.Id}/edit")">수정하기</MudButton>
|
<th>작성일</th>
|
||||||
<MudButton Variant="Variant.Text" Size="Size.Small" Color="Color.Error"
|
<th></th>
|
||||||
@onclick="@(async () => await DeletePost(cell.Item.Id))">삭제</MudButton>
|
</tr>
|
||||||
</CellTemplate>
|
</thead>
|
||||||
</TemplateColumn>
|
<tbody>
|
||||||
</Columns>
|
@foreach (var post in posts)
|
||||||
</MudDataGrid>
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@post.Title</td>
|
||||||
|
<td><label><input type="checkbox" checked="@post.IsPublished" @onchange="@(async e => await TogglePublish(post, (bool)e.Value!))" /> 발행</label></td>
|
||||||
|
<td>@post.ViewCount</td>
|
||||||
|
<td>@post.CreatedAt.ToString("yyyy-MM-dd")</td>
|
||||||
|
<td>
|
||||||
|
<div class="admin-row-actions">
|
||||||
|
<a class="site-button secondary" href="@($"/taxbaik/admin/blog/{post.Id}/edit")">수정</a>
|
||||||
|
<button type="button" class="admin-icon-button danger" @onclick="@(async () => await DeletePost(post.Id))">✕</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
<MudStack Row="true" Justify="Justify.Center" Class="mt-4" Spacing="2">
|
<div class="admin-pagination">
|
||||||
<MudButton Variant="Variant.Outlined" Disabled="@(currentPage <= 1 || isLoading)" @onclick="PreviousPage">이전</MudButton>
|
<button type="button" class="site-button secondary" disabled="@(currentPage <= 1 || isLoading)" @onclick="PreviousPage">이전</button>
|
||||||
<MudButton Variant="Variant.Outlined" Disabled="@(currentPage >= totalPages || isLoading)" @onclick="NextPage">다음</MudButton>
|
<button type="button" class="site-button secondary" disabled="@(currentPage >= totalPages || isLoading)" @onclick="NextPage">다음</button>
|
||||||
</MudStack>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
[CascadingParameter] private Task<AuthenticationState>? AuthStateTask { get; set; }
|
||||||
private List<TaxBaik.Domain.Entities.BlogPost> posts = [];
|
private List<TaxBaik.Domain.Entities.BlogPost> posts = [];
|
||||||
private bool isLoading = true;
|
private bool isLoading = true;
|
||||||
private int currentPage = 1;
|
private int currentPage = 1;
|
||||||
@@ -57,11 +74,21 @@
|
|||||||
private int totalPosts = 0;
|
private int totalPosts = 0;
|
||||||
private const int PageSize = 20;
|
private const int PageSize = 20;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
await LoadPosts();
|
if (firstRender && AuthStateTask != null)
|
||||||
|
{
|
||||||
|
var authState = await AuthStateTask;
|
||||||
|
if (authState.User.Identity?.IsAuthenticated == true)
|
||||||
|
{
|
||||||
|
await LoadPosts();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string NavTo(string url) => url;
|
||||||
|
|
||||||
private async Task LoadPosts()
|
private async Task LoadPosts()
|
||||||
{
|
{
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
@@ -78,58 +105,33 @@
|
|||||||
totalPosts = 0;
|
totalPosts = 0;
|
||||||
totalPages = 1;
|
totalPages = 1;
|
||||||
}
|
}
|
||||||
isLoading = false;
|
finally
|
||||||
|
{
|
||||||
|
isLoading = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task PreviousPage()
|
private async Task PreviousPage() { if (currentPage > 1) { currentPage--; await LoadPosts(); } }
|
||||||
{
|
private async Task NextPage() { if (currentPage < totalPages) { currentPage++; await LoadPosts(); } }
|
||||||
if (currentPage <= 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
currentPage--;
|
|
||||||
await LoadPosts();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task NextPage()
|
|
||||||
{
|
|
||||||
if (currentPage >= totalPages)
|
|
||||||
return;
|
|
||||||
|
|
||||||
currentPage++;
|
|
||||||
await LoadPosts();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task TogglePublish(TaxBaik.Domain.Entities.BlogPost post, bool isPublished)
|
private async Task TogglePublish(TaxBaik.Domain.Entities.BlogPost post, bool isPublished)
|
||||||
{
|
{
|
||||||
var previous = post.IsPublished;
|
var previous = post.IsPublished;
|
||||||
post.IsPublished = isPublished;
|
post.IsPublished = isPublished;
|
||||||
var result = await ApiClient.PutAsync<TaxBaik.Domain.Entities.BlogPost>($"blog/{post.Id}", new
|
var result = await ApiClient.PutAsync<TaxBaik.Domain.Entities.BlogPost>($"blog/{post.Id}", new { post.Title, post.Content, post.CategoryId, post.Tags, post.SeoTitle, post.SeoDescription, post.ThumbnailUrl, IsPublished = isPublished, post.AuthorId });
|
||||||
{
|
|
||||||
post.Title,
|
|
||||||
post.Content,
|
|
||||||
post.CategoryId,
|
|
||||||
post.Tags,
|
|
||||||
post.SeoTitle,
|
|
||||||
post.SeoDescription,
|
|
||||||
post.ThumbnailUrl,
|
|
||||||
IsPublished = isPublished,
|
|
||||||
post.AuthorId
|
|
||||||
});
|
|
||||||
|
|
||||||
if (result == null)
|
if (result == null)
|
||||||
{
|
{
|
||||||
post.IsPublished = previous;
|
post.IsPublished = previous;
|
||||||
Snackbar.Add("발행 상태 변경에 실패했습니다.", Severity.Error);
|
await JS.InvokeVoidAsync("alert", "발행 상태 변경에 실패했습니다.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
await JS.InvokeVoidAsync("alert", "발행 상태가 변경되었습니다.");
|
||||||
Snackbar.Add("발행 상태가 변경되었습니다.", Severity.Success);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DeletePost(int postId)
|
private async Task DeletePost(int postId)
|
||||||
{
|
{
|
||||||
await ApiClient.DeleteAsync($"blog/{postId}");
|
await ApiClient.DeleteAsync($"blog/{postId}");
|
||||||
Snackbar.Add("포스트가 삭제되었습니다.", Severity.Success);
|
await JS.InvokeVoidAsync("alert", "포스트가 삭제되었습니다.");
|
||||||
await LoadPosts();
|
await LoadPosts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,190 @@
|
|||||||
|
@page "/admin/clients/{ClientId:int}"
|
||||||
|
@attribute [Authorize]
|
||||||
|
@using TaxBaik.Application.Services
|
||||||
|
@inject ClientService ClientService
|
||||||
|
@inject ConsultationService ConsultationService
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
|
||||||
|
<PageTitle>고객 상세</PageTitle>
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">Client Details</div>
|
||||||
|
<h1 class="admin-page-title">고객 상세</h1>
|
||||||
|
<p class="admin-page-subtitle">고객 정보와 상담 이력을 관리합니다.</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
@if (client == null)
|
||||||
|
{
|
||||||
|
<div class="admin-surface mt-4">고객을 찾을 수 없습니다.</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="admin-page-actions">
|
||||||
|
<button type="button" class="site-button secondary" @onclick='() => Navigation.NavigateTo("/taxbaik/admin/clients")'>목록으로</button>
|
||||||
|
<a class="site-button secondary" href="@($"/taxbaik/admin/clients/{ClientId}/edit")">수정</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="admin-detail-grid">
|
||||||
|
<section class="admin-surface">
|
||||||
|
<h3 class="admin-section-title">고객 정보</h3>
|
||||||
|
<div class="admin-kv-grid">
|
||||||
|
<div><span>이름</span><strong>@client.Name</strong></div>
|
||||||
|
<div><span>상호</span><strong>@(client.CompanyName ?? "-")</strong></div>
|
||||||
|
<div><span>연락처</span><strong>@(client.Phone ?? "-")</strong></div>
|
||||||
|
<div><span>이메일</span><strong>@(client.Email ?? "-")</strong></div>
|
||||||
|
<div><span>서비스</span><strong>@(client.ServiceType ?? "-")</strong></div>
|
||||||
|
<div><span>사업자 유형</span><strong>@(client.TaxType ?? "-")</strong></div>
|
||||||
|
<div><span>유입 경로</span><strong>@(client.Source ?? "-")</strong></div>
|
||||||
|
<div><span>등록일</span><strong>@client.CreatedAt.ToLocalTime().ToString("yyyy-MM-dd")</strong></div>
|
||||||
|
@if (!string.IsNullOrWhiteSpace(client.Memo))
|
||||||
|
{
|
||||||
|
<div class="span-2"><span>메모</span><strong style="white-space: pre-wrap;">@client.Memo</strong></div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="admin-surface">
|
||||||
|
<div class="admin-section-header compact">
|
||||||
|
<div>
|
||||||
|
<h3 class="admin-section-title">상담 이력</h3>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="site-button primary" @onclick="OpenAddConsultation">+ 상담 추가</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (showAddForm)
|
||||||
|
{
|
||||||
|
<form class="admin-dialog-card mb-4" @onsubmit="AddConsultation" @onsubmit:preventDefault="true">
|
||||||
|
<label>상담일 <input class="admin-input" type="text" placeholder="2026-06-29" @bind="ConsultationDateText" /></label>
|
||||||
|
<label>서비스 분야
|
||||||
|
<select class="admin-input" @bind="newServiceType">
|
||||||
|
<option value="">선택하세요</option>
|
||||||
|
@foreach (var t in ClientService.ServiceTypes)
|
||||||
|
{
|
||||||
|
<option value="@t">@t</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>상담 내용 * <textarea class="admin-input" rows="3" @bind="newSummary"></textarea></label>
|
||||||
|
<label>결과
|
||||||
|
<select class="admin-input" @bind="newResult">
|
||||||
|
<option value="">-</option>
|
||||||
|
@foreach (var r in ConsultationService.Results)
|
||||||
|
{
|
||||||
|
<option value="@r">@r</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>수임료 (원) <input class="admin-input" type="text" placeholder="100000" @bind="FeeText" /></label>
|
||||||
|
<div class="admin-dialog-actions">
|
||||||
|
<button type="submit" class="site-button primary">저장</button>
|
||||||
|
<button type="button" class="site-button secondary" @onclick='() => showAddForm = false'>취소</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (consultations.Count == 0)
|
||||||
|
{
|
||||||
|
<p class="muted">상담 이력이 없습니다.</p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="admin-activity-list">
|
||||||
|
@foreach (var c in consultations)
|
||||||
|
{
|
||||||
|
<article class="admin-activity-card">
|
||||||
|
<div class="admin-activity-head">
|
||||||
|
<div>
|
||||||
|
<span class="muted">@c.ConsultationDate.ToString("yyyy-MM-dd") @(string.IsNullOrEmpty(c.ServiceType) ? "" : $"· {c.ServiceType}")</span>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="admin-icon-button danger" @onclick="@(() => DeleteConsultation(c.Id))">✕</button>
|
||||||
|
</div>
|
||||||
|
<p style="white-space: pre-wrap;">@c.Summary</p>
|
||||||
|
@if (!string.IsNullOrEmpty(c.Result))
|
||||||
|
{
|
||||||
|
<span class="status-pill info">@c.Result</span>
|
||||||
|
}
|
||||||
|
@if (c.Fee.HasValue)
|
||||||
|
{
|
||||||
|
<div class="muted">수임료: @c.Fee.Value.ToString("N0")원</div>
|
||||||
|
}
|
||||||
|
</article>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter] public int ClientId { get; set; }
|
||||||
|
private Domain.Entities.Client? client;
|
||||||
|
private List<Domain.Entities.Consultation> consultations = [];
|
||||||
|
private bool showAddForm;
|
||||||
|
private DateTime? newDate = DateTime.Today;
|
||||||
|
private string newServiceType = "";
|
||||||
|
private string newSummary = "";
|
||||||
|
private string newResult = "";
|
||||||
|
private decimal? newFee;
|
||||||
|
|
||||||
|
private string ConsultationDateText { get => newDate?.ToString("yyyy-MM-dd") ?? ""; set => newDate = DateTime.TryParse(value, out var dt) ? dt : null; }
|
||||||
|
private string FeeText { get => newFee?.ToString() ?? ""; set => newFee = decimal.TryParse(value, out var d) ? d : null; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync() => await LoadAll();
|
||||||
|
|
||||||
|
private async Task LoadAll()
|
||||||
|
{
|
||||||
|
client = await ClientService.GetByIdAsync(ClientId);
|
||||||
|
consultations = (await ConsultationService.GetByClientIdAsync(ClientId)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenAddConsultation()
|
||||||
|
{
|
||||||
|
showAddForm = true;
|
||||||
|
newDate = DateTime.Today;
|
||||||
|
newServiceType = "";
|
||||||
|
newSummary = "";
|
||||||
|
newResult = "";
|
||||||
|
newFee = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task AddConsultation()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(newSummary))
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "상담 내용을 입력하세요.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var c = new Domain.Entities.Consultation
|
||||||
|
{
|
||||||
|
ClientId = ClientId,
|
||||||
|
ConsultationDate = newDate?.ToUniversalTime() ?? DateTime.UtcNow,
|
||||||
|
ServiceType = string.IsNullOrWhiteSpace(newServiceType) ? null : newServiceType,
|
||||||
|
Summary = newSummary,
|
||||||
|
Result = string.IsNullOrWhiteSpace(newResult) ? null : newResult,
|
||||||
|
Fee = newFee
|
||||||
|
};
|
||||||
|
|
||||||
|
await ConsultationService.CreateAsync(c);
|
||||||
|
showAddForm = false;
|
||||||
|
consultations = (await ConsultationService.GetByClientIdAsync(ClientId)).ToList();
|
||||||
|
await JS.InvokeVoidAsync("alert", "상담이 추가되었습니다.");
|
||||||
|
}
|
||||||
|
catch (ValidationException ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteConsultation(int id)
|
||||||
|
{
|
||||||
|
if (!await JS.InvokeAsync<bool>("confirm", "이 상담을 삭제하시겠습니까?")) return;
|
||||||
|
await ConsultationService.DeleteAsync(id);
|
||||||
|
consultations = (await ConsultationService.GetByClientIdAsync(ClientId)).ToList();
|
||||||
|
await JS.InvokeVoidAsync("alert", "삭제되었습니다.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
@page "/admin/clients/create"
|
||||||
|
@page "/admin/clients/{Id:int}/edit"
|
||||||
|
@attribute [Authorize]
|
||||||
|
@using TaxBaik.Application.DTOs
|
||||||
|
@using TaxBaik.Web.Services
|
||||||
|
@using TaxBaik.Domain.Entities
|
||||||
|
@inject IClientBrowserClient ClientClient
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
|
||||||
|
<PageTitle>@(Id.HasValue ? "고객 수정" : "고객 등록")</PageTitle>
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">CRM</div>
|
||||||
|
<h1 class="admin-page-title">@(Id.HasValue ? "고객 수정" : "고객 등록")</h1>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="site-button secondary" @onclick='() => Navigation.NavigateTo("/taxbaik/admin/clients")'>목록으로</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="admin-surface" style="max-width:720px;">
|
||||||
|
@if (isLoading)
|
||||||
|
{
|
||||||
|
<Skeleton Count="5" CssClass="taxbaik-skeleton-grid" />
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<form class="admin-dialog-card" @onsubmit="SaveAsync" @onsubmit:preventDefault="true">
|
||||||
|
<label>고객명 * <input class="admin-input" @bind="dto.Name" /></label>
|
||||||
|
<label>회사명 <input class="admin-input" @bind="dto.CompanyName" /></label>
|
||||||
|
<label>연락처 <input class="admin-input" @bind="dto.Phone" /></label>
|
||||||
|
<label>이메일 <input class="admin-input" type="email" @bind="dto.Email" /></label>
|
||||||
|
<label>서비스 유형
|
||||||
|
<select class="admin-input" @bind="dto.ServiceType">
|
||||||
|
<option value="">선택하세요</option>
|
||||||
|
@foreach (var t in ClientService.ServiceTypes)
|
||||||
|
{
|
||||||
|
<option value="@t">@t</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>세금 유형
|
||||||
|
<select class="admin-input" @bind="dto.TaxType">
|
||||||
|
<option value="">선택하세요</option>
|
||||||
|
@foreach (var t in ClientService.TaxTypes)
|
||||||
|
{
|
||||||
|
<option value="@t">@t</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>상태
|
||||||
|
<select class="admin-input" @bind="dto.Status">
|
||||||
|
<option value="active">활성</option>
|
||||||
|
<option value="inactive">비활성</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>유입 경로
|
||||||
|
<select class="admin-input" @bind="dto.Source">
|
||||||
|
<option value="">선택하세요</option>
|
||||||
|
@foreach (var s in ClientService.Sources)
|
||||||
|
{
|
||||||
|
<option value="@s">@s</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>메모 <textarea class="admin-input" rows="4" @bind="dto.Memo"></textarea></label>
|
||||||
|
<div class="admin-dialog-actions">
|
||||||
|
<button type="submit" class="site-button primary" disabled="@isSaving">저장</button>
|
||||||
|
<button type="button" class="site-button secondary" @onclick='() => Navigation.NavigateTo("/taxbaik/admin/clients")'>취소</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter] public int? Id { get; set; }
|
||||||
|
private CreateClientDto dto = new() { Status = "active" };
|
||||||
|
private bool isLoading = true;
|
||||||
|
private bool isSaving;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
if (Id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var client = await ClientClient.GetByIdAsync(Id.Value);
|
||||||
|
if (client is null)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "고객을 찾을 수 없습니다.");
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/clients");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dto = new CreateClientDto
|
||||||
|
{
|
||||||
|
Name = client.Name,
|
||||||
|
CompanyName = client.CompanyName,
|
||||||
|
Phone = client.Phone,
|
||||||
|
Email = client.Email,
|
||||||
|
ServiceType = client.ServiceType,
|
||||||
|
TaxType = client.TaxType,
|
||||||
|
Status = client.Status,
|
||||||
|
Source = client.Source,
|
||||||
|
Memo = client.Memo
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"오류: {ex.Message}");
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/clients");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isLoading = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveAsync()
|
||||||
|
{
|
||||||
|
isSaving = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(dto.Name))
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "고객명을 입력하세요.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Id.HasValue)
|
||||||
|
{
|
||||||
|
var result = await ClientClient.UpdateAsync(Id.Value, dto);
|
||||||
|
await JS.InvokeVoidAsync("alert", result != null ? "고객 정보가 수정되었습니다." : "수정에 실패했습니다.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var result = await ClientClient.CreateAsync(dto);
|
||||||
|
await JS.InvokeVoidAsync("alert", result != null ? "고객이 등록되었습니다." : "등록에 실패했습니다.");
|
||||||
|
}
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/clients");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"저장 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
isSaving = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
@page "/admin/clients"
|
||||||
|
@attribute [Authorize]
|
||||||
|
@using TaxBaik.Web.Services
|
||||||
|
@using TaxBaik.Domain.Entities
|
||||||
|
@inject IClientBrowserClient ClientClient
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
|
||||||
|
<PageTitle>고객 관리</PageTitle>
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">CRM</div>
|
||||||
|
<h1 class="admin-page-title">고객 관리</h1>
|
||||||
|
<p class="admin-page-subtitle">고객 카드를 등록하고 상담 이력을 관리합니다.</p>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="site-button primary" @onclick='() => Navigation.NavigateTo("/taxbaik/admin/clients/create")'>고객 등록</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="admin-surface mb-3 pa-3">
|
||||||
|
<div class="admin-filter-grid">
|
||||||
|
<input class="admin-input" placeholder="검색 (이름·연락처·회사명)" @bind="searchText" @onkeyup="OnSearchKeyUp" />
|
||||||
|
<select class="admin-input" @bind="statusFilter">
|
||||||
|
<option value="">전체</option>
|
||||||
|
<option value="active">활성</option>
|
||||||
|
<option value="inactive">비활성</option>
|
||||||
|
</select>
|
||||||
|
<button type="button" class="site-button secondary" @onclick="SearchAsync">검색</button>
|
||||||
|
<button type="button" class="site-button secondary" @onclick="ResetAsync">초기화</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="admin-surface">
|
||||||
|
@if (clients is null)
|
||||||
|
{
|
||||||
|
<Skeleton Count="6" CssClass="taxbaik-skeleton-grid" />
|
||||||
|
}
|
||||||
|
else if (!clients.Any())
|
||||||
|
{
|
||||||
|
<div class="muted mt-4">등록된 고객이 없습니다.</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="admin-table-wrap">
|
||||||
|
<table class="admin-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>이름</th>
|
||||||
|
<th>회사명</th>
|
||||||
|
<th>연락처</th>
|
||||||
|
<th>서비스</th>
|
||||||
|
<th>세금 유형</th>
|
||||||
|
<th>상태</th>
|
||||||
|
<th>유입 경로</th>
|
||||||
|
<th>등록일</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var c in clients)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td><strong>@c.Name</strong></td>
|
||||||
|
<td>@(c.CompanyName ?? "—")</td>
|
||||||
|
<td>@(c.Phone ?? "—")</td>
|
||||||
|
<td>@(c.ServiceType ?? "—")</td>
|
||||||
|
<td>@(c.TaxType ?? "—")</td>
|
||||||
|
<td>@(c.Status == "active" ? "활성" : "비활성")</td>
|
||||||
|
<td>@(c.Source ?? "—")</td>
|
||||||
|
<td class="small">@c.CreatedAt.ToLocalTime().ToString("yy.MM.dd")</td>
|
||||||
|
<td>
|
||||||
|
<div class="admin-row-actions">
|
||||||
|
<button type="button" class="admin-icon-button" @onclick="@(() => Navigation.NavigateTo($"/taxbaik/admin/clients/{c.Id}/edit"))">✎</button>
|
||||||
|
<button type="button" class="admin-icon-button danger" @onclick="@(() => DeleteAsync(c))">✕</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
@if (totalPages > 1)
|
||||||
|
{
|
||||||
|
<div class="admin-pagination">
|
||||||
|
<button type="button" class="site-button secondary" disabled="@(currentPage <= 1)" @onclick="PreviousPage">이전</button>
|
||||||
|
<span>@currentPage / @totalPages</span>
|
||||||
|
<button type="button" class="site-button secondary" disabled="@(currentPage >= totalPages)" @onclick="NextPage">다음</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<div class="admin-table-footer">총 @(totalCount)명</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter] private Task<AuthenticationState>? AuthStateTask { get; set; }
|
||||||
|
private List<Client>? clients;
|
||||||
|
private string searchText = "";
|
||||||
|
private string statusFilter = "";
|
||||||
|
private int currentPage = 1;
|
||||||
|
private int totalCount;
|
||||||
|
private int totalPages;
|
||||||
|
private const int PageSize = 20;
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender && AuthStateTask != null)
|
||||||
|
{
|
||||||
|
var authState = await AuthStateTask;
|
||||||
|
if (authState.User.Identity?.IsAuthenticated == true)
|
||||||
|
{
|
||||||
|
await LoadAsync();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var (items, total) = await ClientClient.GetPagedAsync(currentPage, PageSize, string.IsNullOrEmpty(statusFilter) ? null : statusFilter, string.IsNullOrEmpty(searchText) ? null : searchText);
|
||||||
|
clients = items.ToList();
|
||||||
|
totalCount = total;
|
||||||
|
totalPages = (int)Math.Ceiling((double)total / PageSize);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"오류: {ex.Message}");
|
||||||
|
clients = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SearchAsync() { currentPage = 1; await LoadAsync(); }
|
||||||
|
private async Task ResetAsync() { searchText = ""; statusFilter = ""; currentPage = 1; await LoadAsync(); }
|
||||||
|
private async Task PreviousPage() { if (currentPage > 1) { currentPage--; await LoadAsync(); } }
|
||||||
|
private async Task NextPage() { if (currentPage < totalPages) { currentPage++; await LoadAsync(); } }
|
||||||
|
private async Task OnSearchKeyUp(KeyboardEventArgs e) { if (e.Key == "Enter") await SearchAsync(); }
|
||||||
|
private async Task DeleteAsync(Client client)
|
||||||
|
{
|
||||||
|
var confirmed = await JS.InvokeAsync<bool>("confirm", $"'{client.Name}' 고객을 삭제하시겠습니까? 관련 데이터도 함께 삭제됩니다.");
|
||||||
|
if (!confirmed) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var success = await ClientClient.DeleteAsync(client.Id);
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"{client.Name} 고객이 삭제되었습니다.");
|
||||||
|
await LoadAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"오류: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
@page "/admin/companies/create"
|
||||||
|
@attribute [Authorize]
|
||||||
|
@using TaxBaik.Web.Components.Admin.Forms
|
||||||
|
@inject IApiClient ApiClient
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
|
||||||
|
<PageTitle>고객사 등록</PageTitle>
|
||||||
|
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">Settings</div>
|
||||||
|
<h1 class="admin-page-title">새 고객사 등록</h1>
|
||||||
|
<p class="admin-page-subtitle">새로운 고객사를 추가합니다.</p>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="site-button secondary" @onclick="GoBack">취소</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="admin-surface mt-4">
|
||||||
|
<CompanyForm ButtonText="등록" OnSubmit="HandleCreate" OnCancel="GoBack" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private void GoBack()
|
||||||
|
{
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/companies");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task HandleCreate(CompanyForm.CompanyFormModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await ApiClient.PostAsync<object>("company", new
|
||||||
|
{
|
||||||
|
companyCode = model.CompanyCode,
|
||||||
|
companyName = model.CompanyName,
|
||||||
|
contactPerson = model.ContactPerson,
|
||||||
|
phone = model.Phone,
|
||||||
|
email = model.Email,
|
||||||
|
memo = model.Memo
|
||||||
|
});
|
||||||
|
|
||||||
|
await JS.InvokeVoidAsync("alert", "고객사가 등록되었습니다.");
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/companies");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"등록 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
@page "/admin/companies/{id:int}/edit"
|
||||||
|
@attribute [Authorize]
|
||||||
|
@using TaxBaik.Web.Components.Admin.Forms
|
||||||
|
@inject IApiClient ApiClient
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
|
||||||
|
<PageTitle>고객사 수정</PageTitle>
|
||||||
|
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">Settings</div>
|
||||||
|
<h1 class="admin-page-title">고객사 수정</h1>
|
||||||
|
<p class="admin-page-subtitle">고객사 정보를 수정합니다.</p>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="site-button secondary" @onclick="GoBack">취소</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
@if (isLoading)
|
||||||
|
{
|
||||||
|
<div class="admin-surface mt-4">
|
||||||
|
<Skeleton Count="4" CssClass="taxbaik-skeleton-grid" />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else if (formModel == null)
|
||||||
|
{
|
||||||
|
<div class="admin-surface mt-4">고객사를 찾을 수 없습니다.</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="admin-surface mt-4">
|
||||||
|
<CompanyForm ButtonText="수정" InitialData="formModel" OnSubmit="HandleUpdate" OnCancel="GoBack" />
|
||||||
|
<div class="mt-4">
|
||||||
|
<button type="button" class="site-button secondary danger" @onclick="DeleteCompany">고객사 삭제</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
private CompanyForm.CompanyFormModel? formModel;
|
||||||
|
private bool isLoading = true;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var company = await ApiClient.GetAsync<dynamic>($"company/{Id}");
|
||||||
|
IDictionary<string, object>? dict = company as IDictionary<string, object>;
|
||||||
|
if (dict != null)
|
||||||
|
{
|
||||||
|
formModel = new CompanyForm.CompanyFormModel
|
||||||
|
{
|
||||||
|
CompanyCode = (string)dict["companyCode"],
|
||||||
|
CompanyName = (string)dict["companyName"],
|
||||||
|
ContactPerson = (string?)dict["contactPerson"],
|
||||||
|
Phone = (string?)dict["phone"],
|
||||||
|
Email = (string?)dict["email"],
|
||||||
|
Memo = (string?)dict["memo"],
|
||||||
|
IsActive = (bool)(dynamic)dict["isActive"]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"고객사 로드 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GoBack()
|
||||||
|
{
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/companies");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task HandleUpdate(CompanyForm.CompanyFormModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await ApiClient.PutAsync<object>($"company/{Id}", new
|
||||||
|
{
|
||||||
|
companyCode = model.CompanyCode,
|
||||||
|
companyName = model.CompanyName,
|
||||||
|
contactPerson = model.ContactPerson,
|
||||||
|
phone = model.Phone,
|
||||||
|
email = model.Email,
|
||||||
|
memo = model.Memo,
|
||||||
|
isActive = model.IsActive
|
||||||
|
});
|
||||||
|
|
||||||
|
await JS.InvokeVoidAsync("alert", "고객사가 수정되었습니다.");
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/companies");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"수정 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteCompany()
|
||||||
|
{
|
||||||
|
if (!await JS.InvokeAsync<bool>("confirm", "정말 삭제하시겠습니까? 이 작업은 취소할 수 없습니다."))
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await ApiClient.DeleteAsync($"company/{Id}");
|
||||||
|
await JS.InvokeVoidAsync("alert", "고객사가 삭제되었습니다.");
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/companies");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"삭제 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
@page "/admin/companies"
|
||||||
|
@attribute [Authorize]
|
||||||
|
@inject IApiClient ApiClient
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
|
||||||
|
<PageTitle>고객사 관리</PageTitle>
|
||||||
|
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">Settings</div>
|
||||||
|
<h1 class="admin-page-title">고객사 관리</h1>
|
||||||
|
<p class="admin-page-subtitle">등록된 고객사를 관리하고 새로운 고객사를 추가합니다.</p>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="site-button primary" @onclick='() => NavTo("/taxbaik/admin/companies/create")'>새 고객사 등록</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="admin-surface mb-4 mt-4">
|
||||||
|
<div class="admin-summary-bar">
|
||||||
|
<span>@($"전체 고객사 {totalCompanies}개")</span>
|
||||||
|
<span>페이지 @currentPage / @totalPages</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="admin-surface">
|
||||||
|
@if (isLoading)
|
||||||
|
{
|
||||||
|
<Skeleton Count="6" CssClass="taxbaik-skeleton-grid" />
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="admin-table-wrap">
|
||||||
|
<table class="admin-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>회사코드</th>
|
||||||
|
<th>회사명</th>
|
||||||
|
<th>담당자</th>
|
||||||
|
<th>전화</th>
|
||||||
|
<th>이메일</th>
|
||||||
|
<th>활성</th>
|
||||||
|
<th>등록일</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in companies)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@item.CompanyCode</td>
|
||||||
|
<td>@item.CompanyName</td>
|
||||||
|
<td>@(item.ContactPerson ?? "—")</td>
|
||||||
|
<td>@(item.Phone ?? "—")</td>
|
||||||
|
<td>@(item.Email ?? "—")</td>
|
||||||
|
<td>@(item.IsActive ? "활성" : "비활성")</td>
|
||||||
|
<td>@item.CreatedAt.ToString("yyyy-MM-dd")</td>
|
||||||
|
<td><a class="site-button secondary" href="@($"/taxbaik/admin/companies/{item.Id}/edit")">수정</a></td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="admin-pagination">
|
||||||
|
<button type="button" class="site-button secondary" disabled="@(currentPage <= 1 || isLoading)" @onclick="PreviousPage">이전</button>
|
||||||
|
<button type="button" class="site-button secondary" disabled="@(currentPage >= totalPages || isLoading)" @onclick="NextPage">다음</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private List<CompanyDto> companies = [];
|
||||||
|
private bool isLoading = true;
|
||||||
|
private int currentPage = 1;
|
||||||
|
private int totalPages = 1;
|
||||||
|
private int totalCompanies = 0;
|
||||||
|
private const int PageSize = 20;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
await LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
isLoading = true;
|
||||||
|
var response = await ApiClient.GetAsync<dynamic>($"company?page={currentPage}&pageSize={PageSize}");
|
||||||
|
|
||||||
|
IDictionary<string, object>? dict = response as IDictionary<string, object>;
|
||||||
|
if (dict != null)
|
||||||
|
{
|
||||||
|
totalCompanies = (int)(dynamic)dict["total"];
|
||||||
|
totalPages = (totalCompanies + PageSize - 1) / PageSize;
|
||||||
|
|
||||||
|
if (dict["data"] is System.Collections.IEnumerable dataList)
|
||||||
|
{
|
||||||
|
companies = new List<CompanyDto>();
|
||||||
|
foreach (var item in dataList)
|
||||||
|
{
|
||||||
|
if (item is IDictionary<string, object> companyDict)
|
||||||
|
{
|
||||||
|
companies.Add(new CompanyDto
|
||||||
|
{
|
||||||
|
Id = (int)(dynamic)companyDict["id"],
|
||||||
|
CompanyCode = (string)companyDict["companyCode"],
|
||||||
|
CompanyName = (string)companyDict["companyName"],
|
||||||
|
ContactPerson = (string?)companyDict["contactPerson"],
|
||||||
|
Phone = (string?)companyDict["phone"],
|
||||||
|
Email = (string?)companyDict["email"],
|
||||||
|
IsActive = (bool)(dynamic)companyDict["isActive"],
|
||||||
|
CreatedAt = DateTime.Parse(companyDict["createdAt"].ToString()!)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"고객사 로드 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task NextPage()
|
||||||
|
{
|
||||||
|
currentPage++;
|
||||||
|
await LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task PreviousPage()
|
||||||
|
{
|
||||||
|
currentPage = Math.Max(1, currentPage - 1);
|
||||||
|
await LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CompanyDto
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string CompanyCode { get; set; } = "";
|
||||||
|
public string CompanyName { get; set; } = "";
|
||||||
|
public string? ContactPerson { get; set; }
|
||||||
|
public string? Phone { get; set; }
|
||||||
|
public string? Email { get; set; }
|
||||||
|
public bool IsActive { get; set; }
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private string NavTo(string url) => url;
|
||||||
|
}
|
||||||
@@ -0,0 +1,215 @@
|
|||||||
|
@page "/admin/consulting-activities"
|
||||||
|
@using TaxBaik.Web.Services.AdminClients
|
||||||
|
@inject IConsultingActivityBrowserClient ActivityClient
|
||||||
|
@inject IClientBrowserClient ClientClient
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
@attribute [Authorize]
|
||||||
|
|
||||||
|
<PageTitle>상담 활동 관리</PageTitle>
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">CRM & 세무관리</div>
|
||||||
|
<h1 class="admin-page-title">상담 활동 관리</h1>
|
||||||
|
<p class="admin-page-subtitle">고객별 상담 이력과 팔로업을 추적합니다.</p>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="site-button primary" @onclick="OpenCreateDialog">새 활동 기록</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="admin-surface">
|
||||||
|
@if (activities is null)
|
||||||
|
{
|
||||||
|
<Skeleton Count="6" CssClass="taxbaik-skeleton-grid" />
|
||||||
|
}
|
||||||
|
else if (activities.Count == 0)
|
||||||
|
{
|
||||||
|
<div class="muted">상담 활동이 없습니다.</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="admin-table-wrap">
|
||||||
|
<table class="admin-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>고객</th>
|
||||||
|
<th>활동 유형</th>
|
||||||
|
<th>활동일시</th>
|
||||||
|
<th>설명</th>
|
||||||
|
<th>다음 팔로업</th>
|
||||||
|
<th>작업</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in activities)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@item.Id</td>
|
||||||
|
<td>@clientMap.GetValueOrDefault(item.ClientId, $"Client #{item.ClientId}")</td>
|
||||||
|
<td>@item.ActivityType</td>
|
||||||
|
<td>@item.ActivityDate.ToString("g")</td>
|
||||||
|
<td>@Truncate(item.Description)</td>
|
||||||
|
<td>@(item.NextFollowupDate?.ToString("yyyy-MM-dd") ?? "—")</td>
|
||||||
|
<td>
|
||||||
|
<div class="admin-row-actions">
|
||||||
|
<button type="button" class="admin-icon-button" @onclick="@(async () => await OpenEditDialog(item))">✎</button>
|
||||||
|
<button type="button" class="admin-icon-button danger" @onclick="@(async () => await DeleteActivity(item.Id))">✕</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<dialog class="admin-dialog" open="@isDialogOpen">
|
||||||
|
<form class="admin-dialog-card" @onsubmit="SaveActivity" @onsubmit:preventDefault="true">
|
||||||
|
<h3>@(editingActivity == null ? "새 활동 기록" : "활동 기록 수정")</h3>
|
||||||
|
<label>고객
|
||||||
|
<select class="admin-input" @bind="ClientIdText">
|
||||||
|
<option value="">선택하세요</option>
|
||||||
|
@foreach (var client in clients)
|
||||||
|
{
|
||||||
|
<option value="@client.Id.ToString()">@GetClientDisplayName(client)</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>활동 유형
|
||||||
|
<select class="admin-input" @bind="activityForm.ActivityType">
|
||||||
|
<option value="">선택하세요</option>
|
||||||
|
<option value="방문 상담">방문 상담</option>
|
||||||
|
<option value="전화 상담">전화 상담</option>
|
||||||
|
<option value="세무조사 대응 미팅">세무조사 대응 미팅</option>
|
||||||
|
<option value="카카오톡 상담">카카오톡 상담</option>
|
||||||
|
<option value="이메일 자료 접수">이메일 자료 접수</option>
|
||||||
|
<option value="기타">기타</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>활동일 <input class="admin-input" type="text" placeholder="2026-06-29 14:00" @bind="ActivityDateText" /></label>
|
||||||
|
<label>설명 <textarea class="admin-input" rows="4" @bind="activityForm.Description"></textarea></label>
|
||||||
|
<label>다음 팔로업일 <input class="admin-input" type="text" placeholder="2026-07-10" @bind="NextFollowupText" /></label>
|
||||||
|
<div class="admin-dialog-actions">
|
||||||
|
<button type="button" class="site-button secondary" @onclick="CloseDialog">취소</button>
|
||||||
|
<button type="submit" class="site-button primary">저장</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter] private Task<AuthenticationState>? AuthStateTask { get; set; }
|
||||||
|
private List<ConsultingActivity>? activities;
|
||||||
|
private List<Client> clients = [];
|
||||||
|
private Dictionary<int, string> clientMap = new();
|
||||||
|
private bool isDialogOpen;
|
||||||
|
private ConsultingActivity? editingActivity;
|
||||||
|
private ConsultingActivityForm activityForm = new();
|
||||||
|
|
||||||
|
private string ClientIdText { get => activityForm.ClientId > 0 ? activityForm.ClientId.ToString() : ""; set => activityForm.ClientId = int.TryParse(value, out var id) ? id : 0; }
|
||||||
|
private string ActivityDateText { get => activityForm.ActivityDate?.ToString("yyyy-MM-dd HH:mm") ?? ""; set => activityForm.ActivityDate = DateTime.TryParse(value, out var dt) ? dt : null; }
|
||||||
|
private string NextFollowupText { get => activityForm.NextFollowupDate?.ToString("yyyy-MM-dd") ?? ""; set => activityForm.NextFollowupDate = DateTime.TryParse(value, out var dt) ? dt : null; }
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender && AuthStateTask != null)
|
||||||
|
{
|
||||||
|
var authState = await AuthStateTask;
|
||||||
|
if (authState.User.Identity?.IsAuthenticated == true)
|
||||||
|
{
|
||||||
|
await LoadData();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
activities = await ActivityClient.GetAllAsync();
|
||||||
|
var (clientItems, _) = await ClientClient.GetPagedAsync(pageSize: 1000);
|
||||||
|
clients = clientItems.ToList();
|
||||||
|
clientMap = clients.ToDictionary(c => c.Id, GetClientDisplayName);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"데이터 로드 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenCreateDialog()
|
||||||
|
{
|
||||||
|
editingActivity = null;
|
||||||
|
activityForm = new ConsultingActivityForm { ClientId = clients.FirstOrDefault()?.Id ?? 0, ActivityDate = DateTime.Now };
|
||||||
|
isDialogOpen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OpenEditDialog(ConsultingActivity activity)
|
||||||
|
{
|
||||||
|
editingActivity = activity;
|
||||||
|
activityForm = new ConsultingActivityForm
|
||||||
|
{
|
||||||
|
ClientId = activity.ClientId,
|
||||||
|
ActivityType = activity.ActivityType,
|
||||||
|
ActivityDate = activity.ActivityDate,
|
||||||
|
Description = activity.Description,
|
||||||
|
NextFollowupDate = activity.NextFollowupDate
|
||||||
|
};
|
||||||
|
isDialogOpen = true;
|
||||||
|
await Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveActivity()
|
||||||
|
{
|
||||||
|
if (activityForm.ClientId <= 0 || string.IsNullOrWhiteSpace(activityForm.ActivityType) || string.IsNullOrWhiteSpace(activityForm.Description))
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "필수 항목을 입력해주세요.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (editingActivity == null)
|
||||||
|
{
|
||||||
|
var newId = await ActivityClient.CreateAsync(activityForm.ClientId, activityForm.ActivityType, activityForm.ActivityDate ?? DateTime.Now, activityForm.Description, null, activityForm.NextFollowupDate);
|
||||||
|
if (newId > 0)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "활동이 기록되었습니다.");
|
||||||
|
CloseDialog();
|
||||||
|
await LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await ActivityClient.UpdateAsync(editingActivity.Id, null, activityForm.NextFollowupDate);
|
||||||
|
await JS.InvokeVoidAsync("alert", "활동이 업데이트되었습니다.");
|
||||||
|
CloseDialog();
|
||||||
|
await LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"저장 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteActivity(int id)
|
||||||
|
{
|
||||||
|
if (!await JS.InvokeAsync<bool>("confirm", "이 활동을 삭제하시겠습니까?")) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await ActivityClient.DeleteAsync(id);
|
||||||
|
await JS.InvokeVoidAsync("alert", "활동이 삭제되었습니다.");
|
||||||
|
await LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"삭제 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CloseDialog() { isDialogOpen = false; editingActivity = null; activityForm = new(); }
|
||||||
|
private static string Truncate(string? text) => string.IsNullOrWhiteSpace(text) ? "—" : text.Length > 30 ? text[..30] + "..." : text;
|
||||||
|
private static string GetClientDisplayName(Client client) => !string.IsNullOrWhiteSpace(client.CompanyName) ? client.CompanyName : !string.IsNullOrWhiteSpace(client.Name) ? client.Name : $"Client #{client.Id}";
|
||||||
|
private sealed class ConsultingActivityForm { public int ClientId { get; set; } public string ActivityType { get; set; } = ""; public DateTime? ActivityDate { get; set; } = DateTime.Now; public string Description { get; set; } = ""; public DateTime? NextFollowupDate { get; set; } }
|
||||||
|
}
|
||||||
@@ -0,0 +1,190 @@
|
|||||||
|
@page "/admin/contracts"
|
||||||
|
@using TaxBaik.Web.Services.AdminClients
|
||||||
|
@inject IContractBrowserClient ContractClient
|
||||||
|
@inject IClientBrowserClient ClientClient
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
@attribute [Authorize]
|
||||||
|
|
||||||
|
<PageTitle>계약 관리</PageTitle>
|
||||||
|
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">CRM & 세무관리</div>
|
||||||
|
<h1 class="admin-page-title">계약 관리</h1>
|
||||||
|
<p class="admin-page-subtitle">고객 계약과 월 정기수익을 함께 관리합니다.</p>
|
||||||
|
@if (mrr > 0)
|
||||||
|
{
|
||||||
|
<p class="admin-page-subtitle mt-2">월 정기수익: <strong>₩@mrr.ToString("N0")</strong></p>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<button type="button" class="site-button primary" @onclick="OpenCreateDialog">새 계약 추가</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="admin-surface">
|
||||||
|
@if (contracts is null)
|
||||||
|
{
|
||||||
|
<Skeleton Count="5" CssClass="taxbaik-skeleton-grid" />
|
||||||
|
}
|
||||||
|
else if (contracts.Count == 0)
|
||||||
|
{
|
||||||
|
<div class="muted">계약이 없습니다.</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="admin-table-wrap">
|
||||||
|
<table class="admin-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>고객</th>
|
||||||
|
<th>계약번호</th>
|
||||||
|
<th>서비스 유형</th>
|
||||||
|
<th>월 수수료</th>
|
||||||
|
<th>계약기간</th>
|
||||||
|
<th>상태</th>
|
||||||
|
<th>작업</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in contracts)
|
||||||
|
{
|
||||||
|
var isActive = !item.EndDate.HasValue || item.EndDate.Value >= DateTime.Today;
|
||||||
|
<tr>
|
||||||
|
<td>@item.Id</td>
|
||||||
|
<td>@(clientMap.TryGetValue(item.ClientId, out var clientName) ? clientName : "")</td>
|
||||||
|
<td>@item.ContractNumber</td>
|
||||||
|
<td>@item.ServiceType</td>
|
||||||
|
<td>@(item.MonthlyFee?.ToString("C") ?? "—")</td>
|
||||||
|
<td>@item.StartDate@if (item.EndDate.HasValue){<span>~ @item.EndDate.Value</span>}</td>
|
||||||
|
<td><span class="status-pill @(isActive ? "success" : "muted")">@(isActive ? "활성" : "만료")</span></td>
|
||||||
|
<td><button type="button" class="admin-icon-button danger" @onclick="@(async () => await DeleteContract(item.Id))">✕</button></td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<dialog class="admin-dialog" open="@isDialogOpen">
|
||||||
|
<form class="admin-dialog-card" @onsubmit="SaveContract" @onsubmit:preventDefault="true">
|
||||||
|
<h3>새 계약 추가</h3>
|
||||||
|
<label>고객
|
||||||
|
<select class="admin-input" @bind="ClientIdText">
|
||||||
|
<option value="">선택하세요</option>
|
||||||
|
@foreach (var client in clients)
|
||||||
|
{
|
||||||
|
<option value="@client.Id.ToString()">@GetClientDisplayName(client)</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>계약번호 <input class="admin-input" @bind="contractForm.ContractNumber" /></label>
|
||||||
|
<label>서비스 유형
|
||||||
|
<select class="admin-input" @bind="contractForm.ServiceType">
|
||||||
|
<option value="개인 기장대리">개인 기장대리</option>
|
||||||
|
<option value="법인 기장대리">법인 기장대리</option>
|
||||||
|
<option value="세무조정 대행">세무조정 대행</option>
|
||||||
|
<option value="양도세 신고대리">양도세 신고대리</option>
|
||||||
|
<option value="상속·증여 자문">상속·증여 자문</option>
|
||||||
|
<option value="세무조사 대응">세무조사 대응</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>계약 시작일 <input class="admin-input" type="text" placeholder="2026-06-29" @bind="StartDateText" /></label>
|
||||||
|
<label>월 수수료 <input class="admin-input" type="text" placeholder="100000" @bind="MonthlyFeeText" /></label>
|
||||||
|
<div class="admin-dialog-actions">
|
||||||
|
<button type="button" class="site-button secondary" @onclick="CloseDialog">취소</button>
|
||||||
|
<button type="submit" class="site-button primary">저장</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter] private Task<AuthenticationState>? AuthStateTask { get; set; }
|
||||||
|
private List<Contract>? contracts;
|
||||||
|
private List<Client> clients = [];
|
||||||
|
private Dictionary<int, string> clientMap = new();
|
||||||
|
private decimal mrr = 0;
|
||||||
|
private bool isDialogOpen;
|
||||||
|
private ContractForm contractForm = new();
|
||||||
|
private string ClientIdText { get => contractForm.ClientId > 0 ? contractForm.ClientId.ToString() : ""; set => contractForm.ClientId = int.TryParse(value, out var id) ? id : 0; }
|
||||||
|
private string StartDateText { get => contractForm.StartDate?.ToString("yyyy-MM-dd") ?? ""; set => contractForm.StartDate = DateTime.TryParse(value, out var dt) ? dt : null; }
|
||||||
|
private string MonthlyFeeText { get => contractForm.MonthlyFee?.ToString() ?? ""; set => contractForm.MonthlyFee = decimal.TryParse(value, out var amount) ? amount : null; }
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender && AuthStateTask != null)
|
||||||
|
{
|
||||||
|
var authState = await AuthStateTask;
|
||||||
|
if (authState.User.Identity?.IsAuthenticated == true)
|
||||||
|
{
|
||||||
|
await LoadData();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
contracts = await ContractClient.GetAllAsync();
|
||||||
|
var (clientItems, _) = await ClientClient.GetPagedAsync(pageSize: 1000);
|
||||||
|
clients = clientItems.ToList();
|
||||||
|
clientMap = clients.ToDictionary(c => c.Id, GetClientDisplayName);
|
||||||
|
mrr = await ContractClient.GetMonthlyRecurringRevenueAsync();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"데이터 로드 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenCreateDialog()
|
||||||
|
{
|
||||||
|
contractForm = new ContractForm { ClientId = clients.FirstOrDefault()?.Id ?? 0, StartDate = DateTime.Today };
|
||||||
|
isDialogOpen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveContract()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (contractForm.ClientId <= 0)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "고객을 선택하세요.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var newId = await ContractClient.CreateAsync(contractForm.ClientId, contractForm.ContractNumber, contractForm.ServiceType, contractForm.StartDate ?? DateTime.Today, contractForm.MonthlyFee);
|
||||||
|
if (newId > 0)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "계약이 추가되었습니다.");
|
||||||
|
CloseDialog();
|
||||||
|
await LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"저장 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteContract(int id)
|
||||||
|
{
|
||||||
|
if (!await JS.InvokeAsync<bool>("confirm", "이 계약을 삭제하시겠습니까?")) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await ContractClient.DeleteAsync(id);
|
||||||
|
await JS.InvokeVoidAsync("alert", "계약이 삭제되었습니다.");
|
||||||
|
await LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"삭제 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CloseDialog() { isDialogOpen = false; contractForm = new(); }
|
||||||
|
private static string GetClientDisplayName(Client client) => !string.IsNullOrWhiteSpace(client.CompanyName) ? client.CompanyName : !string.IsNullOrWhiteSpace(client.Name) ? client.Name : $"Client #{client.Id}";
|
||||||
|
private sealed class ContractForm { public int ClientId { get; set; } public string ContractNumber { get; set; } = ""; public string ServiceType { get; set; } = ""; public DateTime? StartDate { get; set; } public decimal? MonthlyFee { get; set; } }
|
||||||
|
}
|
||||||
@@ -1,106 +1,212 @@
|
|||||||
@page "/admin/dashboard"
|
@page "/admin/dashboard"
|
||||||
@attribute [Authorize]
|
@attribute [Authorize]
|
||||||
@using TaxBaik.Application.Services
|
@using TaxBaik.Web.Services
|
||||||
@inject AdminDashboardService DashboardService
|
@inject IAdminDashboardClient DashboardClient
|
||||||
|
@inject NavigationManager Nav
|
||||||
|
|
||||||
<PageTitle>대시보드</PageTitle>
|
<PageTitle>대시보드</PageTitle>
|
||||||
|
|
||||||
<section class="admin-page-hero">
|
<section class="admin-page-hero">
|
||||||
<div>
|
<div>
|
||||||
<MudText Typo="Typo.caption" Class="admin-eyebrow">Overview</MudText>
|
<div class="admin-eyebrow">Overview</div>
|
||||||
<MudText Typo="Typo.h4" Class="admin-page-title">대시보드</MudText>
|
<h1 class="admin-page-title">대시보드</h1>
|
||||||
<MudText Typo="Typo.body2" Class="admin-page-subtitle">문의 흐름과 콘텐츠 상태를 한 화면에서 확인합니다.</MudText>
|
<p class="admin-page-subtitle">문의 흐름과 콘텐츠 상태를 한 화면에서 확인합니다.</p>
|
||||||
</div>
|
</div>
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" StartIcon="@Icons.Material.Filled.Add" Href="/taxbaik/admin/blog/create">
|
<button type="button" class="site-button primary" @onclick='() => Nav.NavigateTo("/taxbaik/admin/blog/create")'>새 포스트 작성</button>
|
||||||
새 포스트 작성
|
|
||||||
</MudButton>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<MudGrid Class="admin-metric-grid">
|
@if (summary is null)
|
||||||
<MudItem xs="12" sm="6" md="3">
|
{
|
||||||
<MudPaper Class="admin-metric-card accent-blue" Elevation="0">
|
<div class="admin-metric-grid">
|
||||||
<MudText Typo="Typo.caption">이번달 문의</MudText>
|
<Skeleton Count="4" CssClass="taxbaik-skeleton-grid" />
|
||||||
<MudText Typo="Typo.h3">@summary.ThisMonthInquiries</MudText>
|
|
||||||
<MudText Typo="Typo.body2">월간 상담 유입</MudText>
|
|
||||||
</MudPaper>
|
|
||||||
</MudItem>
|
|
||||||
|
|
||||||
<MudItem xs="12" sm="6" md="3">
|
|
||||||
<MudPaper Class="admin-metric-card accent-amber" Elevation="0">
|
|
||||||
<MudText Typo="Typo.caption">신규 문의</MudText>
|
|
||||||
<MudText Typo="Typo.h3">@summary.NewInquiries</MudText>
|
|
||||||
<MudText Typo="Typo.body2">처리 대기</MudText>
|
|
||||||
</MudPaper>
|
|
||||||
</MudItem>
|
|
||||||
|
|
||||||
<MudItem xs="12" sm="6" md="3">
|
|
||||||
<MudPaper Class="admin-metric-card accent-slate" Elevation="0">
|
|
||||||
<MudText Typo="Typo.caption">전체 포스트</MudText>
|
|
||||||
<MudText Typo="Typo.h3">@summary.TotalPosts</MudText>
|
|
||||||
<MudText Typo="Typo.body2">콘텐츠 자산</MudText>
|
|
||||||
</MudPaper>
|
|
||||||
</MudItem>
|
|
||||||
|
|
||||||
<MudItem xs="12" sm="6" md="3">
|
|
||||||
<MudPaper Class="admin-metric-card accent-green" Elevation="0">
|
|
||||||
<MudText Typo="Typo.caption">발행된 포스트</MudText>
|
|
||||||
<MudText Typo="Typo.h3">@summary.PublishedPosts</MudText>
|
|
||||||
<MudText Typo="Typo.body2">검색 노출 대상</MudText>
|
|
||||||
</MudPaper>
|
|
||||||
</MudItem>
|
|
||||||
</MudGrid>
|
|
||||||
|
|
||||||
<MudPaper Class="admin-surface mt-4" Elevation="0">
|
|
||||||
<div class="admin-section-header">
|
|
||||||
<div>
|
|
||||||
<MudText Typo="Typo.h6">최근 문의</MudText>
|
|
||||||
<MudText Typo="Typo.body2">최근 유입된 상담 요청을 빠르게 확인합니다.</MudText>
|
|
||||||
</div>
|
|
||||||
<MudButton Variant="Variant.Outlined" Color="Color.Primary" Href="/taxbaik/admin/inquiries">문의 전체 보기</MudButton>
|
|
||||||
</div>
|
</div>
|
||||||
<MudSimpleTable Striped="true" Dense="true" Class="admin-table">
|
<div class="admin-surface mt-4">
|
||||||
<thead>
|
<Skeleton Count="4" CssClass="taxbaik-skeleton-grid" />
|
||||||
<tr>
|
</div>
|
||||||
<th>이름</th>
|
<div class="admin-surface mt-4">
|
||||||
<th>전화</th>
|
<Skeleton Count="4" CssClass="taxbaik-skeleton-grid" />
|
||||||
<th>분야</th>
|
</div>
|
||||||
<th>상태</th>
|
}
|
||||||
<th>날짜</th>
|
else
|
||||||
</tr>
|
{
|
||||||
</thead>
|
<div class="admin-metric-grid">
|
||||||
<tbody>
|
<div class="admin-metric-card accent-blue cursor-pointer" @onclick='(() => Nav.NavigateTo("/taxbaik/admin/inquiries"))'>
|
||||||
@foreach (var inquiry in summary.RecentInquiries)
|
<div class="metric-card-inner">
|
||||||
{
|
<span class="metric-label">이번달 문의</span>
|
||||||
<tr>
|
<div class="metric-value-row">
|
||||||
<td>@inquiry.Name</td>
|
<span class="metric-value blue">@summary.ThisMonthInquiries</span>
|
||||||
<td>@inquiry.Phone</td>
|
<span class="metric-icon">💬</span>
|
||||||
<td>@inquiry.ServiceType</td>
|
</div>
|
||||||
<td>
|
<span class="metric-hint">월간 상담 유입</span>
|
||||||
<MudChip Size="Size.Small"
|
</div>
|
||||||
Color="@(inquiry.Status == "new" ? Color.Warning : inquiry.Status == "contacted" ? Color.Info : Color.Success)">
|
</div>
|
||||||
@GetStatusLabel(inquiry.Status)
|
|
||||||
</MudChip>
|
<div class="admin-metric-card accent-amber cursor-pointer" @onclick='(() => Nav.NavigateTo("/taxbaik/admin/inquiries?status=new"))'>
|
||||||
</td>
|
<div class="metric-card-inner">
|
||||||
<td>@inquiry.CreatedAt.ToString("yyyy-MM-dd")</td>
|
<span class="metric-label">신규 문의</span>
|
||||||
</tr>
|
<div class="metric-value-row">
|
||||||
}
|
<span class="metric-value amber">@summary.NewInquiries</span>
|
||||||
</tbody>
|
<span class="metric-icon">⚠️</span>
|
||||||
</MudSimpleTable>
|
</div>
|
||||||
</MudPaper>
|
<span class="metric-hint">처리 대기</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="admin-metric-card accent-slate cursor-pointer" @onclick='(() => Nav.NavigateTo("/taxbaik/admin/blog"))'>
|
||||||
|
<div class="metric-card-inner">
|
||||||
|
<span class="metric-label">전체 포스트</span>
|
||||||
|
<div class="metric-value-row">
|
||||||
|
<span class="metric-value slate">@summary.TotalPosts</span>
|
||||||
|
<span class="metric-icon">📄</span>
|
||||||
|
</div>
|
||||||
|
<span class="metric-hint">콘텐츠 자산</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="admin-metric-card accent-green cursor-pointer" @onclick='(() => Nav.NavigateTo("/taxbaik/admin/blog"))'>
|
||||||
|
<div class="metric-card-inner">
|
||||||
|
<span class="metric-label">발행된 포스트</span>
|
||||||
|
<div class="metric-value-row">
|
||||||
|
<span class="metric-value green">@summary.PublishedPosts</span>
|
||||||
|
<span class="metric-icon">🌐</span>
|
||||||
|
</div>
|
||||||
|
<span class="metric-hint">검색 노출 대상</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (upcomingFilings.Count == 0)
|
||||||
|
{
|
||||||
|
<div class="admin-surface mt-4">이번 달 마감 임박 신고가 없습니다.</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="admin-surface mt-4">
|
||||||
|
<div class="admin-section-header">
|
||||||
|
<div>
|
||||||
|
<h3 class="admin-section-title">이번 달 마감 임박 신고</h3>
|
||||||
|
<p class="muted">30일 이내 신고 예정 건</p>
|
||||||
|
</div>
|
||||||
|
<a class="site-button secondary" href="/taxbaik/admin/tax-filings">전체 일정 보기</a>
|
||||||
|
</div>
|
||||||
|
<div class="admin-table-wrap">
|
||||||
|
<table class="admin-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>고객</th>
|
||||||
|
<th>신고 유형</th>
|
||||||
|
<th>기한</th>
|
||||||
|
<th>D-day</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var f in upcomingFilings)
|
||||||
|
{
|
||||||
|
var dday = (f.DueDate.Date - DateTime.Today).Days;
|
||||||
|
<tr>
|
||||||
|
<td><a href="@($"/taxbaik/admin/clients/{f.ClientId}")">@f.ClientName</a></td>
|
||||||
|
<td>@f.FilingType</td>
|
||||||
|
<td>@f.DueDate.ToString("yyyy-MM-dd")</td>
|
||||||
|
<td>
|
||||||
|
@if (dday < 0)
|
||||||
|
{
|
||||||
|
<span class="status-pill dark">기한 초과 (@(-dday)일)</span>
|
||||||
|
}
|
||||||
|
else if (dday <= 7)
|
||||||
|
{
|
||||||
|
<span class="status-pill danger">D-@dday</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<span>D-@dday</span>
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (summary is not null)
|
||||||
|
{
|
||||||
|
<div class="admin-surface mt-4">
|
||||||
|
<div class="admin-section-header">
|
||||||
|
<div>
|
||||||
|
<h3 class="admin-section-title">최근 문의</h3>
|
||||||
|
<p class="muted">최근 유입된 상담 요청을 빠르게 확인합니다.</p>
|
||||||
|
</div>
|
||||||
|
<a class="site-button secondary" href="/taxbaik/admin/inquiries">문의 전체 보기</a>
|
||||||
|
</div>
|
||||||
|
<div class="admin-table-wrap">
|
||||||
|
<table class="admin-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>이름</th>
|
||||||
|
<th>전화</th>
|
||||||
|
<th>분야</th>
|
||||||
|
<th>상태</th>
|
||||||
|
<th>날짜</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var inquiry in summary.RecentInquiries)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td><a href="@($"/taxbaik/admin/inquiries/{inquiry.Id}")">@inquiry.Name</a></td>
|
||||||
|
<td>@inquiry.Phone</td>
|
||||||
|
<td>@inquiry.ServiceType</td>
|
||||||
|
<td><span class="status-pill @GetStatusClass(inquiry.Status)">@GetStatusLabel(inquiry.Status)</span></td>
|
||||||
|
<td>@inquiry.CreatedAt.ToString("yyyy-MM-dd")</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private AdminDashboardSummary summary = new(0, 0, 0, 0, []);
|
[CascadingParameter]
|
||||||
|
private Task<AuthenticationState>? AuthStateTask { get; set; }
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
private AdminDashboardSummary? summary;
|
||||||
{
|
private List<Domain.Entities.TaxFiling> upcomingFilings = [];
|
||||||
summary = await DashboardService.GetSummaryAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetStatusLabel(string status) => status switch
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
"new" => "신규",
|
if (firstRender && AuthStateTask != null)
|
||||||
"contacted" => "연락함",
|
{
|
||||||
"completed" => "완료",
|
var authState = await AuthStateTask;
|
||||||
_ => status
|
if (authState.User.Identity?.IsAuthenticated == true)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var summaryTask = DashboardClient.GetSummaryAsync();
|
||||||
|
var filingsTask = DashboardClient.GetUpcomingFilingsAsync(30);
|
||||||
|
await Task.WhenAll(summaryTask, filingsTask);
|
||||||
|
summary = await summaryTask;
|
||||||
|
upcomingFilings = (await filingsTask).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"Dashboard error: {ex.Message}");
|
||||||
|
}
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetStatusLabel(string status) => InquiryStatusMapper.Labels.GetValueOrDefault(status, status);
|
||||||
|
private static string GetStatusClass(string status) => status switch
|
||||||
|
{
|
||||||
|
"new" => "warning",
|
||||||
|
"consulting" => "info",
|
||||||
|
"contracted" => "success",
|
||||||
|
"rejected" => "danger",
|
||||||
|
"closed" => "dark",
|
||||||
|
_ => "default"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,112 @@
|
|||||||
|
@page "/admin/faqs/create"
|
||||||
|
@page "/admin/faqs/{Id:int}/edit"
|
||||||
|
@attribute [Authorize]
|
||||||
|
@using TaxBaik.Web.Services
|
||||||
|
@using TaxBaik.Domain.Entities
|
||||||
|
@inject IFaqBrowserClient FaqClient
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
|
||||||
|
<PageTitle>@(Id.HasValue ? "FAQ 수정" : "FAQ 등록")</PageTitle>
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">홈페이지</div>
|
||||||
|
<h1 class="admin-page-title">@(Id.HasValue ? "FAQ 수정" : "FAQ 등록")</h1>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="site-button secondary" @onclick='() => Navigation.NavigateTo("/taxbaik/admin/faqs")'>목록으로</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="admin-surface" style="max-width:720px;">
|
||||||
|
@if (isLoading)
|
||||||
|
{
|
||||||
|
<Skeleton Count="4" CssClass="taxbaik-skeleton-grid" />
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<form class="admin-dialog-card" @onsubmit="SaveAsync" @onsubmit:preventDefault="true">
|
||||||
|
<label>질문 * <textarea class="admin-input" rows="3" @bind="faq.Question"></textarea></label>
|
||||||
|
<label>답변 * <textarea class="admin-input" rows="6" @bind="faq.Answer"></textarea></label>
|
||||||
|
<label>카테고리
|
||||||
|
<select class="admin-input" @bind="faq.Category">
|
||||||
|
<option value="">선택하세요</option>
|
||||||
|
@foreach (var cat in FaqService.Categories)
|
||||||
|
{
|
||||||
|
<option value="@cat">@cat</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>정렬 순서 <input class="admin-input" type="number" min="0" max="9999" @bind="SortOrderText" /></label>
|
||||||
|
<label><input type="checkbox" @bind="faq.IsActive" /> 노출 중</label>
|
||||||
|
<div class="admin-dialog-actions">
|
||||||
|
<button type="submit" class="site-button primary" disabled="@isSaving">저장</button>
|
||||||
|
<button type="button" class="site-button secondary" @onclick='() => Navigation.NavigateTo("/taxbaik/admin/faqs")'>취소</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter] public int? Id { get; set; }
|
||||||
|
private Faq faq = new() { SortOrder = 10, IsActive = true };
|
||||||
|
private bool isLoading = true;
|
||||||
|
private bool isSaving;
|
||||||
|
private string SortOrderText { get => faq.SortOrder.ToString(); set => faq.SortOrder = int.TryParse(value, out var n) ? n : 0; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
if (Id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var existing = await FaqClient.GetByIdAsync(Id.Value);
|
||||||
|
if (existing is null)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "FAQ를 찾을 수 없습니다.");
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/faqs");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
faq = existing;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"오류: {ex.Message}");
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/faqs");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isLoading = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveAsync()
|
||||||
|
{
|
||||||
|
isSaving = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(faq.Question) || string.IsNullOrWhiteSpace(faq.Answer))
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "질문과 답변을 입력하세요.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Id.HasValue)
|
||||||
|
{
|
||||||
|
var result = await FaqClient.UpdateAsync(Id.Value, faq);
|
||||||
|
await JS.InvokeVoidAsync("alert", result != null ? "FAQ가 수정되었습니다." : "수정 실패");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var result = await FaqClient.CreateAsync(faq);
|
||||||
|
await JS.InvokeVoidAsync("alert", result != null ? "FAQ가 등록되었습니다." : "등록 실패");
|
||||||
|
}
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/faqs");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"저장 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
isSaving = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
@page "/admin/faqs"
|
||||||
|
@attribute [Authorize]
|
||||||
|
@using TaxBaik.Web.Services
|
||||||
|
@using TaxBaik.Domain.Entities
|
||||||
|
@inject IFaqBrowserClient FaqClient
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
|
||||||
|
<PageTitle>FAQ 관리</PageTitle>
|
||||||
|
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">홈페이지</div>
|
||||||
|
<h1 class="admin-page-title">FAQ 관리</h1>
|
||||||
|
<p class="admin-page-subtitle">홈페이지 자주 묻는 질문을 등록하고 순서를 관리합니다.</p>
|
||||||
|
</div>
|
||||||
|
<a class="site-button primary" href="/taxbaik/admin/faqs/create">FAQ 등록</a>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="admin-surface">
|
||||||
|
@if (faqs is null)
|
||||||
|
{
|
||||||
|
<Skeleton Count="5" CssClass="taxbaik-skeleton-grid" />
|
||||||
|
}
|
||||||
|
else if (!faqs.Any())
|
||||||
|
{
|
||||||
|
<div class="muted">등록된 FAQ가 없습니다.</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="admin-table-wrap">
|
||||||
|
<table class="admin-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>순서</th>
|
||||||
|
<th>질문</th>
|
||||||
|
<th>카테고리</th>
|
||||||
|
<th>상태</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in faqs)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@item.SortOrder</td>
|
||||||
|
<td>@item.Question</td>
|
||||||
|
<td>@(string.IsNullOrEmpty(item.Category) ? "" : item.Category)</td>
|
||||||
|
<td><span class="status-pill @(item.IsActive ? "success" : "default")">@(item.IsActive ? "노출 중" : "비활성")</span></td>
|
||||||
|
<td>
|
||||||
|
<div class="admin-actions">
|
||||||
|
<button type="button" class="admin-icon-button" @onclick="@(() => Navigation.NavigateTo($"/taxbaik/admin/faqs/{item.Id}/edit"))">✎</button>
|
||||||
|
<button type="button" class="admin-icon-button danger" @onclick="@(() => DeleteAsync(item))">✕</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="muted mt-2">총 @(faqs.Count)개 · 노출 중 @(faqs.Count(f => f.IsActive))개</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
private Task<AuthenticationState>? AuthStateTask { get; set; }
|
||||||
|
|
||||||
|
private List<Faq>? faqs;
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender && AuthStateTask != null)
|
||||||
|
{
|
||||||
|
var authState = await AuthStateTask;
|
||||||
|
if (authState.User.Identity?.IsAuthenticated == true)
|
||||||
|
{
|
||||||
|
await LoadAsync();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
faqs = (await FaqClient.GetAllAsync()).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"오류: {ex.Message}");
|
||||||
|
faqs = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteAsync(Faq item)
|
||||||
|
{
|
||||||
|
var confirmed = await JS.InvokeAsync<bool>("confirm", $"'{item.Question}' 항목을 삭제하시겠습니까?");
|
||||||
|
if (!confirmed) return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var success = await FaqClient.DeleteAsync(item.Id);
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "FAQ가 삭제되었습니다.");
|
||||||
|
await LoadAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "삭제 실패");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"오류: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
@page "/admin/inquiries/create"
|
||||||
|
@attribute [Authorize]
|
||||||
|
@using TaxBaik.Application.DTOs
|
||||||
|
@using TaxBaik.Application.Services
|
||||||
|
@using TaxBaik.Web.Components.Admin.Forms
|
||||||
|
@inject InquiryService InquiryService
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
|
||||||
|
<PageTitle>문의 등록</PageTitle>
|
||||||
|
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">Customer Relations</div>
|
||||||
|
<h1 class="admin-page-title">새 문의 등록</h1>
|
||||||
|
<p class="admin-page-subtitle">고객 문의를 등록합니다. (전화, 오프라인 등)</p>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="site-button secondary" @onclick="GoBack">취소</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="admin-surface mt-4">
|
||||||
|
<InquiryForm ButtonText="등록" OnSubmit="HandleCreate" OnCancel="GoBack" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private void GoBack() => Navigation.NavigateTo("/taxbaik/admin/inquiries");
|
||||||
|
|
||||||
|
private async Task HandleCreate(InquiryForm.InquiryFormModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await InquiryService.SubmitAsync(model.Name, model.Phone, model.ServiceType, model.Message, model.Email, ipAddress: "admin-registered");
|
||||||
|
await JS.InvokeVoidAsync("alert", "문의가 등록되었습니다.");
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/inquiries");
|
||||||
|
}
|
||||||
|
catch (ValidationException ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", ex.Message);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"등록 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,74 +1,77 @@
|
|||||||
@page "/admin/inquiries/{InquiryId:int}"
|
@page "/admin/inquiries/{InquiryId:int}"
|
||||||
@attribute [Authorize]
|
@attribute [Authorize]
|
||||||
@using TaxBaik.Application.Services
|
@using TaxBaik.Web.Services
|
||||||
@inject InquiryService InquiryService
|
@inject IInquiryBrowserClient InquiryClient
|
||||||
@inject NavigationManager Navigation
|
@inject NavigationManager Navigation
|
||||||
@inject ISnackbar Snackbar
|
@inject IJSRuntime JS
|
||||||
|
|
||||||
<PageTitle>문의 상세</PageTitle>
|
<PageTitle>문의 상세</PageTitle>
|
||||||
|
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">Inquiry Details</div>
|
||||||
|
<h1 class="admin-page-title">문의 상세</h1>
|
||||||
|
<p class="admin-page-subtitle">문의 정보를 확인하고 처리 상태를 관리합니다.</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
@if (inquiry != null)
|
@if (inquiry != null)
|
||||||
{
|
{
|
||||||
<MudButton Variant="Variant.Outlined"
|
<div class="admin-page-actions">
|
||||||
Color="Color.Primary"
|
<button type="button" class="site-button secondary" @onclick='() => Navigation.NavigateTo("/taxbaik/admin/inquiries")'>문의 목록으로</button>
|
||||||
StartIcon="@Icons.Material.Filled.ArrowBack"
|
</div>
|
||||||
@onclick="@(() => Navigation.NavigateTo("/taxbaik/admin/inquiries"))">
|
|
||||||
문의 목록으로 돌아가기
|
|
||||||
</MudButton>
|
|
||||||
|
|
||||||
<MudPaper Class="pa-4 mt-4" Elevation="1">
|
<div class="admin-detail-grid">
|
||||||
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Class="mb-4">
|
<section class="admin-surface">
|
||||||
<MudText Typo="Typo.h5">문의 상세</MudText>
|
<h3 class="admin-section-title">문의 정보</h3>
|
||||||
<MudButton Variant="Variant.Filled"
|
<div class="admin-kv-grid">
|
||||||
Color="Color.Primary"
|
<div><span>이름</span><strong>@inquiry.Name</strong></div>
|
||||||
StartIcon="@Icons.Material.Filled.List"
|
<div><span>연락처</span><strong>@inquiry.Phone</strong></div>
|
||||||
Href="/taxbaik/admin/inquiries">
|
<div><span>이메일</span><strong>@(inquiry.Email ?? "-")</strong></div>
|
||||||
다른 문의도 보기
|
<div><span>분야</span><strong>@inquiry.ServiceType</strong></div>
|
||||||
</MudButton>
|
<div class="span-2"><span>문의 내용</span><strong style="white-space: pre-wrap;">@inquiry.Message</strong></div>
|
||||||
</MudStack>
|
<div><span>접수일시</span><strong>@inquiry.CreatedAt.ToLocalTime().ToString("yyyy-MM-dd HH:mm")</strong></div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<MudGrid>
|
<section class="admin-surface">
|
||||||
<MudItem xs="12" md="6">
|
<h3 class="admin-section-title">담당자 메모</h3>
|
||||||
<MudText Typo="Typo.subtitle1">이름</MudText>
|
<textarea class="admin-input" rows="6" @bind="adminMemo"></textarea>
|
||||||
<MudText>@inquiry.Name</MudText>
|
<div class="admin-dialog-actions mt-3">
|
||||||
</MudItem>
|
<button type="button" class="site-button primary" @onclick="SaveMemo">메모 저장</button>
|
||||||
<MudItem xs="12" md="6">
|
</div>
|
||||||
<MudText Typo="Typo.subtitle1">연락처</MudText>
|
</section>
|
||||||
<MudText>@inquiry.Phone</MudText>
|
|
||||||
</MudItem>
|
<section class="admin-surface">
|
||||||
<MudItem xs="12" md="6">
|
<h3 class="admin-section-title">처리 상태</h3>
|
||||||
<MudText Typo="Typo.subtitle1">이메일</MudText>
|
<div class="admin-stack">
|
||||||
<MudText>@inquiry.Email</MudText>
|
@foreach (var (key, label) in InquiryStatusMapper.Labels)
|
||||||
</MudItem>
|
{
|
||||||
<MudItem xs="12" md="6">
|
<button type="button" class="@GetStatusButtonClass(key)" @onclick="@(() => OnStatusChanged(key))">@label</button>
|
||||||
<MudText Typo="Typo.subtitle1">분야</MudText>
|
}
|
||||||
<MudText>@inquiry.ServiceType</MudText>
|
</div>
|
||||||
</MudItem>
|
</section>
|
||||||
<MudItem xs="12">
|
|
||||||
<MudText Typo="Typo.subtitle1">메시지</MudText>
|
@if (inquiry.ClientId == null)
|
||||||
<MudPaper Class="pa-3 mt-2" Outlined="true">
|
{
|
||||||
<MudText Style="white-space: pre-wrap;">@inquiry.Message</MudText>
|
<section class="admin-surface">
|
||||||
</MudPaper>
|
<h3 class="admin-section-title">고객 카드 생성</h3>
|
||||||
</MudItem>
|
<p class="muted">이 문의를 고객 카드로 등록합니다.</p>
|
||||||
<MudItem xs="12">
|
<button type="button" class="site-button primary" @onclick="ConvertToClient">고객으로 등록</button>
|
||||||
<MudText Typo="Typo.subtitle1">상태</MudText>
|
</section>
|
||||||
<MudSelect T="string" Value="inquiry.Status" ValueChanged="@((string status) => OnStatusChanged(status))" Label="상태 변경">
|
}
|
||||||
<MudSelectItem Value="@("new")">신규</MudSelectItem>
|
else
|
||||||
<MudSelectItem Value="@("contacted")">연락함</MudSelectItem>
|
{
|
||||||
<MudSelectItem Value="@("completed")">완료</MudSelectItem>
|
<section class="admin-surface">
|
||||||
</MudSelect>
|
<h3 class="admin-section-title">연결된 고객</h3>
|
||||||
<MudStack Row="true" Class="mt-3" Spacing="2">
|
<a class="site-button secondary" href="@($"/taxbaik/admin/clients/{inquiry.ClientId}")">고객 카드 보기</a>
|
||||||
<MudButton Variant="Variant.Outlined" Color="Color.Warning" OnClick="@(() => OnStatusChanged("new"))">신규</MudButton>
|
</section>
|
||||||
<MudButton Variant="Variant.Outlined" Color="Color.Info" OnClick="@(() => OnStatusChanged("contacted"))">연락함</MudButton>
|
}
|
||||||
<MudButton Variant="Variant.Outlined" Color="Color.Success" OnClick="@(() => OnStatusChanged("completed"))">완료</MudButton>
|
</div>
|
||||||
</MudStack>
|
|
||||||
</MudItem>
|
|
||||||
</MudGrid>
|
|
||||||
</MudPaper>
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<MudText>문의를 찾을 수 없습니다.</MudText>
|
<div class="admin-surface">문의를 찾을 수 없습니다.</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
@@ -76,26 +79,86 @@ else
|
|||||||
public int InquiryId { get; set; }
|
public int InquiryId { get; set; }
|
||||||
|
|
||||||
private Domain.Entities.Inquiry? inquiry;
|
private Domain.Entities.Inquiry? inquiry;
|
||||||
|
private string adminMemo = "";
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
inquiry = await InquiryService.GetByIdAsync(InquiryId);
|
inquiry = await InquiryClient.GetByIdAsync(InquiryId);
|
||||||
|
adminMemo = inquiry?.AdminMemo ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnStatusChanged(string status)
|
private async Task OnStatusChanged(string status)
|
||||||
{
|
{
|
||||||
if (inquiry == null)
|
if (inquiry == null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await InquiryService.UpdateStatusAsync(inquiry.Id, status, "관리자");
|
var success = await InquiryClient.UpdateStatusAsync(inquiry.Id, status);
|
||||||
inquiry.Status = status;
|
if (success)
|
||||||
Snackbar.Add("상태가 변경되었습니다.", Severity.Success);
|
{
|
||||||
|
inquiry.Status = status;
|
||||||
|
await JS.InvokeVoidAsync("alert", "상태가 변경되었습니다.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "상태 변경에 실패했습니다.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (ValidationException ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Snackbar.Add(ex.Message, Severity.Error);
|
await JS.InvokeVoidAsync("alert", $"오류: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task SaveMemo()
|
||||||
|
{
|
||||||
|
if (inquiry == null) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var success = await InquiryClient.UpdateAdminMemoAsync(inquiry.Id, adminMemo);
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
inquiry.AdminMemo = adminMemo;
|
||||||
|
await JS.InvokeVoidAsync("alert", "메모가 저장되었습니다.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "메모 저장에 실패했습니다.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"오류: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ConvertToClient()
|
||||||
|
{
|
||||||
|
if (inquiry == null) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var clientId = await InquiryClient.ConvertToClientAsync(
|
||||||
|
inquiry.Id,
|
||||||
|
inquiry.Name,
|
||||||
|
inquiry.Phone,
|
||||||
|
inquiry.ServiceType);
|
||||||
|
|
||||||
|
if (clientId > 0)
|
||||||
|
{
|
||||||
|
inquiry.ClientId = clientId;
|
||||||
|
inquiry.Status = "consulting";
|
||||||
|
await JS.InvokeVoidAsync("alert", "고객 카드가 생성되었습니다.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "고객 카드 생성에 실패했습니다.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"오류: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetStatusButtonClass(string status)
|
||||||
|
=> inquiry?.Status == status ? "site-button primary" : "site-button secondary";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,120 @@
|
|||||||
|
@page "/admin/inquiries/{id:int}/edit"
|
||||||
|
@attribute [Authorize]
|
||||||
|
@using TaxBaik.Application.DTOs
|
||||||
|
@using TaxBaik.Application.Services
|
||||||
|
@using TaxBaik.Web.Components.Admin.Forms
|
||||||
|
@inject InquiryService InquiryService
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
|
||||||
|
<PageTitle>문의 수정</PageTitle>
|
||||||
|
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">Customer Relations</div>
|
||||||
|
<h1 class="admin-page-title">문의 수정</h1>
|
||||||
|
<p class="admin-page-subtitle">고객 문의 정보를 수정합니다.</p>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="site-button secondary" @onclick="GoBack">취소</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
@if (isLoading)
|
||||||
|
{
|
||||||
|
<div class="admin-surface mt-4"><Skeleton Count="4" CssClass="taxbaik-skeleton-grid" /></div>
|
||||||
|
}
|
||||||
|
else if (inquiry == null)
|
||||||
|
{
|
||||||
|
<div class="admin-surface mt-4">문의를 찾을 수 없습니다.</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="admin-surface mt-4">
|
||||||
|
<InquiryForm ButtonText="수정" InitialData="formModel" OnSubmit="HandleUpdate" OnCancel="GoBack" />
|
||||||
|
<div class="mt-4">
|
||||||
|
<button type="button" class="site-button secondary danger" @onclick="DeleteInquiry">문의 삭제</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter] public int Id { get; set; }
|
||||||
|
private Domain.Entities.Inquiry? inquiry;
|
||||||
|
private InquiryForm.InquiryFormModel? formModel;
|
||||||
|
private bool isLoading = true;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
inquiry = await InquiryService.GetByIdAsync(Id);
|
||||||
|
if (inquiry != null)
|
||||||
|
{
|
||||||
|
formModel = new InquiryForm.InquiryFormModel
|
||||||
|
{
|
||||||
|
Name = inquiry.Name,
|
||||||
|
Phone = inquiry.Phone,
|
||||||
|
Email = inquiry.Email,
|
||||||
|
ServiceType = inquiry.ServiceType,
|
||||||
|
Message = inquiry.Message,
|
||||||
|
Status = inquiry.Status,
|
||||||
|
AdminMemo = inquiry.AdminMemo
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"문의 로드 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GoBack() => Navigation.NavigateTo("/taxbaik/admin/inquiries");
|
||||||
|
|
||||||
|
private async Task HandleUpdate(InquiryForm.InquiryFormModel model)
|
||||||
|
{
|
||||||
|
if (inquiry == null) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
inquiry.Name = model.Name;
|
||||||
|
inquiry.Phone = model.Phone;
|
||||||
|
inquiry.Email = model.Email;
|
||||||
|
inquiry.ServiceType = model.ServiceType;
|
||||||
|
inquiry.Message = model.Message;
|
||||||
|
inquiry.AdminMemo = model.AdminMemo;
|
||||||
|
|
||||||
|
if (inquiry.Status != model.Status)
|
||||||
|
await InquiryService.UpdateStatusAsync(inquiry.Id, model.Status);
|
||||||
|
|
||||||
|
await InquiryService.UpdateAdminMemoAsync(inquiry.Id, model.AdminMemo);
|
||||||
|
await JS.InvokeVoidAsync("alert", "문의가 수정되었습니다.");
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/inquiries");
|
||||||
|
}
|
||||||
|
catch (ValidationException ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", ex.Message);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"수정 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteInquiry()
|
||||||
|
{
|
||||||
|
if (inquiry == null) return;
|
||||||
|
if (!await JS.InvokeAsync<bool>("confirm", "정말 삭제하시겠습니까? 이 작업은 취소할 수 없습니다.")) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await InquiryService.DeleteAsync(inquiry.Id);
|
||||||
|
await JS.InvokeVoidAsync("alert", "문의가 삭제되었습니다.");
|
||||||
|
Navigation.NavigateTo("/taxbaik/admin/inquiries");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"삭제 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,31 +1,77 @@
|
|||||||
@page "/admin/inquiries"
|
@page "/admin/inquiries"
|
||||||
@attribute [Authorize]
|
@attribute [Authorize]
|
||||||
@using TaxBaik.Domain.Interfaces
|
@using TaxBaik.Web.Services
|
||||||
@inject IInquiryRepository InquiryRepository
|
@inject IInquiryBrowserClient InquiryClient
|
||||||
|
|
||||||
<PageTitle>문의 관리</PageTitle>
|
<PageTitle>문의 관리</PageTitle>
|
||||||
|
|
||||||
<section class="admin-page-hero">
|
<section class="admin-page-hero">
|
||||||
<div>
|
<div>
|
||||||
<MudText Typo="Typo.caption" Class="admin-eyebrow">Customer Requests</MudText>
|
<div class="admin-eyebrow">Customer Requests</div>
|
||||||
<MudText Typo="Typo.h4" Class="admin-page-title">문의 관리</MudText>
|
<h1 class="admin-page-title">문의 관리</h1>
|
||||||
<MudText Typo="Typo.body2" Class="admin-page-subtitle">상담 요청을 상태별로 확인하고 후속 조치를 기록합니다.</MudText>
|
<p class="admin-page-subtitle">상담 요청을 상태별로 확인하고 후속 조치를 기록합니다.</p>
|
||||||
</div>
|
</div>
|
||||||
|
<button type="button" class="site-button primary" @onclick='() => Navigation.NavigateTo("/taxbaik/admin/inquiries/create")'>새 문의 등록</button>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<MudPaper Class="admin-surface" Elevation="0">
|
<div class="admin-surface">
|
||||||
<MudTabs Rounded="true" Elevation="0" Class="admin-tabs">
|
@if (isLoading)
|
||||||
<MudTabPanel Text="전체">
|
{
|
||||||
<InquiryTable Status="" />
|
<Skeleton Count="6" CssClass="taxbaik-skeleton-grid" />
|
||||||
</MudTabPanel>
|
}
|
||||||
<MudTabPanel Text="신규">
|
else
|
||||||
<InquiryTable Status="new" />
|
{
|
||||||
</MudTabPanel>
|
<div class="admin-tabbar">
|
||||||
<MudTabPanel Text="연락함">
|
<button type="button" class="admin-tab active">전체</button>
|
||||||
<InquiryTable Status="contacted" />
|
<button type="button" class="admin-tab">신규</button>
|
||||||
</MudTabPanel>
|
<button type="button" class="admin-tab">상담중</button>
|
||||||
<MudTabPanel Text="완료">
|
<button type="button" class="admin-tab">계약완료</button>
|
||||||
<InquiryTable Status="completed" />
|
<button type="button" class="admin-tab">거절</button>
|
||||||
</MudTabPanel>
|
<button type="button" class="admin-tab">종결</button>
|
||||||
</MudTabs>
|
</div>
|
||||||
</MudPaper>
|
<InquiryTable Inquiries="allInquiries" Status="" />
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
private Task<AuthenticationState>? AuthStateTask { get; set; }
|
||||||
|
[Inject] private NavigationManager Navigation { get; set; } = default!;
|
||||||
|
|
||||||
|
private bool isLoading = true;
|
||||||
|
private IReadOnlyList<Domain.Entities.Inquiry> allInquiries = [];
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
if (AuthStateTask != null)
|
||||||
|
{
|
||||||
|
var authState = await AuthStateTask;
|
||||||
|
if (authState.User.Identity?.IsAuthenticated == true)
|
||||||
|
{
|
||||||
|
await LoadData();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadData()
|
||||||
|
{
|
||||||
|
isLoading = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var (items, _) = await InquiryClient.GetPagedAsync(1, 200);
|
||||||
|
allInquiries = items.ToList();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
allInquiries = [];
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
isLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
@page "/admin/login"
|
@page "/admin/login"
|
||||||
|
@using Microsoft.FluentUI.AspNetCore.Components
|
||||||
@using System.ComponentModel.DataAnnotations
|
@using System.ComponentModel.DataAnnotations
|
||||||
@layout TaxBaik.Web.Components.Admin.Layout.BlankLayout
|
@layout TaxBaik.Web.Components.Admin.Layout.BlankLayout
|
||||||
@attribute [AllowAnonymous]
|
@attribute [AllowAnonymous]
|
||||||
@@ -6,42 +7,44 @@
|
|||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject CustomAuthenticationStateProvider AuthStateProvider
|
@inject CustomAuthenticationStateProvider AuthStateProvider
|
||||||
@inject IJSRuntime Js
|
@inject IJSRuntime Js
|
||||||
|
@inject ILocalStorageService LocalStorageService
|
||||||
|
|
||||||
<PageTitle>로그인</PageTitle>
|
<PageTitle>로그인</PageTitle>
|
||||||
|
|
||||||
<MudThemeProvider />
|
<div class="admin-login-page">
|
||||||
|
<div class="admin-login-card admin-surface">
|
||||||
|
<div class="admin-login-brand">
|
||||||
|
<span class="admin-brand-mark">T</span>
|
||||||
|
<div>
|
||||||
|
<div class="admin-brand-title">TaxBaik</div>
|
||||||
|
<div class="admin-brand-subtitle">관리자 로그인</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<MudContainer MaxWidth="MaxWidth.Small" Class="admin-login-page d-flex align-center justify-center" Style="min-height: 100vh;">
|
<form class="admin-login-form" @onsubmit="HandleLogin" @onsubmit:preventDefault>
|
||||||
<MudPaper Class="pa-8" Elevation="3" Style="width: 100%; max-width: 400px;">
|
<label class="admin-field">
|
||||||
<MudText Typo="Typo.h4" Class="mb-6 text-center">관리자 로그인</MudText>
|
<span class="admin-field-label">사용자명</span>
|
||||||
|
<input class="admin-input" type="text" placeholder="사용자명" @bind="model.Username" autocomplete="username" />
|
||||||
|
</label>
|
||||||
|
|
||||||
<div>
|
<label class="admin-field">
|
||||||
<InputText class="mud-input mud-input-outlined mud-input-root mud-input-root-adorned-start mb-4"
|
<span class="admin-field-label">비밀번호</span>
|
||||||
style="width: 100%; min-height: 56px; padding: 16px 14px;"
|
<input class="admin-input" type="password" placeholder="비밀번호" @bind="model.Password" autocomplete="current-password" />
|
||||||
placeholder="사용자명"
|
</label>
|
||||||
autocomplete="username"
|
|
||||||
@bind-Value="model.Username" />
|
|
||||||
|
|
||||||
<InputText type="password"
|
<label class="admin-login-remember">
|
||||||
class="mud-input mud-input-outlined mud-input-root mud-input-root-adorned-start mb-4"
|
<input type="checkbox" @bind="model.RememberMe" />
|
||||||
style="width: 100%; min-height: 56px; padding: 16px 14px;"
|
<span>아이디 저장</span>
|
||||||
placeholder="비밀번호"
|
</label>
|
||||||
autocomplete="current-password"
|
|
||||||
@bind-Value="model.Password" />
|
|
||||||
|
|
||||||
@if (!string.IsNullOrEmpty(errorMessage))
|
@if (!string.IsNullOrEmpty(errorMessage))
|
||||||
{
|
{
|
||||||
<MudAlert Severity="Severity.Error" Class="mb-4">@errorMessage</MudAlert>
|
<div class="admin-inline-alert error" role="alert">@errorMessage</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<button type="button"
|
<button type="submit" class="site-button primary admin-login-submit" disabled="@isLoading">
|
||||||
class="mud-button-root mud-button mud-button-filled mud-button-filled-primary mud-elevation-0"
|
|
||||||
style="width: 100%; min-height: 52px; border: 0; border-radius: 4px; color: white;"
|
|
||||||
@onclick="HandleLogin"
|
|
||||||
disabled="@isLoading">
|
|
||||||
@if (isLoading)
|
@if (isLoading)
|
||||||
{
|
{
|
||||||
<MudProgressCircular Size="Size.Small" Indeterminate="true" Class="mr-2" />
|
|
||||||
<span>로그인 중...</span>
|
<span>로그인 중...</span>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -49,15 +52,32 @@
|
|||||||
<span>로그인</span>
|
<span>로그인</span>
|
||||||
}
|
}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</form>
|
||||||
</MudPaper>
|
</div>
|
||||||
</MudContainer>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private bool isLoading = false;
|
private bool isLoading = false;
|
||||||
private string errorMessage = "";
|
private string errorMessage = "";
|
||||||
|
|
||||||
private LoginModel model = new();
|
private LoginModel model = new();
|
||||||
|
private const string RememberedUsernameKey = "admin-remembered-username";
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var remembered = await LocalStorageService.GetItemAsStringAsync(RememberedUsernameKey);
|
||||||
|
if (!string.IsNullOrEmpty(remembered))
|
||||||
|
{
|
||||||
|
model.Username = remembered;
|
||||||
|
model.RememberMe = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// LocalStorage not available in pre-render
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
@@ -78,15 +98,24 @@
|
|||||||
var request = new { model.Username, model.Password };
|
var request = new { model.Username, model.Password };
|
||||||
var response = await ApiClient.PostAsync<LoginResponse>("auth/login", request);
|
var response = await ApiClient.PostAsync<LoginResponse>("auth/login", request);
|
||||||
|
|
||||||
if (response?.Token == null)
|
if (response?.AccessToken == null || response?.RefreshToken == null)
|
||||||
{
|
{
|
||||||
errorMessage = "사용자명 또는 비밀번호가 올바르지 않습니다.";
|
errorMessage = "사용자명 또는 비밀번호가 올바르지 않습니다.";
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await ApiClient.SetAuthToken(response.Token);
|
if (model.RememberMe)
|
||||||
await AuthStateProvider.LoginAsync(response.Token);
|
{
|
||||||
|
await LocalStorageService.SetItemAsStringAsync(RememberedUsernameKey, model.Username);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await LocalStorageService.RemoveItemAsync(RememberedUsernameKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
await ApiClient.SetAuthToken(response.AccessToken);
|
||||||
|
await AuthStateProvider.LoginAsync(response.AccessToken, response.RefreshToken, response.ExpiresIn);
|
||||||
NavigationManager.NavigateTo(GetReturnUrl(), forceLoad: false);
|
NavigationManager.NavigateTo(GetReturnUrl(), forceLoad: false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@@ -98,7 +127,8 @@
|
|||||||
|
|
||||||
private class LoginResponse
|
private class LoginResponse
|
||||||
{
|
{
|
||||||
public string Token { get; set; } = "";
|
public string AccessToken { get; set; } = "";
|
||||||
|
public string RefreshToken { get; set; } = "";
|
||||||
public int ExpiresIn { get; set; }
|
public int ExpiresIn { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,6 +136,7 @@
|
|||||||
{
|
{
|
||||||
public string Username { get; set; } = "";
|
public string Username { get; set; } = "";
|
||||||
public string Password { get; set; } = "";
|
public string Password { get; set; } = "";
|
||||||
|
public bool RememberMe { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetReturnUrl()
|
private string GetReturnUrl()
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
@page "/admin/logout"
|
||||||
|
@using TaxBaik.Web.Services
|
||||||
|
@inject CustomAuthenticationStateProvider AuthStateProvider
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
|
<PageTitle>로그아웃</PageTitle>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
// 사용자 로그아웃
|
||||||
|
await AuthStateProvider.LogoutAsync();
|
||||||
|
|
||||||
|
// 로그인 페이지로 리다이렉트
|
||||||
|
NavigationManager.NavigateTo("/taxbaik/admin/login", forceLoad: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
@page "/admin/revenue-trackings"
|
||||||
|
@using TaxBaik.Web.Services.AdminClients
|
||||||
|
@inject IRevenueTrackingBrowserClient RevenueClient
|
||||||
|
@inject IClientBrowserClient ClientClient
|
||||||
|
@inject IJSRuntime JS
|
||||||
|
@attribute [Authorize]
|
||||||
|
|
||||||
|
<PageTitle>수익 추적 관리</PageTitle>
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">CRM & 세무관리</div>
|
||||||
|
<h1 class="admin-page-title">수익 추적 관리</h1>
|
||||||
|
<p class="admin-page-subtitle">청구, 납부, 미수금 상태를 한 화면에서 관리합니다.</p>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="site-button primary" @onclick="OpenCreateDialog">새 청구 추가</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="admin-surface">
|
||||||
|
@if (revenues is null)
|
||||||
|
{
|
||||||
|
<Skeleton Count="6" CssClass="taxbaik-skeleton-grid" />
|
||||||
|
}
|
||||||
|
else if (revenues.Count == 0)
|
||||||
|
{
|
||||||
|
<div class="muted">청구 기록이 없습니다.</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="admin-table-wrap">
|
||||||
|
<table class="admin-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>고객</th>
|
||||||
|
<th>청구번호</th>
|
||||||
|
<th>청구일</th>
|
||||||
|
<th>청구액</th>
|
||||||
|
<th>납부여부</th>
|
||||||
|
<th>작업</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in revenues)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@item.Id</td>
|
||||||
|
<td>@clientMap.GetValueOrDefault(item.ClientId, $"Client #{item.ClientId}")</td>
|
||||||
|
<td>@item.InvoiceNumber</td>
|
||||||
|
<td>@item.InvoiceDate.ToString("yyyy-MM-dd")</td>
|
||||||
|
<td>@item.Amount.ToString("C")</td>
|
||||||
|
<td><span class="status-pill @(item.PaymentStatus == "paid" ? "success" : "warning")">@(item.PaymentStatus == "paid" ? "납부" : "미납")</span></td>
|
||||||
|
<td>
|
||||||
|
<div class="admin-row-actions">
|
||||||
|
@if (item.PaymentStatus != "paid")
|
||||||
|
{
|
||||||
|
<button type="button" class="site-button secondary" @onclick="@(async () => await MarkPaid(item.Id))">완료</button>
|
||||||
|
}
|
||||||
|
<button type="button" class="admin-icon-button danger" @onclick="@(async () => await DeleteRevenue(item.Id))">✕</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<dialog class="admin-dialog" open="@isDialogOpen">
|
||||||
|
<form class="admin-dialog-card" @onsubmit="SaveRevenue" @onsubmit:preventDefault="true">
|
||||||
|
<h3>새 청구 추가</h3>
|
||||||
|
<label>고객
|
||||||
|
<select class="admin-input" @bind="ClientIdText">
|
||||||
|
<option value="">선택하세요</option>
|
||||||
|
@foreach (var client in clients)
|
||||||
|
{
|
||||||
|
<option value="@client.Id.ToString()">@GetClientDisplayName(client)</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>청구번호 <input class="admin-input" @bind="revenueForm.InvoiceNumber" /></label>
|
||||||
|
<label>청구일 <input class="admin-input" type="text" placeholder="2026-06-29" @bind="InvoiceDateText" /></label>
|
||||||
|
<label>청구액 <input class="admin-input" type="text" placeholder="100000" @bind="AmountText" /></label>
|
||||||
|
<label>서비스 유형
|
||||||
|
<select class="admin-input" @bind="revenueForm.ServiceType">
|
||||||
|
<option value="">선택하세요</option>
|
||||||
|
<option value="기장 수수료">기장 수수료</option>
|
||||||
|
<option value="세무조정료">세무조정료</option>
|
||||||
|
<option value="세무상담료">세무상담료</option>
|
||||||
|
<option value="신고 대행료">신고 대행료</option>
|
||||||
|
<option value="자문 수수료">자문 수수료</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>납부예정일 <input class="admin-input" type="text" placeholder="2026-07-13" @bind="DueDateText" /></label>
|
||||||
|
<div class="admin-dialog-actions">
|
||||||
|
<button type="button" class="site-button secondary" @onclick="CloseDialog">취소</button>
|
||||||
|
<button type="submit" class="site-button primary">저장</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter] private Task<AuthenticationState>? AuthStateTask { get; set; }
|
||||||
|
private List<RevenueTracking>? revenues;
|
||||||
|
private List<Client> clients = [];
|
||||||
|
private Dictionary<int, string> clientMap = new();
|
||||||
|
private bool isDialogOpen;
|
||||||
|
private RevenueForm revenueForm = new();
|
||||||
|
|
||||||
|
private string ClientIdText { get => revenueForm.ClientId > 0 ? revenueForm.ClientId.ToString() : ""; set => revenueForm.ClientId = int.TryParse(value, out var id) ? id : 0; }
|
||||||
|
private string InvoiceDateText { get => revenueForm.InvoiceDate?.ToString("yyyy-MM-dd") ?? ""; set => revenueForm.InvoiceDate = DateTime.TryParse(value, out var dt) ? dt : null; }
|
||||||
|
private string AmountText { get => revenueForm.Amount?.ToString() ?? ""; set => revenueForm.Amount = decimal.TryParse(value, out var amt) ? amt : null; }
|
||||||
|
private string DueDateText { get => revenueForm.DueDate?.ToString("yyyy-MM-dd") ?? ""; set => revenueForm.DueDate = DateTime.TryParse(value, out var dt) ? dt : null; }
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender && AuthStateTask != null)
|
||||||
|
{
|
||||||
|
var authState = await AuthStateTask;
|
||||||
|
if (authState.User.Identity?.IsAuthenticated == true)
|
||||||
|
{
|
||||||
|
await LoadData();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
revenues = await RevenueClient.GetAllAsync();
|
||||||
|
var (clientItems, _) = await ClientClient.GetPagedAsync(pageSize: 1000);
|
||||||
|
clients = clientItems.ToList();
|
||||||
|
clientMap = clients.ToDictionary(c => c.Id, GetClientDisplayName);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"데이터 로드 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenCreateDialog()
|
||||||
|
{
|
||||||
|
revenueForm = new RevenueForm { ClientId = clients.FirstOrDefault()?.Id ?? 0, InvoiceDate = DateTime.Today, DueDate = DateTime.Today.AddDays(14) };
|
||||||
|
isDialogOpen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveRevenue()
|
||||||
|
{
|
||||||
|
if (revenueForm.ClientId <= 0 || string.IsNullOrWhiteSpace(revenueForm.InvoiceNumber) || revenueForm.Amount is null)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "필수 항목을 입력해주세요.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var newId = await RevenueClient.CreateAsync(revenueForm.ClientId, revenueForm.InvoiceNumber, revenueForm.InvoiceDate ?? DateTime.Today, revenueForm.Amount.Value, revenueForm.ServiceType, revenueForm.DueDate);
|
||||||
|
if (newId > 0)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", "청구가 추가되었습니다.");
|
||||||
|
CloseDialog();
|
||||||
|
await LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"저장 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task MarkPaid(int id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await RevenueClient.MarkPaidAsync(id, DateTime.Now);
|
||||||
|
await JS.InvokeVoidAsync("alert", "납부가 처리되었습니다.");
|
||||||
|
await LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"처리 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteRevenue(int id)
|
||||||
|
{
|
||||||
|
if (!await JS.InvokeAsync<bool>("confirm", "이 청구를 삭제하시겠습니까?")) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await RevenueClient.DeleteAsync(id);
|
||||||
|
await JS.InvokeVoidAsync("alert", "청구가 삭제되었습니다.");
|
||||||
|
await LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("alert", $"삭제 실패: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CloseDialog() { isDialogOpen = false; revenueForm = new(); }
|
||||||
|
private static string GetClientDisplayName(Client client) => !string.IsNullOrWhiteSpace(client.CompanyName) ? client.CompanyName : !string.IsNullOrWhiteSpace(client.Name) ? client.Name : $"Client #{client.Id}";
|
||||||
|
private sealed class RevenueForm { public int ClientId { get; set; } public string InvoiceNumber { get; set; } = ""; public DateTime? InvoiceDate { get; set; } public decimal? Amount { get; set; } public string? ServiceType { get; set; } public DateTime? DueDate { get; set; } }
|
||||||
|
}
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
@page "/admin/season-simulator"
|
||||||
|
@attribute [Authorize]
|
||||||
|
@using TaxBaik.Application.Seasonal
|
||||||
|
@using TaxBaik.Application.Services
|
||||||
|
|
||||||
|
<PageTitle>시즌 시뮬레이터</PageTitle>
|
||||||
|
|
||||||
|
<section class="admin-page-hero">
|
||||||
|
<div>
|
||||||
|
<div class="admin-eyebrow">Season Preview</div>
|
||||||
|
<h1 class="admin-page-title">시즌 시뮬레이터</h1>
|
||||||
|
<p class="admin-page-subtitle">날짜를 선택해 홈페이지 시즌 화면이 어떻게 보이는지 미리 확인합니다.</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="admin-detail-grid">
|
||||||
|
<section class="admin-surface">
|
||||||
|
<h3 class="admin-section-title">시뮬레이션 날짜</h3>
|
||||||
|
<input class="admin-input" type="text" placeholder="yyyy-MM-dd" @bind="SimulationDateText" />
|
||||||
|
<div class="admin-divider"></div>
|
||||||
|
<div class="admin-stack">
|
||||||
|
@foreach (var season in TaxSeasonCalendar.Seasons)
|
||||||
|
{
|
||||||
|
<button type="button" class="site-button secondary" @onclick="@(() => JumpToSeason(season))">@season.StartMonth/@season.StartDay - @season.Name</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="admin-surface">
|
||||||
|
<h3 class="admin-section-title">홈페이지 미리보기</h3>
|
||||||
|
<p class="muted">@(simulationDate?.ToString("yyyy년 MM월 dd일") ?? "날짜를 선택하세요")</p>
|
||||||
|
@if (activeSeason != null)
|
||||||
|
{
|
||||||
|
<span class="status-pill warning">@activeSeason.Name 시즌 활성</span>
|
||||||
|
<div class="season-preview">
|
||||||
|
@if (activeSeason.DaysUntilDeadline <= 7 && activeSeason.DaysUntilDeadline >= 0)
|
||||||
|
{
|
||||||
|
<div class="season-badge">D-@activeSeason.DaysUntilDeadline 마감 임박</div>
|
||||||
|
}
|
||||||
|
<div class="season-headline">@activeSeason.HeroHeadline</div>
|
||||||
|
<div class="season-subtext">@activeSeason.HeroSubtext</div>
|
||||||
|
<div class="season-cta">@activeSeason.CtaText</div>
|
||||||
|
</div>
|
||||||
|
<div class="admin-kv-grid mt-4">
|
||||||
|
<div><span>활성 시즌 키</span><strong><code>@activeSeason.Key</code></strong></div>
|
||||||
|
<div><span>마감까지</span><strong>@(activeSeason.DaysUntilDeadline >= 0 ? $"D-{activeSeason.DaysUntilDeadline}" : $"마감 후 @(-activeSeason.DaysUntilDeadline)일")</strong></div>
|
||||||
|
<div><span>포커스 서비스</span><strong>@activeSeason.FocusService</strong></div>
|
||||||
|
<div><span>블로그 카테고리</span><strong>@activeSeason.RelatedCategorySlug</strong></div>
|
||||||
|
<div class="span-2"><span>긴박감 배지 문구</span><strong><code>@activeSeason.UrgencyBadge</code></strong></div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="muted">선택한 날짜는 시즌 비활성 기간입니다. 홈페이지는 기본 Hero를 표시합니다.</div>
|
||||||
|
<div class="season-preview mt-4">
|
||||||
|
<div class="season-headline">사업자 세금, 부동산,<br />가족자산까지</div>
|
||||||
|
<div class="season-subtext">세무사·부동산중개사·보험설계사 자격 보유 | 온라인 맞춤 상담</div>
|
||||||
|
<div class="season-cta">무료 상담 신청</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="admin-surface mt-4">
|
||||||
|
<h3 class="admin-section-title">연간 시즌 타임라인</h3>
|
||||||
|
<div class="admin-table-wrap">
|
||||||
|
<table class="admin-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>기간</th>
|
||||||
|
<th>시즌</th>
|
||||||
|
<th>블로그 카테고리</th>
|
||||||
|
<th>상태</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var s in TaxSeasonCalendar.Seasons)
|
||||||
|
{
|
||||||
|
var isActive = activeSeason?.Key == s.Key;
|
||||||
|
<tr>
|
||||||
|
<td>@s.StartMonth/@s.StartDay ~ @s.EndMonth/@s.EndDay</td>
|
||||||
|
<td>@s.Name</td>
|
||||||
|
<td><code>@s.RelatedCategorySlug</code></td>
|
||||||
|
<td>@(isActive ? "활성" : "비활성")</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private DateTime? simulationDate = DateTime.Today;
|
||||||
|
private CurrentSeasonDto? activeSeason;
|
||||||
|
private string SimulationDateText { get => simulationDate?.ToString("yyyy-MM-dd") ?? ""; set { simulationDate = DateTime.TryParse(value, out var dt) ? dt : null; ComputeSeason(); } }
|
||||||
|
|
||||||
|
protected override void OnInitialized() => ComputeSeason();
|
||||||
|
|
||||||
|
private void ComputeSeason()
|
||||||
|
{
|
||||||
|
if (simulationDate == null) { activeSeason = null; return; }
|
||||||
|
var date = simulationDate.Value;
|
||||||
|
var season = TaxSeasonCalendar.Seasons.FirstOrDefault(s =>
|
||||||
|
{
|
||||||
|
var start = new DateTime(date.Year, s.StartMonth, s.StartDay);
|
||||||
|
var endYear = (s.EndMonth < s.StartMonth) ? date.Year + 1 : date.Year;
|
||||||
|
var end = new DateTime(endYear, s.EndMonth, s.EndDay);
|
||||||
|
return date >= start && date <= end;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (season == null) { activeSeason = null; return; }
|
||||||
|
|
||||||
|
var endYearCalc = (season.EndMonth < season.StartMonth) ? date.Year + 1 : date.Year;
|
||||||
|
var deadline = new DateTime(endYearCalc, season.EndMonth, season.EndDay);
|
||||||
|
var ddays = (deadline.Date - date.Date).Days;
|
||||||
|
var badge = ddays <= 7 && ddays >= 0 ? season.UrgencyBadge.Replace("{n}", ddays.ToString()) : season.UrgencyBadge;
|
||||||
|
|
||||||
|
activeSeason = new CurrentSeasonDto
|
||||||
|
{
|
||||||
|
Key = season.Key,
|
||||||
|
Name = season.Name,
|
||||||
|
HeroHeadline = season.HeroHeadline,
|
||||||
|
HeroSubtext = season.HeroSubtext,
|
||||||
|
UrgencyBadge = badge,
|
||||||
|
FocusService = season.FocusService,
|
||||||
|
RelatedCategorySlug = season.RelatedCategorySlug,
|
||||||
|
CtaText = season.CtaText,
|
||||||
|
DaysUntilDeadline = ddays,
|
||||||
|
Deadline = deadline
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void JumpToSeason(TaxSeason season)
|
||||||
|
{
|
||||||
|
simulationDate = new DateTime(DateTime.Today.Year, season.StartMonth, season.StartDay);
|
||||||
|
ComputeSeason();
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user