feat: 将interface{}替换为any以提高代码一致性

This commit is contained in:
tbphp
2025-07-04 21:22:25 +08:00
parent 01b86f7e30
commit 13adf2ef8b
6 changed files with 27 additions and 27 deletions

View File

@@ -12,7 +12,7 @@ import (
// @Tags Dashboard
// @Accept json
// @Produce json
// @Success 200 {object} map[string]interface{}
// @Success 200 {object} map[string]any
// @Router /api/dashboard/stats [get]
func (s *Server) Stats(c *gin.Context) {
var totalRequests, successRequests int64

View File

@@ -25,7 +25,7 @@ func isValidGroupName(name string) bool {
}
// validateAndCleanConfig validates the group config against the GroupConfig struct.
func validateAndCleanConfig(configMap map[string]interface{}) (map[string]interface{}, error) {
func validateAndCleanConfig(configMap map[string]any) (map[string]any, error) {
if configMap == nil {
return nil, nil
}
@@ -60,7 +60,7 @@ func validateAndCleanConfig(configMap map[string]interface{}) (map[string]interf
return nil, err
}
var cleanedMap map[string]interface{}
var cleanedMap map[string]any
if err := json.Unmarshal(validatedBytes, &cleanedMap); err != nil {
return nil, err
}
@@ -122,15 +122,15 @@ func (s *Server) ListGroups(c *gin.Context) {
// GroupUpdateRequest defines the payload for updating a group.
// Using a dedicated struct avoids issues with zero values being ignored by GORM's Update.
type GroupUpdateRequest struct {
Name string `json:"name"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
Upstreams json.RawMessage `json:"upstreams"`
ChannelType string `json:"channel_type"`
Sort *int `json:"sort"`
TestModel string `json:"test_model"`
ParamOverrides map[string]interface{} `json:"param_overrides"`
Config map[string]interface{} `json:"config"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
Upstreams json.RawMessage `json:"upstreams"`
ChannelType string `json:"channel_type"`
Sort *int `json:"sort"`
TestModel string `json:"test_model"`
ParamOverrides map[string]any `json:"param_overrides"`
Config map[string]any `json:"config"`
}
// UpdateGroup handles updating an existing group.