57 lines
883 B
Go
57 lines
883 B
Go
package controller
|
|
|
|
import (
|
|
"background/model"
|
|
"github.com/gin-gonic/gin"
|
|
"qiniupkg.com/x/log.v7"
|
|
)
|
|
|
|
|
|
func AddHardware(c *gin.Context) {
|
|
resp := RespBase{"unkown error",-231,nil}
|
|
defer func() {
|
|
c.JSON(200,resp)
|
|
}()
|
|
var hardware model.Hardware
|
|
|
|
e := c.BindJSON(&hardware)
|
|
if nil != e{
|
|
log.Print(e)
|
|
print(e)
|
|
return
|
|
}
|
|
if nil != hardware.CreateHardware(){
|
|
print(e)
|
|
return
|
|
}
|
|
resp.Data = nil
|
|
resp.Msg = "OK"
|
|
resp.Status = 0
|
|
}
|
|
|
|
func DeleteHardWare(c *gin.Context) {
|
|
|
|
}
|
|
|
|
func UpdateHardWare(c *gin.Context) {
|
|
|
|
}
|
|
|
|
func ReadHardWare(c *gin.Context) {
|
|
var req model.Hardware
|
|
rsp := RespBase{"ERR",-1,nil}
|
|
defer func() {
|
|
c.JSON(200,rsp)
|
|
}()
|
|
e := c.BindJSON(&req)
|
|
if nil != e{
|
|
log.Error(e.Error())
|
|
return
|
|
}
|
|
limit,offset := GetPageParaFromQuery(c)
|
|
hardware,e := model.GetHardwares(limit,offset)
|
|
rsp.Data = hardware
|
|
rsp.Msg = "OK"
|
|
rsp.Status = 0
|
|
}
|