From 9f80b48fd7d2a8934dcd0645d6c4f68bdc015943 Mon Sep 17 00:00:00 2001 From: a7458969 <290198252@qq.com> Date: Wed, 27 May 2020 22:05:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E7=AB=A0=E6=9F=A5?= =?UTF-8?q?=E6=89=BE=E5=85=AC=E5=BC=80=E9=80=89=E9=A1=B9=E5=80=92=E5=8F=8D?= =?UTF-8?q?=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/blog.go | 7 ++++--- main.go | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) 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) }