删除mongodb的支持
parent
0d27f524ed
commit
b3e9b1d9a1
|
@ -21,7 +21,7 @@ var gMongo *mgo.Session
|
|||
func Init() {
|
||||
mysqlconf := config.GetMysqlConfig()
|
||||
blogConf := config.GetMysqlBlogConfig()
|
||||
InitMongoDb()
|
||||
//InitMongoDb()
|
||||
blogDb = Database{Type: string(""), DB: initMysql(blogConf)}
|
||||
gDb = Database{Type: string(""), DB: initMysqlTLS(mysqlconf)}
|
||||
}
|
||||
|
|
6
main.go
6
main.go
|
@ -70,9 +70,9 @@ func main() {
|
|||
InitRedis()
|
||||
InitMysql()
|
||||
|
||||
mgo := db.GetMongoDb()
|
||||
mgo = mgo
|
||||
config.GetMongoDBConfig()
|
||||
//o := db.GetMongoDb()
|
||||
//mgo = mgo
|
||||
//config.GetMongoDBConfig()
|
||||
r := gin.Default()
|
||||
store := sessions.NewCookieStore([]byte("secret123"))
|
||||
r.Use(sessions.Middleware("sess_store", store))
|
||||
|
|
|
@ -40,7 +40,7 @@ func CreateDoc(doc Doc) error {
|
|||
FROM
|
||||
DUAL
|
||||
WHERE
|
||||
NOT EXISTS ( SELECT * FROM doc WHERE doc.title = '%s' );`, doc.Title, doc.Content, doc.Author, doc.Type,doc.Title)
|
||||
NOT EXISTS ( SELECT * FROM doc WHERE doc.title = '%s' );`, doc.Title, strings.Replace(doc.Content, "'", "\\'", -1), doc.Author, doc.Type,doc.Title)
|
||||
_, e := db.GetMysqlClient().Query(sql)
|
||||
if nil != e {
|
||||
logs.Error(e.Error())
|
||||
|
@ -51,7 +51,7 @@ WHERE
|
|||
|
||||
func UpdateDoc(doc Doc) error{
|
||||
sql := fmt.Sprintf(`update doc set doc.author = '%s' ,doc.title = '%s',doc.type = '%d',doc.content = '%s' where doc.id = '%d'; `,
|
||||
doc.Author, strings.Replace(doc.Title, "'", "\\'", -1), doc.Type,
|
||||
doc.Author, doc.Title, doc.Type,
|
||||
strings.Replace(doc.Content, "'", "\\'", -1),doc.ID)
|
||||
_, e := db.GetMysqlClient().Query(sql)
|
||||
if nil != e {
|
||||
|
|
Loading…
Reference in New Issue