refactor(backend): authorization v2

This commit is contained in:
pycook
2025-07-16 18:11:04 +08:00
parent d8387323dd
commit 7e2c667fc4
48 changed files with 10593 additions and 554 deletions

View File

@@ -63,10 +63,14 @@ func (c *Controller) GetConfig(ctx *gin.Context) {
cfg, err := configService.GetConfig(ctx)
if err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) {
ctx.AbortWithError(http.StatusInternalServerError, &myErrors.ApiError{Code: myErrors.ErrInternal, Data: map[string]any{"err": err}})
if errors.Is(err, gorm.ErrRecordNotFound) {
// Return default configuration if no config exists
defaultCfg := model.GetDefaultConfig()
ctx.JSON(http.StatusOK, NewHttpResponseWithData(defaultCfg))
return
}
ctx.AbortWithError(http.StatusInternalServerError, &myErrors.ApiError{Code: myErrors.ErrInternal, Data: map[string]any{"err": err}})
return
}
ctx.JSON(http.StatusOK, NewHttpResponseWithData(cfg))