diff --git a/server/collection/internal/handler/routes.go b/server/collection/internal/handler/routes.go index 7c9fa49f..1d8b59a5 100644 --- a/server/collection/internal/handler/routes.go +++ b/server/collection/internal/handler/routes.go @@ -27,11 +27,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/api/collection/get_collect_product_list", Handler: GetCollectProductListHandler(serverCtx), }, - { - Method: http.MethodPost, - Path: "/api/collection/test_ai", - Handler: TestAiHandler(serverCtx), - }, }, ) } diff --git a/server/collection/internal/handler/testaihandler.go b/server/collection/internal/handler/testaihandler.go deleted file mode 100644 index 1be6a44d..00000000 --- a/server/collection/internal/handler/testaihandler.go +++ /dev/null @@ -1,35 +0,0 @@ -package handler - -import ( - "net/http" - "reflect" - - "fusenapi/utils/basic" - - "fusenapi/server/collection/internal/logic" - "fusenapi/server/collection/internal/svc" - "fusenapi/server/collection/internal/types" -) - -func TestAiHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - - var req types.TestAiReq - userinfo, err := basic.RequestParse(w, r, svcCtx, &req) - if err != nil { - return - } - - // 创建一个业务逻辑层实例 - l := logic.NewTestAiLogic(r.Context(), svcCtx) - - rl := reflect.ValueOf(l) - basic.BeforeLogic(w, r, rl) - - resp := l.TestAi(&req, userinfo, w) - - if !basic.AfterLogic(w, r, rl, resp) { - basic.NormalAfterLogic(w, r, resp) - } - } -} diff --git a/server/collection/internal/logic/testailogic.go b/server/collection/internal/logic/testailogic.go deleted file mode 100644 index aaa82bad..00000000 --- a/server/collection/internal/logic/testailogic.go +++ /dev/null @@ -1,57 +0,0 @@ -package logic - -import ( - "fusenapi/constants" - "fusenapi/utils/auth" - "fusenapi/utils/basic" - "fusenapi/utils/curl" - "math/rand" - "net/http" - "time" - - "context" - - "fusenapi/server/collection/internal/svc" - "fusenapi/server/collection/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type TestAiLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewTestAiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TestAiLogic { - return &TestAiLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *TestAiLogic) TestAi(req *types.TestAiReq, userinfo *auth.UserInfo, w http.ResponseWriter) (resp *basic.Response) { - lenAiHost := len(l.svcCtx.Config.BLMService.Urls) - if lenAiHost == 0 { - return resp.SetStatusWithMessage(basic.CodeServiceErr, "ai host list is 0") - } - hostIndex := rand.Intn(lenAiHost) - var resultBLM constants.BLMServiceUrlResult - logx.Info("正在请求:" + l.svcCtx.Config.BLMService.Urls[hostIndex]) - err := curl.NewClient(l.ctx, &curl.Config{ - BaseUrl: l.svcCtx.Config.BLMService.Urls[hostIndex], - Url: constants.BLMServiceUrlLogoCombine, - RequireTimeout: time.Second * 15, - }).PostJson(req.Data, &resultBLM) - if err != nil { - w.WriteHeader(http.StatusInternalServerError) - return resp.SetStatusWithMessage(basic.CodeServiceErr, "request failed") - } - return resp.SetStatusWithMessage(basic.CodeOK, "success") -} - -// 处理逻辑后 w,r 如:重定向, resp 必须重新处理 -// func (l *TestAiLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) { -// // httpx.OkJsonCtx(r.Context(), w, resp) -// } diff --git a/server/collection/internal/types/types.go b/server/collection/internal/types/types.go index 7e408a4f..62d68266 100644 --- a/server/collection/internal/types/types.go +++ b/server/collection/internal/types/types.go @@ -40,10 +40,6 @@ type GetCollectProductListRspItem struct { IsDeleted int64 `json:"is_deleted"` } -type TestAiReq struct { - Data map[string]interface{} `json:"data"` -} - type Request struct { } diff --git a/server_api/collection.api b/server_api/collection.api index d653f4c4..37bcf004 100644 --- a/server_api/collection.api +++ b/server_api/collection.api @@ -18,9 +18,6 @@ service collection { //获取收藏列表 @handler GetCollectProductListHandler get /api/collection/get_collect_product_list(GetCollectProductListReq) returns (response); - //测试算法合图并发 - @handler TestAiHandler - post /api/collection/test_ai(TestAiReq) returns (response); } //收藏产品 @@ -55,8 +52,4 @@ type GetCollectProductListRspItem { MinPrice string `json:"min_price"` IsShelf int64 `json:"is_shelf"` IsDeleted int64 `json:"is_deleted"` -} -//测试算法 -type TestAiReq { - Data map[string]interface{} `json:"data"` } \ No newline at end of file