You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
958 B
43 lines
958 B
package core
|
|
|
|
import (
|
|
"aufs/db"
|
|
"encoding/json"
|
|
"net/http"
|
|
// "github.com/jmoiron/sqlx"
|
|
// _ "github.com/logoove/sqlite"
|
|
)
|
|
|
|
// 输出的结构
|
|
type ScJson struct {
|
|
Message string `json:"message"`
|
|
Status int `json:"status"`
|
|
Data []db.StServerInfo `json:"data"`
|
|
}
|
|
|
|
// 系统设置
|
|
func Settdb(w http.ResponseWriter, r *http.Request) {
|
|
// 检查数据表是否存在
|
|
// scdb, err := sqlx.Open("sqlite", "ups.db")
|
|
// if err != nil {
|
|
// fmt.Printf("Failed to open database: %v\n", err)
|
|
// return
|
|
// }
|
|
// defer scdb.Close()
|
|
// 如果表sc_server不存在,则创建
|
|
// _, err = scdb.Exec("SELECT name FROM sqlite_master WHERE type='table' AND name='sc_server'")
|
|
// if err != nil {
|
|
// // cuowu
|
|
// log.Fatalf("table has exists:%s", err)
|
|
// }
|
|
//
|
|
sclst := db.GetlScList()
|
|
//
|
|
scresp := ScJson{
|
|
Message: "success",
|
|
Status: 200,
|
|
Data: sclst,
|
|
}
|
|
uCorsHadler(w, r)
|
|
json.NewEncoder(w).Encode(scresp)
|
|
}
|
|
|