增加跨域配置,以及增加配置说明

This commit is contained in:
2020-02-20 14:20:56 +08:00
parent 9070bd2fe7
commit 0f29b3304e
23 changed files with 255 additions and 144 deletions
-18
View File
@@ -1,18 +0,0 @@
package db
import (
"code.hoteas.com/hoteas/hotime"
"code.hoteas.com/hoteas/hotime/dri/mysql"
"code.hoteas.com/hoteas/hotime/dri/sqlite"
"strings"
)
func SetDB(appIns *hotime.Application) {
if appIns.Config.GetString("dbType") == "sqlite" || strings.Index(appIns.Config.GetString("dbName"), ".db") == len(appIns.Config.GetString("dbName"))-3 {
appIns.Config["dbType"] = "sqlite"
sqlite.SetDB(appIns)
} else {
appIns.Config["dbType"] = "mysql"
mysql.SetDB(appIns)
}
}
-2
View File
@@ -56,8 +56,6 @@ func (this *DDY) send(mUrl string, umoblie string, content string) (bool, error)
return false, errors.New("连接错误")
}
var msg interface{}
err1 := json.Unmarshal([]byte(res), &msg)
if err1 != nil {
+1 -1
View File
@@ -24,7 +24,7 @@ func Down(url, path, name string) bool {
}
defer out.Close()
resp, err := http.Get(url)
if err!=nil{
if err != nil {
return false
}
defer resp.Body.Close()
-19
View File
@@ -1,19 +0,0 @@
package mysql
import (
"code.hoteas.com/hoteas/hotime"
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
func SetDB(appIns *hotime.Application) {
appIns.SetConnectDB(func(err ...*hotime.Error) *sql.DB {
query := appIns.Config.GetString("dbUser") + ":" + appIns.Config.GetString("dbPwd") +
"@tcp(" + appIns.Config.GetString("dbHost") + ":" + appIns.Config.GetString("dbPort") + ")/" + appIns.Config.GetString("dbName") + "?charset=utf8"
DB, e := sql.Open("mysql", query)
if e != nil && len(err) != 0 {
err[0].SetError(e)
}
return DB
})
}
-17
View File
@@ -1,17 +0,0 @@
package sqlite
import (
"code.hoteas.com/hoteas/hotime"
"database/sql"
_ "github.com/mattn/go-sqlite3"
)
func SetDB(appIns *hotime.Application) {
appIns.SetConnectDB(func(err ...*hotime.Error) *sql.DB {
db, e := sql.Open("sqlite3", appIns.Config.GetString("dbName"))
if e != nil && len(err) != 0 {
err[0].SetError(e)
}
return db
})
}
+3 -3
View File
@@ -26,7 +26,7 @@ func (this *Upload) UpFile(Request *http.Request, fieldName, savefilepath, saveP
fieldName = k
file, _, err = Request.FormFile(fieldName)
if err != nil {
return "", errors.New("上传头像失败")
return "", errors.New("上传文件失败")
}
}
@@ -58,12 +58,12 @@ func (this *Upload) UpFile(Request *http.Request, fieldName, savefilepath, saveP
header, err := os.OpenFile(filePath, os.O_CREATE, 0666)
if err != nil {
return "", errors.New("服务器创建头像文件失败")
return "", errors.New("服务器创建文件失败")
}
_, err = io.Copy(header, file)
if err != nil {
return "", errors.New("服务器复制头像文件失败")
return "", errors.New("服务器复制文件失败")
}
return filePath, nil