golang-im聊天
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

36 lines
685 B

  1. package repo
  2. import (
  3. "gim/internal/logic/domain/group/model"
  4. "gim/pkg/db"
  5. "gim/pkg/gerrors"
  6. "github.com/jinzhu/gorm"
  7. )
  8. type groupDao struct{}
  9. var GroupDao = new(groupDao)
  10. // Get 获取群组信息
  11. func (*groupDao) Get(groupId int64) (*model.Group, error) {
  12. var group = model.Group{Id: groupId}
  13. err := db.DB.First(&group).Error
  14. if err != nil && err != gorm.ErrRecordNotFound {
  15. return nil, gerrors.WrapError(err)
  16. }
  17. if err == gorm.ErrRecordNotFound {
  18. return nil, nil
  19. }
  20. return &group, nil
  21. }
  22. // Save 插入一条群组
  23. func (*groupDao) Save(group *model.Group) error {
  24. err := db.DB.Save(&group).Error
  25. if err != nil {
  26. return gerrors.WrapError(err)
  27. }
  28. return nil
  29. }