business_sys_interaction_log.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // BusinessSysInteractionLog 商家系统交互记录表
  7. type BusinessSysInteractionLog struct {
  8. ID uint32 `orm:"column(id);pk" 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. o := orm.NewOrm()
  38. id, err := o.Insert(m)
  39. if err != nil {
  40. return
  41. }
  42. m.ID = uint32(id)
  43. return
  44. }
  45. // Update 更新数据
  46. func (m *BusinessSysInteractionLog) Update(cols []string) (err error) {
  47. o := orm.NewOrm()
  48. _, err = o.Update(m, cols...)
  49. return
  50. }
  51. var BinlogFileNameKey = "binlog_filename" // binlog文件名
  52. var BinlogPositionKey = "binlog_binlog_position" // binlog位置
  53. var CrmIndexLastUpdateTime = "crm_index_update_time" // crm数据
  54. // GetBusinessSysInteractionLogByKey 根据记录key获取数据
  55. func GetBusinessSysInteractionLogByKey(key string) (item *BusinessSysInteractionLog, err error) {
  56. o := orm.NewOrm()
  57. sql := `SELECT * FROM business_sys_interaction_log WHERE 1=1 AND interaction_key = ? LIMIT 1`
  58. err = o.Raw(sql, key).QueryRow(&item)
  59. return
  60. }