routes.go 4.6 KB
// Code generated by goctl. DO NOT EDIT.
package handler

import (
	"net/http"

	chat "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/chat/api/internal/handler/chat"
	dataset "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/chat/api/internal/handler/dataset"
	document "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/chat/api/internal/handler/document"
	"gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/chat/api/internal/svc"

	"github.com/zeromicro/go-zero/rest"
)

func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
	server.AddRoutes(
		rest.WithMiddlewares(
			[]rest.Middleware{serverCtx.LogRequest},
			[]rest.Route{
				{
					Method:  http.MethodGet,
					Path:    "/chat/session/:id",
					Handler: chat.ChatSessionGetHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/chat/session",
					Handler: chat.ChatSessionSaveHandler(serverCtx),
				},
				{
					Method:  http.MethodDelete,
					Path:    "/chat/session/:id",
					Handler: chat.ChatSessionDeleteHandler(serverCtx),
				},
				{
					Method:  http.MethodPut,
					Path:    "/chat/session/:id",
					Handler: chat.ChatSessionUpdateHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/chat/session/search",
					Handler: chat.ChatSessionSearchHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/chat/session/conversation",
					Handler: chat.ChatSessionConversationHandler(serverCtx),
				},
				{
					Method:  http.MethodGet,
					Path:    "/chat/session/conversation",
					Handler: chat.ChatSessionConversationWsHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/chat/session/my_spark_sessions",
					Handler: chat.ChatMySparkSessionsHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/chat/spark_session",
					Handler: chat.ChatSparkSessionSaveHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/chat/session/records",
					Handler: chat.ChatSessionRecordsHandler(serverCtx),
				},
				{
					Method:  http.MethodGet,
					Path:    "/chat/models",
					Handler: chat.ChatModelsHandler(serverCtx),
				},
			}...,
		),
		rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
		rest.WithPrefix("/v1"),
	)

	server.AddRoutes(
		rest.WithMiddlewares(
			[]rest.Middleware{serverCtx.LogRequest},
			[]rest.Route{
				{
					Method:  http.MethodGet,
					Path:    "/chat/document/:id",
					Handler: document.ChatDocumentGetHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/chat/document",
					Handler: document.ChatDocumentSaveHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/chat/document/batch_save",
					Handler: document.ChatDocumentBatchSaveHandler(serverCtx),
				},
				{
					Method:  http.MethodDelete,
					Path:    "/chat/document/:id",
					Handler: document.ChatDocumentDeleteHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/chat/document/rename",
					Handler: document.ChatDocumentRenameHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/chat/document/search",
					Handler: document.ChatDocumentSearchHandler(serverCtx),
				},
			}...,
		),
		rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
		rest.WithPrefix("/v1"),
	)

	server.AddRoutes(
		rest.WithMiddlewares(
			[]rest.Middleware{serverCtx.LogRequest},
			[]rest.Route{
				{
					Method:  http.MethodGet,
					Path:    "/chat/dataset/:id",
					Handler: dataset.ChatDatasetGetHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/chat/dataset",
					Handler: dataset.ChatDatasetSaveHandler(serverCtx),
				},
				{
					Method:  http.MethodDelete,
					Path:    "/chat/dataset/:id",
					Handler: dataset.ChatDatasetDeleteHandler(serverCtx),
				},
				{
					Method:  http.MethodPut,
					Path:    "/chat/dataset/:id",
					Handler: dataset.ChatDatasetUpdateHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/chat/dataset/rename",
					Handler: dataset.ChatDatasetRenameHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/chat/dataset/search",
					Handler: dataset.ChatDatasetSearchHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/chat/dataset/add_files",
					Handler: dataset.ChatDatasetAddFilesHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/chat/dataset/remove_files",
					Handler: dataset.ChatDatasetRemvoeFilesHandler(serverCtx),
				},
			}...,
		),
		rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
		rest.WithPrefix("/v1"),
	)
}