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