39 lines
652 B
Go
39 lines
652 B
Go
|
package Controllers
|
||
|
|
||
|
import (
|
||
|
"ESG/Models"
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"net/http"
|
||
|
//"fmt"
|
||
|
)
|
||
|
|
||
|
//查询List
|
||
|
func GetList(c *gin.Context){
|
||
|
var list Models.List
|
||
|
data := list.GetList()
|
||
|
c.JSON(http.StatusOK,gin.H{
|
||
|
"data": data,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
//查询单个News
|
||
|
func GetDetails(c *gin.Context){
|
||
|
var list Models.List
|
||
|
id := c.Query("id")
|
||
|
data := list.GetDetails(id)
|
||
|
c.JSON(http.StatusOK, gin.H{
|
||
|
"data": data,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
//发布
|
||
|
func SetNews(c *gin.Context){
|
||
|
var list Models.List
|
||
|
list.Title = c.PostForm("title")
|
||
|
list.Cover = c.PostForm("cover")
|
||
|
list.Picture = c.PostForm("img")
|
||
|
data := list.SetNews()
|
||
|
c.JSON(http.StatusOK, gin.H{
|
||
|
"data": data,
|
||
|
})
|
||
|
}
|