7dd51a1169
TaxBaik CI/CD / build-and-deploy (push) Successful in 48s
Architecture: - Create companies table with company_code as unique identifier - Add company_id foreign key to admin_users for multi-tenant support - Implement backward compatibility with DEFAULT company for existing users Core Components: - Company entity with full CRUD operations - ICompanyRepository interface following Repository pattern - CompanyRepository with Dapper implementation - CompanyService with business logic and validation - CompanyController with REST API endpoints Admin UI: - CompanyForm reusable component (Create/Edit pattern) - CompanyList.razor with pagination and company overview - CompanyCreate.razor for registering new companies - CompanyEdit.razor for managing existing companies with delete - All pages follow admin-page-hero pattern for consistency SOLID Principles: - Single Responsibility: Each component has one reason to change - Open/Closed: Extensible without modifying existing code - Interface Segregation: Clean repository and service contracts - Dependency Inversion: All layers depend on abstractions Database Migration (V014): - Creates companies table with active/inactive status - Assigns existing admin users to DEFAULT company - Provides foundation for role-based access control Future Enhancement: - Admin users can belong to specific companies - Data filtering based on company_id (multi-tenant isolation) - Company-based permission model
31 lines
1.3 KiB
SQL
31 lines
1.3 KiB
SQL
-- Create Companies table for multi-tenant support
|
|
CREATE TABLE IF NOT EXISTS companies (
|
|
id SERIAL PRIMARY KEY,
|
|
company_code VARCHAR(50) NOT NULL UNIQUE,
|
|
company_name VARCHAR(200) NOT NULL,
|
|
contact_person VARCHAR(100),
|
|
phone VARCHAR(20),
|
|
email VARCHAR(200),
|
|
memo TEXT,
|
|
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
);
|
|
|
|
-- Add company_id to admin_users (nullable for backward compatibility)
|
|
ALTER TABLE admin_users ADD COLUMN IF NOT EXISTS company_id INT REFERENCES companies(id) ON DELETE RESTRICT;
|
|
|
|
-- Create index for company lookups
|
|
CREATE INDEX IF NOT EXISTS idx_companies_code ON companies(company_code);
|
|
CREATE INDEX IF NOT EXISTS idx_admin_users_company ON admin_users(company_id);
|
|
|
|
-- Insert default company for existing admin users
|
|
INSERT INTO companies (company_code, company_name, is_active)
|
|
VALUES ('DEFAULT', '기본 회사', TRUE)
|
|
ON CONFLICT (company_code) DO NOTHING;
|
|
|
|
-- Assign existing admin users to default company if not assigned
|
|
UPDATE admin_users
|
|
SET company_id = (SELECT id FROM companies WHERE company_code = 'DEFAULT')
|
|
WHERE company_id IS NULL;
|