wechat_group_helper_relation.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package models
  2. import (
  3. "context"
  4. "eta/eta_menu_sync/global"
  5. )
  6. // WechatGroupHelperRelation 微信群与小助手关系表
  7. type WechatGroupHelperRelation struct {
  8. WechatGroupId int `gorm:"primaryKey;column:wechat_group_id;autoIncrement:false;" description:"微信群id"`
  9. WechatHelperId int `gorm:"primaryKey;column:wechat_helper_id;autoIncrement:false;" description:"微信小助手id"`
  10. }
  11. func (m *WechatGroupHelperRelation) TableName() string {
  12. return "wechat_group_helper_relation"
  13. }
  14. // Create 添加记录
  15. func (m *WechatGroupHelperRelation) Create() (err error) {
  16. err = global.DEFAULT_MYSQL.Create(m).Error
  17. return
  18. }
  19. // GetListByHelperId 通过小助手id获取所有关联的群信息
  20. func (m *WechatGroupHelperRelation) GetListByHelperId(helperId int) (items []*WechatGroupHelperRelation, err error) {
  21. err = global.DEFAULT_MYSQL.WithContext(context.TODO()).Model(m).
  22. Where("wechat_helper_id = ? ", helperId).Find(&items).Error
  23. return
  24. }
  25. // CreateList 批量添加入库
  26. func (m *WechatGroupHelperRelation) CreateList(list []WechatGroupHelperRelation) (err error) {
  27. err = global.DEFAULT_MYSQL.Create(list).Error
  28. return
  29. }