diff --git a/controller/blog.go b/controller/blog.go index 88d4d3b..652bfee 100644 --- a/controller/blog.go +++ b/controller/blog.go @@ -63,7 +63,8 @@ func GetArticles(c *gin.Context) { }else{ is_public = 1 } - sql = fmt.Sprintf("select * from doc where doc.title like '%%%s%%' and doc.type = %d and is_public = %d limit %d offset %d ",is_public,req.Name,req.Type,limit,offset*limit) + sql = fmt.Sprintf("select * from doc where doc.title like '%%%s%%' and doc.type = %d and is_public = %d limit %d offset %d ", + is_public,req.Name,req.Type,limit,offset*limit) } }else{ if req.Type == 110{ @@ -78,9 +79,9 @@ func GetArticles(c *gin.Context) { }else{ is_public := 0 if public == "true"{ - is_public = 0 - }else{ is_public = 1 + }else{ + is_public = 0 } sql = fmt.Sprintf("SELECT doc.id,doc.author,LEFT(doc.content,50) as content,doc.title,doc.type from doc where doc.type = %d and is_public = %d " + "limit %d offset %d",req.Type,is_public,limit,offset) diff --git a/main.go b/main.go index deeb0f4..c28c980 100644 --- a/main.go +++ b/main.go @@ -52,6 +52,7 @@ func InitConfig() { log.Println(e.Error()) } } + func InitMysql() { c := config.GetMysqlConfig() if c == nil { @@ -60,6 +61,7 @@ func InitMysql() { db.Init() } } + func InitRedisConfig() { e := config.InitRedis() if nil != e { @@ -67,12 +69,14 @@ func InitRedisConfig() { return } } + func InitElasticSearch(){ e := db.GetElastic().CreateIndex("hardware",model.HardwareTypeMapping()) if nil != e{ } } + func InitLogs() { logs.Init(config.GetLogConfig().Dir, config.GetLogConfig().File, config.GetLogConfig().Level, config.GetLogConfig().SaveFile) }