사주 결과 강화
This commit is contained in:
@@ -22,19 +22,55 @@ interface PageProps {
|
||||
}>;
|
||||
}
|
||||
|
||||
// Python 사주 엔진 호출 (실패 시 null 반환)
|
||||
async function fetchFromPythonEngine(
|
||||
year: number, month: number, day: number,
|
||||
hour: number | null, gender: string
|
||||
): Promise<{
|
||||
saju: any; daeunList: any[]; currentDaeun: any;
|
||||
interactions: any[]; shinsal: any[]; gongmang: any; hiddenStems: any[];
|
||||
} | null> {
|
||||
const url = process.env.SAJU_ENGINE_URL;
|
||||
const secret = process.env.SAJU_ENGINE_SECRET;
|
||||
if (!url) return null;
|
||||
|
||||
try {
|
||||
const res = await fetch(`${url}/saju/calculate`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...(secret ? { 'X-API-Secret': secret } : {}),
|
||||
},
|
||||
body: JSON.stringify({ year, month, day, hour: hour ?? undefined, gender, calendar_type: 'solar' }),
|
||||
signal: AbortSignal.timeout(10000),
|
||||
cache: 'no-store',
|
||||
});
|
||||
if (!res.ok) return null;
|
||||
const data = await res.json();
|
||||
return {
|
||||
saju: data.saju,
|
||||
daeunList: data.daeunList,
|
||||
currentDaeun: data.currentDaeun,
|
||||
interactions: data.interactions,
|
||||
shinsal: data.shinsal,
|
||||
gongmang: data.gongmang,
|
||||
hiddenStems: data.hiddenStems,
|
||||
};
|
||||
} catch {
|
||||
console.warn('[사주] Python 엔진 연결 실패 — TypeScript 폴백 사용');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
const params = await searchParams;
|
||||
const {
|
||||
year, month, day, hour, gender, calendarType,
|
||||
originalYear, originalMonth, originalDay, isLeapMonth
|
||||
} = params;
|
||||
const { year, month, day, hour, gender, calendarType, originalYear, originalMonth, originalDay, isLeapMonth } = params;
|
||||
|
||||
const yearNum = parseInt(year, 10);
|
||||
const monthNum = parseInt(month, 10);
|
||||
const dayNum = parseInt(day, 10);
|
||||
const hourNum = hour ? parseInt(hour, 10) : null;
|
||||
|
||||
// 필수 파라미터 누락 시 안전한 기본값 (NaN 방지)
|
||||
if (isNaN(yearNum) || isNaN(monthNum) || isNaN(dayNum)) {
|
||||
return (
|
||||
<div className="min-h-full bg-[#f0f5ff] flex items-center justify-center">
|
||||
@@ -52,9 +88,35 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
const isLunar = calendarType === 'lunar';
|
||||
const isLeap = isLeapMonth === 'true';
|
||||
|
||||
const sajuData = calculateSaju(yearNum, monthNum, dayNum, hourNum, gender);
|
||||
// ── Python 엔진 호출 (폴백: TypeScript) ──────────────────────────────
|
||||
const engineResult = await fetchFromPythonEngine(yearNum, monthNum, dayNum, hourNum, gender);
|
||||
|
||||
// 결제 여부 + 저장된 AI 해석 확인 (서버사이드)
|
||||
// 사주팔자 (Python 엔진 우선, TS 폴백)
|
||||
const sajuData = engineResult?.saju ?? calculateSaju(yearNum, monthNum, dayNum, hourNum, gender);
|
||||
|
||||
// 추가 분석 (신강신약, 용신, 오행균형, 세운) — TypeScript 계산 유지
|
||||
const analysis = performFullAnalysis(sajuData);
|
||||
const elementScores = analysis.elementScores;
|
||||
|
||||
// 대운 (Python 엔진 우선, TS 폴백)
|
||||
const currentYear = new Date().getFullYear();
|
||||
const daeunList = engineResult?.daeunList ?? calculateDaeun(
|
||||
yearNum, monthNum, dayNum, gender,
|
||||
sajuData.month.stem, sajuData.month.branch
|
||||
);
|
||||
const currentDaeun = engineResult?.currentDaeun ?? getCurrentDaeun(daeunList, currentYear);
|
||||
|
||||
// 지지 상호작용 / 신살 / 공망 / 지장간 (Python 엔진 우선, TS 폴백)
|
||||
const branchInteractions = engineResult?.interactions ?? analysis.branchInteractions;
|
||||
const shinsal = engineResult?.shinsal ?? analysis.shinsal;
|
||||
const gongmang = engineResult?.gongmang ?? analysis.gongmang;
|
||||
const hiddenStems = engineResult?.hiddenStems ?? analysis.hiddenStems;
|
||||
|
||||
// ── 절기 정보 (표시용) ────────────────────────────────────────────────
|
||||
const solarTermIndex = getCurrentSolarTerm(yearNum, monthNum, dayNum);
|
||||
const solarTermName = getSolarTermName(solarTermIndex);
|
||||
|
||||
// ── 결제 여부 + 저장된 AI 해석 ────────────────────────────────────────
|
||||
let hasPaid = false;
|
||||
let savedInterpretation: string | null = null;
|
||||
try {
|
||||
@@ -62,11 +124,8 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
const { data: { user } } = await supabase.auth.getUser();
|
||||
if (user) {
|
||||
const { data: order } = await supabase
|
||||
.from('orders')
|
||||
.select('id')
|
||||
.eq('user_id', user.id)
|
||||
.eq('product_id', 'saju_detail')
|
||||
.eq('status', 'paid')
|
||||
.from('orders').select('id')
|
||||
.eq('user_id', user.id).eq('product_id', 'saju_detail').eq('status', 'paid')
|
||||
.maybeSingle();
|
||||
hasPaid = !!order;
|
||||
|
||||
@@ -74,52 +133,35 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
const birthKey: Record<string, unknown> = { birth_year: yearNum, birth_month: monthNum, birth_day: dayNum, gender };
|
||||
if (hourNum !== null) birthKey.birth_hour = hourNum;
|
||||
const { data: record } = await supabase
|
||||
.from('saju_records')
|
||||
.select('interpretation')
|
||||
.eq('user_id', user.id)
|
||||
.eq('is_paid', true)
|
||||
.contains('saju_data', birthKey)
|
||||
.maybeSingle();
|
||||
.from('saju_records').select('interpretation')
|
||||
.eq('user_id', user.id).eq('is_paid', true)
|
||||
.contains('saju_data', birthKey).maybeSingle();
|
||||
savedInterpretation = record?.interpretation ?? null;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// 인증 오류 시 무시 (미로그인)
|
||||
// 미로그인 시 무시
|
||||
}
|
||||
|
||||
// 절기 정보
|
||||
const solarTermIndex = getCurrentSolarTerm(yearNum, monthNum, dayNum);
|
||||
const solarTermName = getSolarTermName(solarTermIndex);
|
||||
const monthBranchIndex = getSolarTermMonthBranch(yearNum, monthNum, dayNum);
|
||||
const monthBranchName = EARTHLY_BRANCHES_KR[monthBranchIndex];
|
||||
|
||||
// 종합 분석 수행
|
||||
const analysis = performFullAnalysis(sajuData);
|
||||
const elementScores = analysis.elementScores;
|
||||
|
||||
// 대운 계산
|
||||
const daeunList = calculateDaeun(
|
||||
yearNum, monthNum, dayNum, gender,
|
||||
sajuData.month.stem, sajuData.month.branch
|
||||
);
|
||||
const currentYear = new Date().getFullYear();
|
||||
const currentDaeun = getCurrentDaeun(daeunList, currentYear);
|
||||
|
||||
// 오행 색상 매핑
|
||||
const elementColors: { [key: string]: string } = {
|
||||
// ── 오행 색상 ──────────────────────────────────────────────────────────
|
||||
const elementColors: { [k: string]: string } = {
|
||||
'木': 'text-green-700', '火': 'text-red-600', '土': 'text-yellow-700',
|
||||
'金': 'text-amber-600', '水': 'text-blue-700',
|
||||
};
|
||||
const elementBgColors: { [key: string]: string } = {
|
||||
const elementBgColors: { [k: string]: string } = {
|
||||
'木': 'bg-green-50 border-green-400', '火': 'bg-red-50 border-red-400',
|
||||
'土': 'bg-yellow-50 border-yellow-400', '金': 'bg-amber-50 border-amber-400',
|
||||
'水': 'bg-blue-50 border-blue-400',
|
||||
};
|
||||
|
||||
// 띠 계산
|
||||
// ── 띠 계산 ────────────────────────────────────────────────────────────
|
||||
const zodiacAnimals = ['쥐', '소', '호랑이', '토끼', '용', '뱀', '말', '양', '원숭이', '닭', '개', '돼지'];
|
||||
const zodiacIndex = (yearNum - 4) % 12;
|
||||
const zodiacAnimal = zodiacAnimals[zodiacIndex >= 0 ? zodiacIndex : zodiacIndex + 12];
|
||||
const zodiacIdx = (yearNum - 4) % 12;
|
||||
const zodiacAnimal = zodiacAnimals[zodiacIdx >= 0 ? zodiacIdx : zodiacIdx + 12];
|
||||
|
||||
const engineBadge = engineResult
|
||||
? <span className="text-[10px] bg-emerald-50 border border-emerald-200 text-emerald-700 px-2 py-0.5 rounded-full font-semibold">Python 엔진</span>
|
||||
: <span className="text-[10px] bg-slate-100 border border-slate-200 text-slate-500 px-2 py-0.5 rounded-full">TS 폴백</span>;
|
||||
|
||||
return (
|
||||
<div className="min-h-full bg-[#f0f5ff]">
|
||||
@@ -138,12 +180,10 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
<div className="px-6 py-8 max-w-4xl mx-auto">
|
||||
<div className="grid lg:grid-cols-[280px_1fr] gap-6">
|
||||
|
||||
{/* 사이드바 - 기본 정보 */}
|
||||
{/* 사이드바 */}
|
||||
<aside className="lg:sticky lg:top-6 h-fit">
|
||||
<div className="bg-[#04102b] rounded-2xl p-6 text-white">
|
||||
<h2 className="text-base font-bold mb-5 text-center pb-4 border-b border-white/10">
|
||||
기본 정보
|
||||
</h2>
|
||||
<h2 className="text-base font-bold mb-5 text-center pb-4 border-b border-white/10">기본 정보</h2>
|
||||
<div className="space-y-4 text-sm">
|
||||
<div>
|
||||
<div className="text-blue-300/60 mb-1">생년월일</div>
|
||||
@@ -172,6 +212,10 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
<div className="text-blue-300/60 mb-1">띠</div>
|
||||
<div className="font-bold">{zodiacAnimal}띠</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-blue-300/60 mb-1">태어난 절기</div>
|
||||
<div className="font-bold text-amber-300">{solarTermName} 이후</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-blue-300/60 mb-1">일간</div>
|
||||
<div className="font-bold text-2xl text-amber-400">
|
||||
@@ -181,26 +225,26 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
{FIVE_ELEMENTS_KR[sajuData.day.element as keyof typeof FIVE_ELEMENTS_KR]}({sajuData.day.element})
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="text-blue-300/60 text-xs">계산 엔진</div>
|
||||
{engineBadge}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-5 pt-5 border-t border-white/10 space-y-2">
|
||||
<Link
|
||||
href="/saju/input"
|
||||
className="block w-full text-center bg-white/10 hover:bg-white/20 text-white px-4 py-2 rounded-lg transition text-sm font-medium"
|
||||
>
|
||||
<Link href="/saju/input"
|
||||
className="block w-full text-center bg-white/10 hover:bg-white/20 text-white px-4 py-2 rounded-lg transition text-sm font-medium">
|
||||
다시 입력하기
|
||||
</Link>
|
||||
<Link
|
||||
href="/saju"
|
||||
className="block w-full text-center bg-violet-500/20 hover:bg-violet-500/30 text-violet-300 px-4 py-2 rounded-lg transition text-sm font-medium"
|
||||
>
|
||||
<Link href="/saju"
|
||||
className="block w-full text-center bg-violet-500/20 hover:bg-violet-500/30 text-violet-300 px-4 py-2 rounded-lg transition text-sm font-medium">
|
||||
서비스 소개
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
{/* 메인 콘텐츠 */}
|
||||
{/* 메인 */}
|
||||
<main className="space-y-6">
|
||||
|
||||
{/* 사주팔자 표 */}
|
||||
@@ -273,26 +317,27 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
<div className="text-[10px] text-slate-400 font-normal">숨은 천간</div>
|
||||
</td>
|
||||
{(() => {
|
||||
const pillars = sajuData.hour
|
||||
? [analysis.hiddenStems.find(h => h.pillar === '시주'), analysis.hiddenStems.find(h => h.pillar === '일주'), analysis.hiddenStems.find(h => h.pillar === '월주'), analysis.hiddenStems.find(h => h.pillar === '년주')]
|
||||
: [analysis.hiddenStems.find(h => h.pillar === '일주'), analysis.hiddenStems.find(h => h.pillar === '월주'), analysis.hiddenStems.find(h => h.pillar === '년주')];
|
||||
return pillars.map((h, idx) => (
|
||||
<td key={idx} className={`py-2 px-2 text-center ${h?.pillar === '일주' ? 'bg-amber-50' : ''}`}>
|
||||
{h && (
|
||||
<div className="flex flex-wrap justify-center gap-1">
|
||||
{h.stems.map((s, si) => (
|
||||
<span
|
||||
key={si}
|
||||
className={`inline-block px-1.5 py-0.5 rounded text-xs font-semibold border ${elementBgColors[s.element] || 'bg-gray-100'}`}
|
||||
title={s.role}
|
||||
>
|
||||
{s.stemKr}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
));
|
||||
const order = sajuData.hour
|
||||
? ['시주', '일주', '월주', '년주']
|
||||
: ['일주', '월주', '년주'];
|
||||
return order.map((pillarName, idx) => {
|
||||
const h = hiddenStems.find((hs: any) => hs.pillar === pillarName);
|
||||
return (
|
||||
<td key={idx} className={`py-2 px-2 text-center ${pillarName === '일주' ? 'bg-amber-50' : ''}`}>
|
||||
{h && (
|
||||
<div className="flex flex-wrap justify-center gap-1">
|
||||
{h.stems.map((s: any, si: number) => (
|
||||
<span key={si}
|
||||
className={`inline-block px-1.5 py-0.5 rounded text-xs font-semibold border ${elementBgColors[s.element] || 'bg-gray-100'}`}
|
||||
title={s.role}>
|
||||
{s.stemKr}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
);
|
||||
});
|
||||
})()}
|
||||
</tr>
|
||||
|
||||
@@ -338,11 +383,11 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
</div>
|
||||
|
||||
{/* 지지 상호작용 */}
|
||||
{analysis.branchInteractions.length > 0 && (
|
||||
{branchInteractions.length > 0 && (
|
||||
<div className="mt-5 pt-5 border-t border-slate-100">
|
||||
<h3 className="text-sm font-bold text-[#04102b] mb-3 text-center">지지 상호작용</h3>
|
||||
<div className="flex flex-wrap justify-center gap-2">
|
||||
{analysis.branchInteractions.map((inter, idx) => {
|
||||
{branchInteractions.map((inter: any, idx: number) => {
|
||||
const isPositive = inter.type.includes('합');
|
||||
const isNegative = inter.type.includes('충') || inter.type.includes('형');
|
||||
const colorClass = isPositive
|
||||
@@ -351,7 +396,8 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
? 'bg-red-50 border-red-400 text-red-800'
|
||||
: 'bg-amber-50 border-amber-400 text-amber-800';
|
||||
return (
|
||||
<span key={idx} className={`inline-flex items-center px-3 py-1 rounded-full text-xs font-bold border ${colorClass}`}>
|
||||
<span key={idx} className={`inline-flex items-center px-3 py-1 rounded-full text-xs font-bold border ${colorClass}`}
|
||||
title={inter.description}>
|
||||
{inter.type} {inter.branchesKr.join('')}
|
||||
{inter.resultElement && ` → ${FIVE_ELEMENTS_KR[inter.resultElement as keyof typeof FIVE_ELEMENTS_KR]}`}
|
||||
</span>
|
||||
@@ -389,6 +435,7 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
|
||||
{/* 분석 카드 그리드 */}
|
||||
<div className="grid md:grid-cols-2 gap-6">
|
||||
|
||||
{/* 신강/신약 + 용신 */}
|
||||
<div className="bg-white rounded-2xl border border-[#dbe8ff] p-6">
|
||||
<h3 className="text-base font-extrabold text-[#04102b] mb-4">일간 세력 분석</h3>
|
||||
@@ -405,7 +452,7 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
<span className="text-slate-500 text-xs">점수: {analysis.dayMasterStrength.score}</span>
|
||||
</div>
|
||||
<ul className="space-y-1 text-xs text-slate-500 mb-5">
|
||||
{analysis.dayMasterStrength.reasons.map((r, i) => (
|
||||
{analysis.dayMasterStrength.reasons.map((r: string, i: number) => (
|
||||
<li key={i} className="flex items-start">
|
||||
<span className="text-amber-500 mr-1.5">-</span>
|
||||
<span>{r}</span>
|
||||
@@ -433,9 +480,9 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
{/* 신살 + 공망 */}
|
||||
<div className="bg-white rounded-2xl border border-[#dbe8ff] p-6">
|
||||
<h3 className="text-base font-extrabold text-[#04102b] mb-4">신살 (神煞)</h3>
|
||||
{analysis.shinsal.length > 0 ? (
|
||||
{shinsal.length > 0 ? (
|
||||
<div className="space-y-2 mb-5">
|
||||
{analysis.shinsal.map((s, i) => (
|
||||
{shinsal.map((s: any, i: number) => (
|
||||
<div key={i} className="flex items-start gap-2 p-3 rounded-xl bg-[#f0f5ff]">
|
||||
<span className="inline-block px-2 py-0.5 bg-[#04102b] text-white rounded-lg text-xs font-bold whitespace-nowrap">
|
||||
{s.name}
|
||||
@@ -456,13 +503,13 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
<div className="border-t border-slate-100 pt-4">
|
||||
<h4 className="font-bold text-[#04102b] mb-2 text-sm">공망 (空亡)</h4>
|
||||
<div className="flex gap-2 mb-2">
|
||||
{analysis.gongmang.branchesKr.map((bk, i) => (
|
||||
{gongmang.branchesKr.map((bk: string, i: number) => (
|
||||
<span key={i} className="px-2.5 py-1 bg-[#04102b] text-white rounded-lg text-xs font-bold">
|
||||
{bk}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<p className="text-xs text-slate-500 leading-relaxed">{analysis.gongmang.description}</p>
|
||||
<p className="text-xs text-slate-500 leading-relaxed">{gongmang.description}</p>
|
||||
</div>
|
||||
|
||||
{/* 세운 정보 */}
|
||||
@@ -478,7 +525,7 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
</div>
|
||||
{analysis.seun.interactions.length > 0 && (
|
||||
<div className="flex flex-wrap gap-1.5 mt-2">
|
||||
{analysis.seun.interactions.map((si, i) => (
|
||||
{analysis.seun.interactions.map((si: any, i: number) => (
|
||||
<span key={i} className={`text-xs px-2 py-0.5 rounded-full font-semibold ${
|
||||
si.type.includes('합') ? 'bg-emerald-50 text-emerald-700' : 'bg-red-50 text-red-700'
|
||||
}`}>
|
||||
@@ -493,7 +540,10 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
|
||||
{/* AI 상세 해석 섹션 */}
|
||||
{(() => {
|
||||
const birthKey = { birth_year: yearNum, birth_month: monthNum, birth_day: dayNum, gender, ...(hourNum !== null ? { birth_hour: hourNum } : {}) };
|
||||
const birthKey = {
|
||||
birth_year: yearNum, birth_month: monthNum, birth_day: dayNum, gender,
|
||||
...(hourNum !== null ? { birth_hour: hourNum } : {}),
|
||||
};
|
||||
const currentUrl = `/saju/result?year=${yearNum}&month=${monthNum}&day=${dayNum}${hourNum !== null ? `&hour=${hourNum}` : ''}&gender=${gender}&calendarType=${calendarType}${originalYear ? `&originalYear=${originalYear}&originalMonth=${originalMonth}&originalDay=${originalDay}` : ''}${isLeap ? '&isLeapMonth=true' : ''}`;
|
||||
return (
|
||||
<SajuAISection
|
||||
@@ -536,37 +586,21 @@ export default async function SajuResultPage({ searchParams }: PageProps) {
|
||||
)}
|
||||
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-3">
|
||||
{daeunList.map((daeun, index) => {
|
||||
{daeunList.map((daeun: any, index: number) => {
|
||||
const isCurrent = currentDaeun &&
|
||||
daeun.startYear === currentDaeun.startYear &&
|
||||
daeun.endYear === currentDaeun.endYear;
|
||||
|
||||
return (
|
||||
<div
|
||||
key={index}
|
||||
className={`rounded-xl p-3 border-2 transition ${isCurrent
|
||||
? 'bg-amber-50 border-amber-400'
|
||||
: 'bg-white border-[#dbe8ff]'
|
||||
}`}
|
||||
>
|
||||
<div key={index}
|
||||
className={`rounded-xl p-3 border-2 transition ${isCurrent ? 'bg-amber-50 border-amber-400' : 'bg-white border-[#dbe8ff]'}`}>
|
||||
<div className="text-center">
|
||||
<div className="text-xl font-bold text-[#04102b] mb-0.5">
|
||||
{daeun.stem}{daeun.branch}
|
||||
</div>
|
||||
<div className="text-xs text-slate-500 mb-1.5">
|
||||
{daeun.stemKr}{daeun.branchKr}
|
||||
</div>
|
||||
<div className="text-xs text-slate-400">
|
||||
{daeun.age}세 ~ {daeun.age + 9}세
|
||||
</div>
|
||||
<div className="text-xs text-slate-400">
|
||||
{daeun.startYear} ~ {daeun.endYear}
|
||||
</div>
|
||||
<div className="text-xl font-bold text-[#04102b] mb-0.5">{daeun.stem}{daeun.branch}</div>
|
||||
<div className="text-xs text-slate-500 mb-1.5">{daeun.stemKr}{daeun.branchKr}</div>
|
||||
<div className="text-xs text-slate-400">{daeun.age}세 ~ {daeun.age + 9}세</div>
|
||||
<div className="text-xs text-slate-400">{daeun.startYear} ~ {daeun.endYear}</div>
|
||||
{isCurrent && (
|
||||
<div className="mt-1.5">
|
||||
<span className="inline-block bg-[#04102b] text-white text-xs px-2.5 py-0.5 rounded-full font-semibold">
|
||||
현재
|
||||
</span>
|
||||
<span className="inline-block bg-[#04102b] text-white text-xs px-2.5 py-0.5 rounded-full font-semibold">현재</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -154,13 +154,16 @@ async def calculate_saju_api(request: Request, body: SajuRequest):
|
||||
year, month, day = body.year, body.month, body.day
|
||||
if body.calendar_type == 'lunar':
|
||||
try:
|
||||
import korean_lunar_calendar
|
||||
calendar = korean_lunar_calendar.KoreanLunarCalendar()
|
||||
calendar.setLunarDate(year, month, day, False)
|
||||
solar = calendar.SolarIsoFormat().split('-')
|
||||
year, month, day = int(solar[0]), int(solar[1]), int(solar[2])
|
||||
from korean_lunar_calendar import KoreanLunarCalendar
|
||||
cal = KoreanLunarCalendar()
|
||||
cal.setLunarDate(year, month, day, False)
|
||||
solar_str = cal.SolarIsoFormat() # 'YYYY-MM-DD'
|
||||
parts = solar_str.split('-')
|
||||
year, month, day = int(parts[0]), int(parts[1]), int(parts[2])
|
||||
logger.info(f'음력 변환 완료: 음력 {body.year}/{body.month}/{body.day} → 양력 {year}/{month}/{day}')
|
||||
except Exception as e:
|
||||
logger.warning(f'음력 변환 실패, 양력으로 처리: {e}')
|
||||
raise HTTPException(status_code=400, detail=f'음력 변환 실패: {e}')
|
||||
|
||||
# 사주팔자 계산
|
||||
saju = calculate_saju(year, month, day, body.hour, body.gender)
|
||||
|
||||
@@ -4,3 +4,4 @@ ephem==4.1.6
|
||||
slowapi==0.1.9
|
||||
python-dotenv==1.0.1
|
||||
pydantic==2.10.3
|
||||
korean-lunar-calendar==0.3.1
|
||||
|
||||
Reference in New Issue
Block a user