feat: ga-core + ga-api + ga-batch + V13-V15 + Docker + frontend skeleton
ga-core (22 tables): - user/role: VO + Mapper + XML (login + RBAC) - org: Grade, Organization (CTE recursive tree), Agent + history - product: InsuranceCompany, Product, Contract - rule: CommissionRate, PayoutRule, OverrideRule, ChargebackRule, ExceptionTypeCode - receive: CompanyProfile, FieldMapping, CodeMapping, RawCommissionData, ParseError - ledger: Recruit, Maintain, Exception (batch insert + cursor) - settle: SettleMaster (UPSERT), Override, Chargeback, Payment, Reconciliation, BatchJobLog - All XMLs use EncryptTypeHandler for PII fields ga-api: - AuthController: login (lock on N fails), refresh, me, password, logout - Domain controllers: Agent, Organization, Contract, Company, Product, Rule, Receive, Ledger (recruit/maintain/exception + approve), Settle (confirm/hold/release), Payment, User, Role (matrix), BatchTrigger - All use @RequirePermission + @DataChangeLog ga-batch: - MonthlySettlementJob: 8 Steps (receiveData, transformData, reconcile, calcRecruit, calcMaintain, chargebackException, calcOverride, aggregate) - DataReceiver strategy + ManualReceiver, MappingEngine stub - CommissionCalculator (pct/tax via MoneyUtil), JobLauncherController DB V13~V15: - V13: 14 indexes (settle_master, ledgers, contract, chargeback, payment, raw, logs) - V14: create_monthly_partition() helper function - V15: v_agent_monthly_summary, v_org_settle_summary, v_chargeback_risk views Infra: - docker-compose: postgres + redis + api + batch + frontend - Multi-stage Dockerfile (gradle build → JRE) ga-frontend (skeleton): - Vite + React 18 + TypeScript + AntD 5 + AG Grid + React Query + Zustand - API request layer (axios + JWT), LoginPage, MainLayout (dynamic menu), Dashboard - nginx.conf for /api proxying
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
# Stage 1: build
|
||||
FROM node:20-alpine AS builder
|
||||
WORKDIR /work
|
||||
COPY package.json ./
|
||||
RUN npm install --no-package-lock
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: nginx
|
||||
FROM nginx:alpine
|
||||
COPY --from=builder /work/dist /usr/share/nginx/html
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
EXPOSE 80
|
||||
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>GA 수수료 정산 솔루션</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,17 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://api:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "ga-frontend",
|
||||
"private": true,
|
||||
"version": "1.0.0-alpha",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"preview": "vite preview",
|
||||
"lint": "eslint src --ext ts,tsx"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ag-grid-community/client-side-row-model": "^31.3.2",
|
||||
"@ag-grid-community/core": "^31.3.2",
|
||||
"@ag-grid-community/react": "^31.3.2",
|
||||
"@ag-grid-community/styles": "^31.3.2",
|
||||
"@tanstack/react-query": "^5.40.0",
|
||||
"antd": "^5.18.0",
|
||||
"axios": "^1.7.2",
|
||||
"dayjs": "^1.11.11",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-router-dom": "^6.23.1",
|
||||
"recharts": "^2.12.7",
|
||||
"zustand": "^4.5.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.3.3",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@vitejs/plugin-react": "^4.3.0",
|
||||
"typescript": "^5.4.5",
|
||||
"vite": "^5.2.11"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Routes, Route, Navigate } from 'react-router-dom';
|
||||
import LoginPage from '@/pages/LoginPage';
|
||||
import MainLayout from '@/layouts/MainLayout';
|
||||
import Dashboard from '@/pages/Dashboard';
|
||||
|
||||
function RequireAuth({ children }: { children: React.ReactNode }) {
|
||||
const token = localStorage.getItem('accessToken');
|
||||
return token ? <>{children}</> : <Navigate to="/login" replace />;
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<Routes>
|
||||
<Route path="/login" element={<LoginPage />} />
|
||||
<Route path="/" element={<RequireAuth><MainLayout /></RequireAuth>}>
|
||||
<Route index element={<Dashboard />} />
|
||||
{/* TODO: 추가 페이지는 동적 라우팅으로 확장 */}
|
||||
</Route>
|
||||
</Routes>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import api, { unwrap } from './request';
|
||||
|
||||
export interface LoginReq {
|
||||
loginId: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
export interface LoginResp {
|
||||
accessToken: string;
|
||||
refreshToken?: string;
|
||||
accessTokenExpiresIn: number;
|
||||
userId: number;
|
||||
loginId: string;
|
||||
userName: string;
|
||||
roles: string[];
|
||||
}
|
||||
|
||||
export interface UserResp {
|
||||
userId: number;
|
||||
loginId: string;
|
||||
userName: string;
|
||||
email?: string;
|
||||
phone?: string;
|
||||
agentId?: number;
|
||||
agentName?: string;
|
||||
orgName?: string;
|
||||
status: string;
|
||||
roleCodes?: string[];
|
||||
}
|
||||
|
||||
export const authApi = {
|
||||
login: (req: LoginReq) => unwrap<LoginResp>(api.post('/api/auth/login', req)),
|
||||
refresh: (refreshToken: string) =>
|
||||
unwrap<LoginResp>(api.post('/api/auth/refresh', { refreshToken })),
|
||||
me: () => unwrap<UserResp>(api.get('/api/auth/me')),
|
||||
logout: () => unwrap<void>(api.post('/api/auth/logout')),
|
||||
changePassword: (oldPassword: string, newPassword: string) =>
|
||||
unwrap<void>(api.post('/api/auth/password', { oldPassword, newPassword })),
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
import api, { unwrap } from './request';
|
||||
|
||||
export interface MenuResp {
|
||||
menuId: number;
|
||||
parentMenuId?: number;
|
||||
menuCode: string;
|
||||
menuName: string;
|
||||
menuType: 'DIRECTORY' | 'PAGE' | 'LINK';
|
||||
menuPath?: string;
|
||||
menuIcon?: string;
|
||||
componentPath?: string;
|
||||
menuLevel: number;
|
||||
sortOrder: number;
|
||||
permissions: string[];
|
||||
children: MenuResp[];
|
||||
}
|
||||
|
||||
export const menuApi = {
|
||||
myMenus: () => unwrap<MenuResp[]>(api.get('/api/menus/my')),
|
||||
tree: () => unwrap<MenuResp[]>(api.get('/api/menus/tree')),
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
import axios, { AxiosError } from 'axios';
|
||||
import { message } from 'antd';
|
||||
|
||||
export interface ApiResponse<T> {
|
||||
success: boolean;
|
||||
code: string;
|
||||
message: string;
|
||||
data: T;
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
export interface PageResponse<T> {
|
||||
list: T[];
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
total: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: import.meta.env.VITE_API_URL ?? '',
|
||||
timeout: 60_000,
|
||||
});
|
||||
|
||||
api.interceptors.request.use((config) => {
|
||||
const token = localStorage.getItem('accessToken');
|
||||
if (token) config.headers.Authorization = `Bearer ${token}`;
|
||||
return config;
|
||||
});
|
||||
|
||||
api.interceptors.response.use(
|
||||
(res) => {
|
||||
const body = res.data;
|
||||
if (body && typeof body === 'object' && 'success' in body && body.success === false) {
|
||||
message.error(body.message ?? '오류가 발생했습니다');
|
||||
return Promise.reject(body);
|
||||
}
|
||||
return res;
|
||||
},
|
||||
(err: AxiosError<ApiResponse<unknown>>) => {
|
||||
const status = err.response?.status;
|
||||
const body = err.response?.data;
|
||||
if (status === 401) {
|
||||
localStorage.removeItem('accessToken');
|
||||
window.location.href = '/login';
|
||||
} else if (status === 403) {
|
||||
message.error(body?.message ?? '권한이 없습니다');
|
||||
} else {
|
||||
message.error(body?.message ?? err.message ?? '서버 오류');
|
||||
}
|
||||
return Promise.reject(err);
|
||||
},
|
||||
);
|
||||
|
||||
export default api;
|
||||
|
||||
/** ApiResponse<T> 의 data 만 풀어서 반환 */
|
||||
export async function unwrap<T>(p: Promise<{ data: ApiResponse<T> }>): Promise<T> {
|
||||
const res = await p;
|
||||
return res.data.data;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
html, body, #root { height: 100%; margin: 0; padding: 0; }
|
||||
body {
|
||||
font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", sans-serif;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import { Layout, Menu, Dropdown, Badge, Space, Avatar, Button } from 'antd';
|
||||
import { useNavigate, Outlet } from 'react-router-dom';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { BellOutlined, UserOutlined, LogoutOutlined } from '@ant-design/icons';
|
||||
import { menuApi, MenuResp } from '@/api/menu';
|
||||
import { authApi } from '@/api/auth';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
|
||||
const { Header, Sider, Content } = Layout;
|
||||
|
||||
function toMenuItems(menus: MenuResp[]): any[] {
|
||||
return menus.map((m) => ({
|
||||
key: m.menuPath ?? m.menuCode,
|
||||
label: m.menuName,
|
||||
children: m.children?.length ? toMenuItems(m.children) : undefined,
|
||||
}));
|
||||
}
|
||||
|
||||
export default function MainLayout() {
|
||||
const navigate = useNavigate();
|
||||
const auth = useAuthStore();
|
||||
|
||||
const { data: menus = [] } = useQuery({
|
||||
queryKey: ['menu', 'my'],
|
||||
queryFn: menuApi.myMenus,
|
||||
});
|
||||
|
||||
const handleLogout = async () => {
|
||||
try { await authApi.logout(); } catch { /* ignore */ }
|
||||
localStorage.removeItem('accessToken');
|
||||
localStorage.removeItem('refreshToken');
|
||||
auth.clear();
|
||||
navigate('/login');
|
||||
};
|
||||
|
||||
return (
|
||||
<Layout style={{ minHeight: '100vh' }}>
|
||||
<Header style={{ display: 'flex', justifyContent: 'space-between',
|
||||
background: '#001529', color: '#fff' }}>
|
||||
<div style={{ fontSize: 18, fontWeight: 600 }}>GA 수수료 정산 솔루션</div>
|
||||
<Space>
|
||||
<Badge count={0}>
|
||||
<Button type="text" icon={<BellOutlined style={{ color: '#fff' }} />} />
|
||||
</Badge>
|
||||
<Dropdown menu={{
|
||||
items: [
|
||||
{ key: 'logout', label: '로그아웃', icon: <LogoutOutlined />, onClick: handleLogout },
|
||||
],
|
||||
}}>
|
||||
<Space style={{ color: '#fff', cursor: 'pointer' }}>
|
||||
<Avatar size="small" icon={<UserOutlined />} />
|
||||
{auth.userName ?? auth.loginId}
|
||||
</Space>
|
||||
</Dropdown>
|
||||
</Space>
|
||||
</Header>
|
||||
<Layout>
|
||||
<Sider width={240} theme="light">
|
||||
<Menu
|
||||
mode="inline"
|
||||
items={toMenuItems(menus)}
|
||||
onClick={({ key }) => navigate(String(key))}
|
||||
style={{ borderRight: 0, height: '100%' }}
|
||||
/>
|
||||
</Sider>
|
||||
<Content style={{ padding: 24 }}>
|
||||
<Outlet />
|
||||
</Content>
|
||||
</Layout>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import { ConfigProvider } from 'antd';
|
||||
import koKR from 'antd/locale/ko_KR';
|
||||
import 'dayjs/locale/ko';
|
||||
import App from './App';
|
||||
import './index.css';
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: { queries: { retry: 1, staleTime: 30_000 } },
|
||||
});
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||
<React.StrictMode>
|
||||
<ConfigProvider locale={koKR}>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
</QueryClientProvider>
|
||||
</ConfigProvider>
|
||||
</React.StrictMode>,
|
||||
);
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Card, Col, Row, Statistic, Typography } from 'antd';
|
||||
|
||||
const { Title } = Typography;
|
||||
|
||||
export default function Dashboard() {
|
||||
return (
|
||||
<>
|
||||
<Title level={3}>대시보드</Title>
|
||||
<Row gutter={16}>
|
||||
<Col span={6}>
|
||||
<Card><Statistic title="이번 달 정산 건수" value={0} suffix="건" /></Card>
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<Card><Statistic title="확정 대기" value={0} suffix="건" /></Card>
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<Card><Statistic title="지급 완료" value={0} suffix="건" /></Card>
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<Card><Statistic title="대사 차이" value={0} suffix="건" valueStyle={{ color: '#cf1322' }} /></Card>
|
||||
</Col>
|
||||
</Row>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { Button, Card, Form, Input, message } from 'antd';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { authApi } from '@/api/auth';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
|
||||
export default function LoginPage() {
|
||||
const navigate = useNavigate();
|
||||
const setAuth = useAuthStore((s) => s.setAuth);
|
||||
|
||||
const onFinish = async (values: { loginId: string; password: string }) => {
|
||||
try {
|
||||
const resp = await authApi.login(values);
|
||||
localStorage.setItem('accessToken', resp.accessToken);
|
||||
if (resp.refreshToken) localStorage.setItem('refreshToken', resp.refreshToken);
|
||||
setAuth({
|
||||
userId: resp.userId, loginId: resp.loginId,
|
||||
userName: resp.userName, roles: resp.roles,
|
||||
});
|
||||
message.success(`${resp.userName}님 환영합니다`);
|
||||
navigate('/');
|
||||
} catch {
|
||||
// 인터셉터에서 메시지 처리
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center',
|
||||
minHeight: '100vh' }}>
|
||||
<Card title="GA 수수료 정산 솔루션" style={{ width: 400 }}>
|
||||
<Form layout="vertical" onFinish={onFinish}>
|
||||
<Form.Item label="아이디" name="loginId" rules={[{ required: true }]}>
|
||||
<Input autoFocus />
|
||||
</Form.Item>
|
||||
<Form.Item label="비밀번호" name="password" rules={[{ required: true }]}>
|
||||
<Input.Password />
|
||||
</Form.Item>
|
||||
<Button type="primary" htmlType="submit" block>로그인</Button>
|
||||
</Form>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { create } from 'zustand';
|
||||
import { persist } from 'zustand/middleware';
|
||||
|
||||
interface AuthState {
|
||||
userId?: number;
|
||||
loginId?: string;
|
||||
userName?: string;
|
||||
roles: string[];
|
||||
setAuth: (data: { userId: number; loginId: string; userName: string; roles: string[] }) => void;
|
||||
clear: () => void;
|
||||
}
|
||||
|
||||
export const useAuthStore = create<AuthState>()(
|
||||
persist(
|
||||
(set) => ({
|
||||
roles: [],
|
||||
setAuth: (d) => set({ ...d }),
|
||||
clear: () => set({ userId: undefined, loginId: undefined, userName: undefined, roles: [] }),
|
||||
}),
|
||||
{ name: 'ga-auth' },
|
||||
),
|
||||
);
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
"strict": true,
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"esModuleInterop": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
server: {
|
||||
port: 3000,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:8080',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
sourcemap: false,
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user