fix(config): use web.AppConfig instead of adapter

- use web.AppConfig, and change related codes

TODO: handles errors
This commit is contained in:
roberChen
2021-03-25 10:42:18 +08:00
parent e3a792e6df
commit 2d05b5a80f
11 changed files with 95 additions and 92 deletions

View File

@@ -3,7 +3,7 @@ package conf
import (
"strings"
"github.com/beego/beego/v2/adapter"
"github.com/beego/beego/v2/server/web"
)
type SmtpConf struct {
@@ -19,14 +19,14 @@ type SmtpConf struct {
}
func GetMailConfig() *SmtpConf {
user_name := adapter.AppConfig.String("smtp_user_name")
password := adapter.AppConfig.String("smtp_password")
smtp_host := adapter.AppConfig.String("smtp_host")
smtp_port := adapter.AppConfig.DefaultInt("smtp_port", 25)
form_user_name := adapter.AppConfig.String("form_user_name")
enable_mail := adapter.AppConfig.String("enable_mail")
mail_number := adapter.AppConfig.DefaultInt("mail_number", 5)
secure := adapter.AppConfig.DefaultString("secure", "NONE")
user_name, _ := web.AppConfig.String("smtp_user_name")
password, _ := web.AppConfig.String("smtp_password")
smtp_host, _ := web.AppConfig.String("smtp_host")
smtp_port := web.AppConfig.DefaultInt("smtp_port", 25)
form_user_name, _ := web.AppConfig.String("form_user_name")
enable_mail, _ := web.AppConfig.String("enable_mail")
mail_number := web.AppConfig.DefaultInt("mail_number", 5)
secure := web.AppConfig.DefaultString("secure", "NONE")
if secure != "NONE" && secure != "LOGIN" && secure != "SSL" {
secure = "NONE"