business_sys_interaction_log.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package data_manage
  2. import (
  3. "eta_gn/eta_task/global"
  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. ID uint32 `gorm:"primaryKey;column:id;type:int(10) unsigned;not null" json:"-"`
  10. InteractionKey string `gorm:"unique;column:interaction_key;type:varchar(128);not null;default:''" json:"interactionKey"` // 记录Key
  11. InteractionVal string `gorm:"column:interaction_val;type:text;default:null" json:"interactionVal"` // 记录值
  12. Remark string `gorm:"column:remark;type:varchar(128);not null;default:''" json:"remark"` // 备注
  13. ModifyTime time.Time `gorm:"column:modify_time;type:datetime;default:null" json:"modifyTime"` // 修改日期
  14. CreateTime time.Time `gorm:"column:create_time;type:datetime;default:null" json:"createTime"` // 创建时间
  15. }
  16. // TableName get sql table name.获取数据库表名
  17. func (m *BusinessSysInteractionLog) TableName() string {
  18. return "business_sys_interaction_log"
  19. }
  20. // BusinessSysInteractionLogColumns get sql column name.获取数据库列名
  21. var BusinessSysInteractionLogColumns = struct {
  22. ID string
  23. InteractionKey string
  24. InteractionVal string
  25. Remark string
  26. ModifyTime string
  27. CreateTime string
  28. }{
  29. ID: "id",
  30. InteractionKey: "interaction_key",
  31. InteractionVal: "interaction_val",
  32. Remark: "remark",
  33. ModifyTime: "modify_time",
  34. CreateTime: "create_time",
  35. }
  36. // Create 添加数据
  37. func (m *BusinessSysInteractionLog) Create() (err error) {
  38. //o := orm.NewOrm()
  39. //id, err := o.Insert(m)
  40. //if err != nil {
  41. // return
  42. //}
  43. //m.ID = uint32(id)
  44. err = global.DEFAULT_DmSQL.Create(m).Error
  45. if err != nil {
  46. return
  47. }
  48. return
  49. }
  50. // Update 更新数据
  51. func (m *BusinessSysInteractionLog) Update(cols []string) (err error) {
  52. //o := orm.NewOrm()
  53. //_, err = o.Update(m, cols...)
  54. err = global.DEFAULT_DmSQL.Select(cols).Updates(m).Error
  55. return
  56. }
  57. var BinlogFileNameKey = "binlog_filename" // binlog文件名
  58. var BinlogPositionKey = "binlog_binlog_position" // binlog位置
  59. var CrmIndexLastUpdateTime = "crm_index_update_time" // crm数据
  60. // GetBusinessSysInteractionLogByKey 根据记录key获取数据
  61. func GetBusinessSysInteractionLogByKey(key string) (item *BusinessSysInteractionLog, err error) {
  62. //o := orm.NewOrm()
  63. sql := `SELECT * FROM business_sys_interaction_log WHERE 1=1 AND interaction_key = ? LIMIT 1`
  64. //err = o.Raw(sql, key).QueryRow(&item)
  65. err = global.DEFAULT_DmSQL.Raw(sql, key).First(&item).Error
  66. return
  67. }