feat(cleaner-history): add search IPC handler
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,9 @@ import type {
|
|||||||
CleanerExecutionRecord,
|
CleanerExecutionRecord,
|
||||||
CleanerOrderRecord,
|
CleanerOrderRecord,
|
||||||
CleanerMaterialRecord,
|
CleanerMaterialRecord,
|
||||||
GetCleanerBatchesOptions
|
GetCleanerBatchesOptions,
|
||||||
|
SearchCleanerHistoryOptions,
|
||||||
|
CleanerHistorySearchResult
|
||||||
} from '../types/cleaner-history.types'
|
} from '../types/cleaner-history.types'
|
||||||
|
|
||||||
const log = createLogger('CleanerHistoryHandler')
|
const log = createLogger('CleanerHistoryHandler')
|
||||||
@@ -152,5 +154,42 @@ export function registerCleanerHistoryHandlers(): void {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search across all history levels (batches, orders, materials)
|
||||||
|
* Admin users search all records, regular users search only their own
|
||||||
|
*/
|
||||||
|
ipcMain.handle(
|
||||||
|
IPC_CHANNELS.CLEANER_HISTORY_SEARCH,
|
||||||
|
async (
|
||||||
|
_event,
|
||||||
|
options: SearchCleanerHistoryOptions
|
||||||
|
): Promise<IpcResult<CleanerHistorySearchResult>> => {
|
||||||
|
return withErrorHandling(async () => {
|
||||||
|
const currentUser = SessionManager.getInstance().getUserInfo()
|
||||||
|
|
||||||
|
if (!currentUser) {
|
||||||
|
throw new Error('用户未登录')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!options.query || options.query.trim().length === 0) {
|
||||||
|
return { batches: [], totalMatches: 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
const userId = currentUser.userType === 'Admin' ? undefined : currentUser.id
|
||||||
|
|
||||||
|
log.info('Searching cleaner history', {
|
||||||
|
userId: currentUser.id,
|
||||||
|
userType: currentUser.userType,
|
||||||
|
query: options.query
|
||||||
|
})
|
||||||
|
|
||||||
|
return await dao.searchBatches(userId, {
|
||||||
|
...options,
|
||||||
|
query: options.query.trim()
|
||||||
|
})
|
||||||
|
}, 'cleanerHistory:search')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
log.info('Cleaner history IPC handlers registered')
|
log.info('Cleaner history IPC handlers registered')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user