添加获取所有文章分类接口

master
a74589669 2019-09-07 00:31:01 +08:00
parent 653a972b8f
commit 4e2ff25d38
3 changed files with 23 additions and 2 deletions

View File

@ -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
}

View File

@ -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()))

View File

@ -67,4 +67,4 @@ func DeleteDoc(id int64) error{
return e
}
return nil
}
}