groupInfo.go 1.6 KB
Newer Older
chenweijian's avatar
chenweijian committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
package group_m

import (
	"gorm.io/gorm"
	"hilo-user/_const/enum/group_e"
	"hilo-user/domain"
	"hilo-user/myerr/bizerr"
	"time"
)

type GroupInfo struct {
	Id             int64
	ImGroupId      string
	TxGroupId      string
	Type           uint16
	Code           string
	OriginCode     string
	Owner          uint64
	Name           string
	Introduction   string
	Notification   string
	FaceUrl        string
	Country        string
	ChannelId      string
	Password       string
	EntryLevel     uint32 // obsolete
	MicOn          bool
	LoadHistory    bool
	ThemeId        int16
	MicNumType     group_e.GroupMicNumType
	TouristMic     uint8     // 游客是否能上麦1是2否
	TouristSendMsg uint8     // 游客是否能发消息1是2否
	TouristSendPic uint8     // 游客是否能发图片1是2否
	MemberFee      uint64    // 加入会员需要黄钻数
	CreatedTime    time.Time `gorm:"->"`
	UpdatedTime    time.Time `gorm:"->"`
}

func GetGroupInfo(model *domain.Model, groupId string) (*GroupInfo, error) {
	if len(groupId) <= 0 {
		return nil, bizerr.GroupNotFound
	}
	r := GroupInfo{}
	err := model.Db.Where(&GroupInfo{ImGroupId: groupId}).First(&r).Error
	if err != nil {
		if err == gorm.ErrRecordNotFound {
			return nil, nil
		} else {
			return nil, err
		}
	}
	return &r, nil
}

func GetGroupInfoByOwner(model *domain.Model, userId uint64) (*GroupInfo, error) {
	if userId <= 0 {
		return nil, bizerr.GroupNotFound
	}
	r := GroupInfo{}
	err := model.Db.Where(&GroupInfo{Owner: userId}).First(&r).Error
	if err != nil {
		if err == gorm.ErrRecordNotFound {
			return nil, nil
		} else {
			return nil, err
		}
	}
	return &r, nil
}