Add backend foundation and config-driven workbench
This commit is contained in:
31
backend/internal/httpapi/handlers/entry_handler.go
Normal file
31
backend/internal/httpapi/handlers/entry_handler.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"cmr-backend/internal/httpx"
|
||||
"cmr-backend/internal/service"
|
||||
)
|
||||
|
||||
type EntryHandler struct {
|
||||
entryService *service.EntryService
|
||||
}
|
||||
|
||||
func NewEntryHandler(entryService *service.EntryService) *EntryHandler {
|
||||
return &EntryHandler{entryService: entryService}
|
||||
}
|
||||
|
||||
func (h *EntryHandler) Resolve(w http.ResponseWriter, r *http.Request) {
|
||||
result, err := h.entryService.Resolve(r.Context(), service.ResolveEntryInput{
|
||||
ChannelCode: r.URL.Query().Get("channelCode"),
|
||||
ChannelType: r.URL.Query().Get("channelType"),
|
||||
PlatformAppID: r.URL.Query().Get("platformAppId"),
|
||||
TenantCode: r.URL.Query().Get("tenantCode"),
|
||||
})
|
||||
if err != nil {
|
||||
httpx.WriteError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
httpx.WriteJSON(w, http.StatusOK, map[string]any{"data": result})
|
||||
}
|
||||
Reference in New Issue
Block a user