mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-10 02:23:43 +08:00
fix: models api return models in deactivate channels
- Enhance logging functionality by adding context support and improving debugging options. - Standardize function naming conventions across middleware to ensure consistency. - Optimize data retrieval and handling in the model controller, including caching and error management. - Simplify the bug report template to streamline the issue reporting process.
This commit is contained in:
@@ -32,16 +32,16 @@ func Distribute() func(c *gin.Context) {
|
||||
if ok {
|
||||
id, err := strconv.Atoi(channelId.(string))
|
||||
if err != nil {
|
||||
abortWithError(c, http.StatusBadRequest, errors.New("Invalid Channel Id"))
|
||||
AbortWithError(c, http.StatusBadRequest, errors.New("Invalid Channel Id"))
|
||||
return
|
||||
}
|
||||
channel, err = model.GetChannelById(id, true)
|
||||
if err != nil {
|
||||
abortWithError(c, http.StatusBadRequest, errors.New("Invalid Channel Id"))
|
||||
AbortWithError(c, http.StatusBadRequest, errors.New("Invalid Channel Id"))
|
||||
return
|
||||
}
|
||||
if channel.Status != model.ChannelStatusEnabled {
|
||||
abortWithError(c, http.StatusForbidden, errors.New("The channel has been disabled"))
|
||||
AbortWithError(c, http.StatusForbidden, errors.New("The channel has been disabled"))
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@@ -54,7 +54,7 @@ func Distribute() func(c *gin.Context) {
|
||||
logger.SysError(fmt.Sprintf("Channel does not exist: %d", channel.Id))
|
||||
message = "Database consistency has been broken, please contact the administrator"
|
||||
}
|
||||
abortWithError(c, http.StatusServiceUnavailable, errors.New(message))
|
||||
AbortWithError(c, http.StatusServiceUnavailable, errors.New(message))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user