package dbmodel import ( "encoding/json" "fmt" "github.com/astaxie/beego/orm" ) type CallbackIn struct { Id int `json:"id" orm:"column(id);auto" description:"增长id"` ServiceType int `json:"service_type" orm:"column(service_type)" description:"业务类型,101:维保记录"` SourceName string `json:"source_name" orm:"column(source_name)" description:"数据源名称,如 cbs表示查博士"` SourceObjectId string `json:"source_object_id" orm:"column(source_object_id)" description:"数据源对象id,如:order_id"` RequestCode int `json:"request_code" orm:"column(request_code)" description:"请求结果码,同request_params.code,1表示已出报告"` RequestParams string `json:"request_params" orm:"column(request_params)" description:"请求参数` ResponseParams string `json:"response_params" orm:"column(response_params)" description:"响应参数` Elapsed float64 `json:"elapsed" orm:"column(elapsed)" description:"调用耗时,单位:秒"` AddTime int64 `json:"add_time" orm:"column(add_time)" description:"生成时间戳"` } func (p *CallbackIn) DbName() string { return "db_gd_access_log" } func (p *CallbackIn) TableName() string { return "t_gd_callback_in_log" } func (p CallbackIn) String() string { vals, _ := json.Marshal(p) return string(vals) } func (p *CallbackIn) Create(db orm.Ormer) (int64, error) { return db.Insert(p) } func (p *CallbackIn) Update(db orm.Ormer, filters, values map[string]interface{}) (int64, error) { if len(values) == 0 { return 0, fmt.Errorf("update nil values") } qs := db.QueryTable(p.TableName()) for k, v := range filters { qs = qs.Filter(k, v) } return qs.Update(values) } func (p *CallbackIn) Fetch(db orm.Ormer, filters map[string]interface{}, fields ...string) error { qs := db.QueryTable(p.TableName()) for k, v := range filters { qs = qs.Filter(k, v) } return qs.One(p, fields...) }