|
|
|
|
@@ -24,29 +24,29 @@ func NewChannelHandler(channelService *service.ChannelService) *ChannelHandler {
|
|
|
|
|
// --- Request / Response types ---
|
|
|
|
|
|
|
|
|
|
type createChannelRequest struct {
|
|
|
|
|
Name string `json:"name" binding:"required,max=100"`
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
GroupIDs []int64 `json:"group_ids"`
|
|
|
|
|
ModelPricing []channelModelPricingRequest `json:"model_pricing"`
|
|
|
|
|
Name string `json:"name" binding:"required,max=100"`
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
GroupIDs []int64 `json:"group_ids"`
|
|
|
|
|
ModelPricing []channelModelPricingRequest `json:"model_pricing"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type updateChannelRequest struct {
|
|
|
|
|
Name string `json:"name" binding:"omitempty,max=100"`
|
|
|
|
|
Description *string `json:"description"`
|
|
|
|
|
Status string `json:"status" binding:"omitempty,oneof=active disabled"`
|
|
|
|
|
GroupIDs *[]int64 `json:"group_ids"`
|
|
|
|
|
ModelPricing *[]channelModelPricingRequest `json:"model_pricing"`
|
|
|
|
|
Name string `json:"name" binding:"omitempty,max=100"`
|
|
|
|
|
Description *string `json:"description"`
|
|
|
|
|
Status string `json:"status" binding:"omitempty,oneof=active disabled"`
|
|
|
|
|
GroupIDs *[]int64 `json:"group_ids"`
|
|
|
|
|
ModelPricing *[]channelModelPricingRequest `json:"model_pricing"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type channelModelPricingRequest struct {
|
|
|
|
|
Models []string `json:"models" binding:"required,min=1,max=100"`
|
|
|
|
|
BillingMode string `json:"billing_mode" binding:"omitempty,oneof=token per_request image"`
|
|
|
|
|
InputPrice *float64 `json:"input_price" binding:"omitempty,min=0"`
|
|
|
|
|
OutputPrice *float64 `json:"output_price" binding:"omitempty,min=0"`
|
|
|
|
|
CacheWritePrice *float64 `json:"cache_write_price" binding:"omitempty,min=0"`
|
|
|
|
|
CacheReadPrice *float64 `json:"cache_read_price" binding:"omitempty,min=0"`
|
|
|
|
|
ImageOutputPrice *float64 `json:"image_output_price" binding:"omitempty,min=0"`
|
|
|
|
|
Intervals []pricingIntervalRequest `json:"intervals"`
|
|
|
|
|
Models []string `json:"models" binding:"required,min=1,max=100"`
|
|
|
|
|
BillingMode string `json:"billing_mode" binding:"omitempty,oneof=token per_request image"`
|
|
|
|
|
InputPrice *float64 `json:"input_price" binding:"omitempty,min=0"`
|
|
|
|
|
OutputPrice *float64 `json:"output_price" binding:"omitempty,min=0"`
|
|
|
|
|
CacheWritePrice *float64 `json:"cache_write_price" binding:"omitempty,min=0"`
|
|
|
|
|
CacheReadPrice *float64 `json:"cache_read_price" binding:"omitempty,min=0"`
|
|
|
|
|
ImageOutputPrice *float64 `json:"image_output_price" binding:"omitempty,min=0"`
|
|
|
|
|
Intervals []pricingIntervalRequest `json:"intervals"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type pricingIntervalRequest struct {
|
|
|
|
|
@@ -62,26 +62,26 @@ type pricingIntervalRequest struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type channelResponse struct {
|
|
|
|
|
ID int64 `json:"id"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
Status string `json:"status"`
|
|
|
|
|
GroupIDs []int64 `json:"group_ids"`
|
|
|
|
|
ModelPricing []channelModelPricingResponse `json:"model_pricing"`
|
|
|
|
|
CreatedAt string `json:"created_at"`
|
|
|
|
|
UpdatedAt string `json:"updated_at"`
|
|
|
|
|
ID int64 `json:"id"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
Status string `json:"status"`
|
|
|
|
|
GroupIDs []int64 `json:"group_ids"`
|
|
|
|
|
ModelPricing []channelModelPricingResponse `json:"model_pricing"`
|
|
|
|
|
CreatedAt string `json:"created_at"`
|
|
|
|
|
UpdatedAt string `json:"updated_at"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type channelModelPricingResponse struct {
|
|
|
|
|
ID int64 `json:"id"`
|
|
|
|
|
Models []string `json:"models"`
|
|
|
|
|
BillingMode string `json:"billing_mode"`
|
|
|
|
|
InputPrice *float64 `json:"input_price"`
|
|
|
|
|
OutputPrice *float64 `json:"output_price"`
|
|
|
|
|
CacheWritePrice *float64 `json:"cache_write_price"`
|
|
|
|
|
CacheReadPrice *float64 `json:"cache_read_price"`
|
|
|
|
|
ImageOutputPrice *float64 `json:"image_output_price"`
|
|
|
|
|
Intervals []pricingIntervalResponse `json:"intervals"`
|
|
|
|
|
ID int64 `json:"id"`
|
|
|
|
|
Models []string `json:"models"`
|
|
|
|
|
BillingMode string `json:"billing_mode"`
|
|
|
|
|
InputPrice *float64 `json:"input_price"`
|
|
|
|
|
OutputPrice *float64 `json:"output_price"`
|
|
|
|
|
CacheWritePrice *float64 `json:"cache_write_price"`
|
|
|
|
|
CacheReadPrice *float64 `json:"cache_read_price"`
|
|
|
|
|
ImageOutputPrice *float64 `json:"image_output_price"`
|
|
|
|
|
Intervals []pricingIntervalResponse `json:"intervals"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type pricingIntervalResponse struct {
|
|
|
|
|
@@ -106,7 +106,7 @@ func channelToResponse(ch *service.Channel) *channelResponse {
|
|
|
|
|
Name: ch.Name,
|
|
|
|
|
Description: ch.Description,
|
|
|
|
|
Status: ch.Status,
|
|
|
|
|
GroupIDs: ch.GroupIDs,
|
|
|
|
|
GroupIDs: ch.GroupIDs,
|
|
|
|
|
CreatedAt: ch.CreatedAt.Format("2006-01-02T15:04:05Z"),
|
|
|
|
|
UpdatedAt: ch.UpdatedAt.Format("2006-01-02T15:04:05Z"),
|
|
|
|
|
}
|
|
|
|
|
|