2020-03-23 15:58:39 +00:00
|
|
|
package model
|
|
|
|
|
2020-03-25 02:57:25 +00:00
|
|
|
import (
|
|
|
|
"background/db"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"qiniupkg.com/x/log.v7"
|
|
|
|
)
|
2020-03-23 15:58:39 +00:00
|
|
|
|
2020-03-25 16:30:07 +00:00
|
|
|
func HardwareTypeMapping() (string){
|
|
|
|
return `"mappings":{
|
|
|
|
"hardware":{
|
|
|
|
"properties":{
|
|
|
|
"id":{"type":"keyword"},
|
|
|
|
"name":{"type":"text"},
|
|
|
|
"desc":{"type":"text"},
|
|
|
|
"id":{"type":"interger"},
|
|
|
|
"pic":{"type":"doc"},
|
|
|
|
"doc":{"type":"doc"}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`
|
|
|
|
}
|
|
|
|
|
2020-03-23 15:58:39 +00:00
|
|
|
// this api is based on elasticsearch
|
|
|
|
type Hardware struct {
|
2020-03-25 16:30:07 +00:00
|
|
|
ID int32 `json:"id,omitempty"`
|
|
|
|
BuyDate string `json:"buy_date,omitempty"` //购入时间
|
|
|
|
Name string `json:"name,omitempty"` // 名字
|
|
|
|
Desc string `json:"desc,omitempty"` // 描述
|
|
|
|
Pic string `json:"pic,omitempty"` // 图片
|
|
|
|
Doc string `json:"doc,omitempty"` //文档资料
|
2020-03-23 15:58:39 +00:00
|
|
|
}
|
|
|
|
|
2020-03-25 02:57:25 +00:00
|
|
|
func (this *Hardware )CreateHardware( ) error{
|
|
|
|
if nil == this{
|
|
|
|
return errors.New("null pointer")
|
|
|
|
}
|
2020-03-25 03:26:32 +00:00
|
|
|
e := db.GetElastic().Create("hardware","0","sdfasdfasd",*this)
|
2020-03-25 02:57:25 +00:00
|
|
|
if nil != e{
|
|
|
|
log.Print(e.Error())
|
|
|
|
return e
|
|
|
|
}
|
2020-03-23 15:58:39 +00:00
|
|
|
return nil;
|
2020-03-25 16:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *Hardware)Hardwares() ([]Hardware,error){
|
|
|
|
|
|
|
|
return nil,nil
|
|
|
|
}
|