callback_out.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package dbmodel
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/astaxie/beego/orm"
  6. )
  7. type CallbackOut struct {
  8. Id int `json:"id" orm:"column(id);auto" description:"增长id"`
  9. ServiceType int `json:"service_type" orm:"column(service_type)" description:"业务类型,101:维保记录"`
  10. MerchantId int `json:"merchant_id" orm:"column(merchant_id)" description:"下游商户id"`
  11. ObjectId string `json:"object_id" orm:"column(object_id)" description:"关联的对象id,如:order_no"`
  12. RequestCode int `json:"request_code" orm:"column(request_code)" description:"请求结果码,同request_params.code,0表示生成报告成功`
  13. RequestParams string `json:"request_params" orm:"column(request_params)" description:"请求参数`
  14. ResponseParams string `json:"response_params" orm:"column(response_params)" description:"响应参数`
  15. Elapsed float64 `json:"elapsed" orm:"column(elapsed)" description:"调用耗时,单位:秒"`
  16. AddTime int64 `json:"add_time" orm:"column(add_time)" description:"生成时间戳"`
  17. IsReuse int `json:"is_reuse" orm:"column(is_reuse)" description:"是否复用,1:是,0:否"`
  18. Search string `json:"search" orm:"column(search)" description:"搜索条件,维保业务时的值代表VIN码"`
  19. }
  20. func (p *CallbackOut) DbName() string {
  21. return "db_gd_service"
  22. }
  23. func (p *CallbackOut) TableName() string {
  24. return "t_gd_callback_out_log"
  25. }
  26. func (p CallbackOut) String() string {
  27. vals, _ := json.Marshal(p)
  28. return string(vals)
  29. }
  30. func (p *CallbackOut) Create(db orm.Ormer) (int64, error) {
  31. return db.Insert(p)
  32. }
  33. func (p *CallbackOut) Update(db orm.Ormer, filters, values map[string]interface{}) (int64, error) {
  34. if len(values) == 0 {
  35. return 0, fmt.Errorf("update nil values")
  36. }
  37. qs := db.QueryTable(p.TableName())
  38. for k, v := range filters {
  39. qs = qs.Filter(k, v)
  40. }
  41. return qs.Update(values)
  42. }
  43. func (p *CallbackOut) Fetch(db orm.Ormer, filters map[string]interface{}, fields ...string) error {
  44. qs := db.QueryTable(p.TableName())
  45. for k, v := range filters {
  46. qs = qs.Filter(k, v)
  47. }
  48. return qs.One(p, fields...)
  49. }