feat(t230): use OCR for ERP session login
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"cmroubao/backend-api/internal/platform/assetstore"
|
||||
"cmroubao/backend-api/internal/platform/database"
|
||||
"cmroubao/backend-api/internal/platform/migration"
|
||||
"cmroubao/backend-api/internal/platform/ocrapi"
|
||||
"cmroubao/backend-api/internal/platform/password"
|
||||
"cmroubao/backend-api/internal/platform/shunyunbao"
|
||||
repository "cmroubao/backend-api/internal/repository/sqlite"
|
||||
@@ -232,11 +233,16 @@ func buildRouter(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ocr, err := ocrapi.NewClient(cfg.OCRAPIURL, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
erpSession, err := shunyunbao.NewSessionManager(shunyunbao.SessionConfig{
|
||||
BaseURL: cfg.ShunyunbaoURL,
|
||||
Username: cfg.ShunyunbaoUsername,
|
||||
Password: cfg.ShunyunbaoPassword,
|
||||
Timeout: cfg.ShunyunbaoTimeout,
|
||||
BaseURL: cfg.ShunyunbaoURL,
|
||||
Username: cfg.ShunyunbaoUsername,
|
||||
Password: cfg.ShunyunbaoPassword,
|
||||
Timeout: cfg.ShunyunbaoTimeout,
|
||||
CaptchaRecognizer: ocr,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -296,7 +302,6 @@ func buildRouter(
|
||||
return nil, err
|
||||
}
|
||||
webService.SetProcurement(procurement)
|
||||
webService.SetERPConnection(erpSession)
|
||||
renderer, err := webui.NewRenderer()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -340,7 +345,6 @@ func buildRouter(
|
||||
Authorizations: authorizations,
|
||||
Freight: freight,
|
||||
Procurement: procurement,
|
||||
ERP: erpSession,
|
||||
},
|
||||
webHandler,
|
||||
)
|
||||
|
||||
@@ -196,7 +196,7 @@ func TestBuildRouterRegistersProtectedLogoutRoute(t *testing.T) {
|
||||
response.Header().Get("Location"),
|
||||
)
|
||||
}
|
||||
for _, target := range []string{"/freight", "/freight/import", "/erp"} {
|
||||
for _, target := range []string{"/freight", "/freight/import"} {
|
||||
request = httptest.NewRequest(http.MethodGet, target, nil)
|
||||
response = httptest.NewRecorder()
|
||||
router.ServeHTTP(response, request)
|
||||
|
||||
Reference in New Issue
Block a user