燕鹏
4 years ago
32 changed files with 111 additions and 124 deletions
@ -1,29 +1,18 @@ |
|||||
package models |
package models |
||||
|
|
||||
import ( |
import ( |
||||
"github.com/astaxie/beego" |
"fmt" |
||||
//"github.com/Unknwon/com"
|
"github.com/beego/beego/v2/client/orm" |
||||
//"os"
|
"github.com/beego/beego/v2/core/config" |
||||
//"path"
|
|
||||
"github.com/astaxie/beego/orm" |
|
||||
//_ "github.com/mattn/go-sqlite3"
|
|
||||
_ "github.com/go-sql-driver/mysql" |
_ "github.com/go-sql-driver/mysql" |
||||
) |
) |
||||
|
|
||||
const ( |
|
||||
_DB_NAME = "data/beeblog.db" |
|
||||
_SQLITE3_DRIVER = "sqlite3" |
|
||||
) |
|
||||
|
|
||||
func RegistDB() { |
func RegistDB() { |
||||
//if !com.IsExist(_DB_NAME){
|
dbUrl, _ := config.String("dburl") |
||||
// os.MkdirAll(path.Dir(_DB_NAME),os.ModePerm)
|
fmt.Println(dbUrl) |
||||
// os.Create(_DB_NAME)
|
orm.RegisterDriver("mysql", orm.DRMySQL) |
||||
//}
|
orm.RegisterDataBase("default", "mysql", "root:"+dbUrl+"/beeblog?charset=utf8&loc=Local") |
||||
//orm.RegisterModel(new(Attachment),new(Topic))
|
|
||||
//orm.RegisterDriver(_SQLITE3_DRIVER,orm.DRSqlite)
|
|
||||
//orm.RegisterDataBase("default",_SQLITE3_DRIVER,_DB_NAME,10)
|
|
||||
|
|
||||
orm.RegisterModel(new(User), new(Blog), new(NLabel), new(Note), new(NoteColl), new(Category), new(Like), new(Comment)) |
orm.RegisterModel(new(User), new(Blog), new(NLabel), new(Note), new(NoteColl), new(Category), new(Like), new(Comment)) |
||||
orm.RegisterDataBase("default", "mysql", "root:"+beego.AppConfig.String("dburl")+"/beeblog?charset=utf8&loc=Local", 30) |
|
||||
|
//orm.RunSyncdb("default", false, true)
|
||||
} |
} |
||||
|
@ -1,11 +1,11 @@ |
|||||
package routers |
package routers |
||||
|
|
||||
import ( |
import ( |
||||
"github.com/astaxie/beego" |
|
||||
"beeblog/controllers" |
"beeblog/controllers" |
||||
|
beego "github.com/beego/beego/v2/server/web" |
||||
) |
) |
||||
|
|
||||
func init() { |
func init() { |
||||
beego.Router("/api/comms/save", &controllers.CommentController{}, "post:Save") |
beego.Router("/api/comms/save", &controllers.CommentController{}, "post:Save") |
||||
beego.Router("/api/comms/del/:id([0-9]+)", &controllers.CommentController{}, "get:Del") |
beego.Router("/api/comms/del/:id([0-9]+)", &controllers.CommentController{}, "get:Del") |
||||
} |
} |
||||
|
Loading…
Reference in new issue