29 lines
620 B
Go
29 lines
620 B
Go
package model
|
|
|
|
import (
|
|
"background/db"
|
|
"github.com/pkg/errors"
|
|
"qiniupkg.com/x/log.v7"
|
|
)
|
|
|
|
// this api is based on elasticsearch
|
|
type Hardware struct {
|
|
ID int32 `json:"id"`
|
|
BuyDate string `json:"buy_date"` //购入时间
|
|
Name string `json:"name"` // 名字
|
|
Desc string `json:"desc"` // 描述
|
|
Pic string `json:"pic"` // 图片
|
|
Doc string `json:"doc"` //文档资料
|
|
}
|
|
|
|
func (this *Hardware )CreateHardware( ) error{
|
|
if nil == this{
|
|
return errors.New("null pointer")
|
|
}
|
|
e := db.GetElastic().Create("hardware","0","sdfasdfasd",*this)
|
|
if nil != e{
|
|
log.Print(e.Error())
|
|
return e
|
|
}
|
|
return nil;
|
|
} |