diff --git a/controller/blog.go b/controller/blog.go index 834393d..d53394b 100644 --- a/controller/blog.go +++ b/controller/blog.go @@ -219,4 +219,24 @@ func DeleteArticle(c *gin.Context) { rsp.Data = id rsp.Status = 0 rsp.Msg = "OK" +} +func ArticlesTypes(c *gin.Context) { + resp := RespBase{"unkown error",-231,nil} + defer func() { + c.JSON(200,resp) + }() + type DocType struct { + Id int64 `sql:"id"` + TypeName string `sql:"type_name"` + } + docTypes := []DocType{} + e := db.GetMysqlClient().Query2("select * from doc_type", + &docTypes) + if nil != e{ + log.Print(e.Error()) + return + } + resp.Data = docTypes + resp.Msg = "OK" + resp.Status = 0 } \ No newline at end of file diff --git a/main.go b/main.go index 3fb7a36..0b6dfb2 100644 --- a/main.go +++ b/main.go @@ -44,7 +44,7 @@ func InitLogs() { } func CORSMiddleware(c *gin.Context) { c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, UPDATE") - c.Writer.Header().Set("Access-Control-Allow-Origin", "http://172.21.102.193:8080") + c.Writer.Header().Set("Access-Control-Allow-Origin", "http://localhost:8080") c.Writer.Header().Set("Access-Control-Max-Age", "86400") c.Writer.Header().Set("Access-Control-Allow-Headers", "X-Requested-With," + @@ -106,6 +106,7 @@ func main() { api.DELETE("/article/:id",controller.DeleteArticle) api.POST("/image_upload",fileController.OnUpload) api.GET("/image_download/:file",fileController.OnDownLoad) + api.GET("/doc_types",controller.ArticlesTypes) } e := r.Run(":" + strconv.Itoa(config.GetPort())) diff --git a/model/blog.go b/model/blog.go index 4501dfc..a51604c 100644 --- a/model/blog.go +++ b/model/blog.go @@ -67,4 +67,4 @@ func DeleteDoc(id int64) error{ return e } return nil -} \ No newline at end of file +}