feat(t226): add Go ERP session login
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
"cmroubao/backend-api/internal/platform/erpconnector"
|
||||
"cmroubao/backend-api/internal/platform/migration"
|
||||
"cmroubao/backend-api/internal/platform/password"
|
||||
"cmroubao/backend-api/internal/platform/shunyunbao"
|
||||
repository "cmroubao/backend-api/internal/repository/sqlite"
|
||||
"cmroubao/backend-api/internal/transport/authcommon"
|
||||
"cmroubao/backend-api/internal/transport/httpapi"
|
||||
@@ -230,6 +231,15 @@ func buildRouter(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
erpSession, err := shunyunbao.NewSessionManager(shunyunbao.SessionConfig{
|
||||
BaseURL: cfg.ShunyunbaoURL,
|
||||
Username: cfg.ShunyunbaoUsername,
|
||||
Password: cfg.ShunyunbaoPassword,
|
||||
Timeout: cfg.ShunyunbaoTimeout,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
freight, err := usecase.NewFreightService(
|
||||
store,
|
||||
erpClient,
|
||||
@@ -285,6 +295,7 @@ func buildRouter(
|
||||
return nil, err
|
||||
}
|
||||
webService.SetProcurement(procurement)
|
||||
webService.SetERPConnection(erpSession)
|
||||
renderer, err := webui.NewRenderer()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -328,6 +339,7 @@ func buildRouter(
|
||||
Authorizations: authorizations,
|
||||
Freight: freight,
|
||||
Procurement: procurement,
|
||||
ERP: erpSession,
|
||||
},
|
||||
webHandler,
|
||||
)
|
||||
|
||||
@@ -137,10 +137,12 @@ func TestBuildRouterRegistersProtectedLogoutRoute(t *testing.T) {
|
||||
t.Fatalf("migration.Up() error = %v", err)
|
||||
}
|
||||
router, err := buildRouter(ctx, config.Config{
|
||||
AssetDirectory: filepath.Join(t.TempDir(), "assets"),
|
||||
ClaimLease: 10 * time.Minute,
|
||||
RunningLease: 30 * time.Minute,
|
||||
ReadinessTTL: 2 * time.Minute,
|
||||
AssetDirectory: filepath.Join(t.TempDir(), "assets"),
|
||||
ClaimLease: 10 * time.Minute,
|
||||
RunningLease: 30 * time.Minute,
|
||||
ReadinessTTL: 2 * time.Minute,
|
||||
ShunyunbaoURL: "https://www.shunyunbaoerp.com",
|
||||
ShunyunbaoTimeout: 30 * time.Second,
|
||||
}, db)
|
||||
if err != nil {
|
||||
t.Fatalf("buildRouter() error = %v", err)
|
||||
@@ -159,7 +161,7 @@ func TestBuildRouterRegistersProtectedLogoutRoute(t *testing.T) {
|
||||
response.Header().Get("Location"),
|
||||
)
|
||||
}
|
||||
for _, target := range []string{"/freight", "/freight/import"} {
|
||||
for _, target := range []string{"/freight", "/freight/import", "/erp"} {
|
||||
request = httptest.NewRequest(http.MethodGet, target, nil)
|
||||
response = httptest.NewRecorder()
|
||||
router.ServeHTTP(response, request)
|
||||
|
||||
Reference in New Issue
Block a user