添加获取所有文章分类接口
parent
653a972b8f
commit
4e2ff25d38
|
@ -220,3 +220,23 @@ func DeleteArticle(c *gin.Context) {
|
|||
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
|
||||
}
|
3
main.go
3
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()))
|
||||
|
|
Loading…
Reference in New Issue