refactor: organize source web and tests by business module

This commit is contained in:
abaishu0730 committed 2026-10-19 08:45:51 +08:00
1 parent 9854d2d5c2
commit 2aed328774
113 files changed
+189 -183

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
// This router is called only after dashboard authentication and same-origin validation.
function workspaceApi({workspace,store,user,route,method,body,reply,bpmSessions}){
if(!workspace)return false;
const members=()=>store.users();
if(route==='/api/workspace' && method==='GET'){const snapshot=workspace.snapshot(members());snapshot.capabilities.remoteLogin=Boolean(bpmSessions);reply(200,snapshot);return true;}
if(method!=='POST')return false;
if(route==='/api/calendar'){reply(200,workspace.saveCalendar(body,user));return true;}
if(route==='/api/exceptions'){reply(201,workspace.createException(body,user,members()));return true;}
const action=/^\/api\/exceptions\/([\w-]+)\/action$/.exec(route);if(action){reply(200,workspace.actOnException(action[1],body,user,members()));return true;}
if(route==='/api/connections'){reply(201,workspace.createConnection(body,user,members()));return true;}
const disable=/^\/api\/connections\/([\w-]+)\/disable$/.exec(route);if(disable){if(Object.keys(body).length)throw Object.assign(new Error('停用连接不接受额外数据。'),{status:400});reply(200,workspace.disableConnection(disable[1],user));return true;}
if(route==='/api/supervisor'){reply(200,workspace.saveSupervisor(body,user,members()));return true;}
return false;
}
module.exports={workspaceApi};