business_sys_interaction_log.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package index
  2. import (
  3. "eta/eta_bridge/global"
  4. "time"
  5. )
  6. // BusinessSysInteractionLog 商家系统交互记录表
  7. type BusinessSysInteractionLog struct {
  8. ID uint32 `gorm:"primaryKey;column:id;type:int(10) unsigned;not null" json:"-"`
  9. InteractionKey string `gorm:"unique;column:interaction_key;type:varchar(128);not null;default:''" json:"interactionKey"` // 记录Key
  10. InteractionVal string `gorm:"column:interaction_val;type:text;default:null" json:"interactionVal"` // 记录值
  11. Remark string `gorm:"column:remark;type:varchar(128);not null;default:''" json:"remark"` // 备注
  12. ModifyTime time.Time `gorm:"column:modify_time;type:datetime;default:null" json:"modifyTime"` // 修改日期
  13. CreateTime time.Time `gorm:"column:create_time;type:datetime;default:null" json:"createTime"` // 创建时间
  14. }
  15. // TableName get sql table name.获取数据库表名
  16. func (m *BusinessSysInteractionLog) TableName() string {
  17. return "business_sys_interaction_log"
  18. }
  19. // BusinessSysInteractionLogColumns get sql column name.获取数据库列名
  20. var BusinessSysInteractionLogColumns = struct {
  21. ID string
  22. InteractionKey string
  23. InteractionVal string
  24. Remark string
  25. ModifyTime string
  26. CreateTime string
  27. }{
  28. ID: "id",
  29. InteractionKey: "interaction_key",
  30. InteractionVal: "interaction_val",
  31. Remark: "remark",
  32. ModifyTime: "modify_time",
  33. CreateTime: "create_time",
  34. }
  35. // Create 添加数据
  36. func (m *BusinessSysInteractionLog) Create() (err error) {
  37. err = global.MYSQL["index"].Create(m).Error
  38. return
  39. }
  40. // Update 更新数据
  41. func (m *BusinessSysInteractionLog) Update(cols []string) (err error) {
  42. err = global.MYSQL["index"].Model(m).Select(cols).Updates(m).Error
  43. return
  44. }
  45. var BinlogFileNameKey = "binlog_filename" // binlog文件名
  46. var BinlogPositionKey = "binlog_binlog_position" // binlog位置
  47. // GetBusinessSysInteractionLogByKey 根据记录key获取数据
  48. func GetBusinessSysInteractionLogByKey(key string) (item *BusinessSysInteractionLog, err error) {
  49. err = global.MYSQL["index"].Where("interaction_key = ?", key).First(&item).Error
  50. return
  51. }