Skip to content

Commit

Permalink
fix: error for the install step
Browse files Browse the repository at this point in the history
  • Loading branch information
saltbo committed Feb 10, 2021
1 parent da3c3f5 commit b6d627a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
8 changes: 7 additions & 1 deletion internal/app/api/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ func (rs *Option) createDatabase(c *gin.Context) {
return
}

if err := dao.NewOption().Init(); err != nil {
ginutil.JSONServerError(c, err)
return
}

viper.Set("database.driver", p["driver"])
viper.Set("database.dsn", p["dsn"])
if err := viper.WriteConfigAs("config.yml"); err != nil {
viper.SetConfigFile("config.yml")
if err := viper.WriteConfigAs(viper.ConfigFileUsed()); err != nil {
ginutil.JSONServerError(c, err)
return
}
Expand Down
6 changes: 6 additions & 0 deletions internal/app/dao/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ func (o *Option) Set(name string, opts model.Opts) error {
}
return gdb.Save(mOpt).Error
}

func (o *Option) Init() error {
o.Set(model.OptSite, model.DefaultSiteOpts)
o.Set(model.OptEmail, model.DefaultEmailOpts)
return nil
}
10 changes: 7 additions & 3 deletions internal/app/model/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ import (
)

const (
OptSite = "CORE_SITE"
OptEmail = "CORE_EMAIL"
//OptInvitation = "INVITATION"
OptSite = "core.site"
OptEmail = "core.email"
)

var (
DefaultSiteOpts = Opts{"name": "ZPan", "intro": "您的私有网盘专家", "locale": "zh-CN", "invite_required": true}
DefaultEmailOpts = Opts{"address": "smtpdm.aliyun.com:25", "username": "no-reply@saltbo.fun", "password": "yourpassword", "sender": "ZPan"}
)

type Option struct {
Expand Down

0 comments on commit b6d627a

Please sign in to comment.