feat: migrate ERP configuration from .env to per-user database storage

- Moved ERP credentials (URL, username, password) from environment variables to dbo_BIPUsers table
- Each user now has their own ERP configuration stored in the database
- Added UserErpConfigService for managing per-user ERP settings
- Updated cleaner and extractor handlers to fetch ERP config from database instead of .env
- Removed ERP fields from ConfigManager UI editable fields
- Added new IPC handlers and preload APIs for user ERP config management
- Includes migration script to transfer existing .env ERP settings to database
- Added migration guide documentation

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Misaka
2026-03-05 21:52:54 +08:00
parent 3d2127b660
commit 5977254180
15 changed files with 1654 additions and 53 deletions

View File

@@ -235,6 +235,39 @@ export interface MaterialTypeAPI {
}>
}
/**
* User ERP Configuration API
*/
export interface UserErpConfigAPI {
/**
* Get current user's ERP configuration
*/
getCurrent: () => Promise<{
success: boolean
config?: { url: string; username: string; password: string }
error?: string
}>
/**
* Update current user's ERP configuration
*/
update: (config: { url: string; username: string; password: string }) => Promise<{
success: boolean
config?: { url: string; username: string; password: string }
error?: string
}>
/**
* Test ERP connection with provided credentials
*/
testConnection: (config: { url: string; username: string; password: string }) => Promise<{
success: boolean
message?: string
}>
/**
* Get all users' ERP configurations (admin only)
*/
getAll: () => Promise<Array<{ username: string; erpUrl: string; erpUsername: string }>>
}
declare global {
interface Window {
electron: {
@@ -263,6 +296,7 @@ declare global {
materials: MaterialsAPI
settings: SettingsAPI
materialType: MaterialTypeAPI
userErpConfig: UserErpConfigAPI
}
api: unknown
}

View File

@@ -137,6 +137,16 @@ const api = {
ipcRenderer.invoke('materialType:delete', { materialName, managerName }),
upsertBatch: (request: MaterialTypeBatchRequest) =>
ipcRenderer.invoke('materialType:upsertBatch', request)
},
// User ERP Configuration service
userErpConfig: {
getCurrent: () => ipcRenderer.invoke('user-erp-config:getCurrent'),
update: (config: { url: string; username: string; password: string }) =>
ipcRenderer.invoke('user-erp-config:update', config),
testConnection: (config: { url: string; username: string; password: string }) =>
ipcRenderer.invoke('user-erp-config:testConnection', config),
getAll: () => ipcRenderer.invoke('user-erp-config:getAll')
}
} as const