fix: reset branch. (#1277)

* fix: to start im or chat, ZooKeeper must be started first.

* fix: msg gateway start output err info

Signed-off-by: Gordon <1432970085@qq.com>

* fix: msg gateway start output err info

Signed-off-by: Gordon <1432970085@qq.com>

* chore: package path changes

Signed-off-by: withchao <993506633@qq.com>

* fix: go mod update

Signed-off-by: Gordon <1432970085@qq.com>

* fix: token update

Signed-off-by: Gordon <1432970085@qq.com>

* chore: package path changes

Signed-off-by: withchao <993506633@qq.com>

* chore: package path changes

Signed-off-by: withchao <993506633@qq.com>

* fix: token update

Signed-off-by: Gordon <1432970085@qq.com>

* fix: token update

Signed-off-by: Gordon <1432970085@qq.com>

* fix: token update

Signed-off-by: Gordon <1432970085@qq.com>

* fix: token update

Signed-off-by: Gordon <1432970085@qq.com>

* fix: token update

Signed-off-by: Gordon <1432970085@qq.com>

* fix: token update

Signed-off-by: Gordon <1432970085@qq.com>

* fix: get all userID

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: msggateway add online status call

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* refactor: log change

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* refactor: log change

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* chore: network mode change

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* cicd: robot automated Change

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* cicd: robot automated Change

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat: add api of get server time

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* feat: remove go work sum

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix: pull message add isRead field

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: check msg-transfer script

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: start don't kill old process

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix: check component

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: pull message set isRead only message come from single.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix: multiple gateway kick user each other.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: multiple gateway kick user each other.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: multiple gateway kick user each other.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: multiple gateway kick user each other.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: multiple gateway kick user each other.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: multiple gateway kick user each other.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix: multiple gateway kick user each other.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: add ex field to update group info.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

* cicd: robot automated Change

* refactor: change project module name.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* refactor: change project module name.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* refactor: change project module name.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

* test: for pressure test.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* test: for pressure test.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* test: for pressure test.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* test: message log.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

* fxi: component check output valid info.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fxi: component check output valid info.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* test: send message test log.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

* cicd: robot automated Change

* test: remove info log.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* feat: api of send message add sendTime field.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: add callback for update user's info.

* cicd: robot automated Change

* fix: change callback command name.

* cicd: robot automated Change

* fix: single chat unread status change.

* fix: single chat unread status change.

* fix: single chat unread status change.

* fix: user status change.

* cicd: robot automated Change

* fix: user status change.

* fix: user status change.

* fix: user status change.

* cicd: robot automated Change

* fix: ws close when user logout.

* fix: remove repeat platform on online status.

* cicd: robot automated Change

* fix: api send messages for notification conversation .

* fix: api send messages for notification conversation .

* fix: api send messages for notification conversation .

* fix: api send messages for notification conversation .

* fix: api send messages for notification conversation .

* fix: api send messages for notification conversation.

* fix: api send messages for notification conversation.

* fix: api send messages for notification conversation.

* fix: api send messages for notification conversation.

* fix: api send messages for notification conversation.

* fix: api send messages for notification conversation.

* re: remove router of unsubscribeStatus.

* re: remove router of unsubscribeStatus.

* re: remove router of unsubscribeStatus.

* re: remove router of unsubscribeStatus.

* fix: reset branch

* fix: not support redis cluster. CROSSSLOT Keys in request don't hash to the same slot

* fix: update user.FaceURL do not trigger GroupMemberInfoSetNotification

* cicd: robot automated Change

* fix: api send messages for notification conversation.

* fix: api send messages for notification conversation.

---------

Signed-off-by: Gordon <1432970085@qq.com>
Signed-off-by: withchao <993506633@qq.com>
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: withchao <993506633@qq.com>
Co-authored-by: Xinwei Xiong <3293172751NSS@gmail.com>
Co-authored-by: FGadvancer <FGadvancer@users.noreply.github.com>
Co-authored-by: withchao <withchao@users.noreply.github.com>
This commit is contained in:
Gordon
2023-10-24 20:28:22 +08:00
committed by GitHub
parent 8a13017665
commit cb0394392b
91 changed files with 781 additions and 1444 deletions
+1 -4
View File
@@ -63,11 +63,10 @@ func (b *BlackGorm) Find(
ctx context.Context,
blacks []*relation.BlackModel,
) (blackList []*relation.BlackModel, err error) {
where := make([][]interface{}, 0, len(blacks))
var where [][]interface{}
for _, black := range blacks {
where = append(where, []interface{}{black.OwnerUserID, black.BlockUserID})
}
return blackList, utils.Wrap(
b.db(ctx).Where("(owner_user_id, block_user_id) in ?", where).Find(&blackList).Error,
"",
@@ -76,7 +75,6 @@ func (b *BlackGorm) Find(
func (b *BlackGorm) Take(ctx context.Context, ownerUserID, blockUserID string) (black *relation.BlackModel, err error) {
black = &relation.BlackModel{}
return black, utils.Wrap(
b.db(ctx).Where("owner_user_id = ? and block_user_id = ?", ownerUserID, blockUserID).Take(black).Error,
"",
@@ -98,7 +96,6 @@ func (b *BlackGorm) FindOwnerBlacks(
showNumber,
)
total = int64(totalUint32)
return
}
+1 -7
View File
@@ -15,8 +15,6 @@
package relation
import (
//nolint:staticcheck //tofix: SA1019: "github.com/golang/protobuf/jsonpb" is deprecated: Use the "google.golang.org/protobuf/encoding/protojson" package instead.
"github.com/golang/protobuf/jsonpb"
"github.com/jinzhu/copier"
"google.golang.org/protobuf/proto"
@@ -40,10 +38,7 @@ func NewChatLogGorm(db *gorm.DB) relation.ChatLogModelInterface {
func (c *ChatLogGorm) Create(msg *pbmsg.MsgDataToMQ) error {
chatLog := new(relation.ChatLogModel)
err := copier.Copy(chatLog, msg.MsgData)
if err != nil {
return err
}
copier.Copy(chatLog, msg.MsgData)
switch msg.MsgData.SessionType {
case constant.GroupChatType, constant.SuperGroupChatType:
chatLog.RecvID = msg.MsgData.GroupID
@@ -64,6 +59,5 @@ func (c *ChatLogGorm) Create(msg *pbmsg.MsgDataToMQ) error {
}
chatLog.CreateTime = utils.UnixMillSecondToTime(msg.MsgData.CreateTime)
chatLog.SendTime = utils.UnixMillSecondToTime(msg.MsgData.SendTime)
return c.DB.Create(chatLog).Error
}
@@ -54,7 +54,6 @@ func (c *ConversationGorm) UpdateByMap(
args map[string]interface{},
) (rows int64, err error) {
result := c.db(ctx).Where("owner_user_id IN (?) and conversation_id=?", userIDList, conversationID).Updates(args)
return result.RowsAffected, utils.Wrap(result.Error, "")
}
@@ -80,7 +79,6 @@ func (c *ConversationGorm) Find(
Error,
"",
)
return conversations, err
}
@@ -89,7 +87,6 @@ func (c *ConversationGorm) Take(
userID, conversationID string,
) (conversation *relation.ConversationModel, err error) {
cc := &relation.ConversationModel{}
return cc, utils.Wrap(
c.db(ctx).Where("conversation_id = ? And owner_user_id = ?", conversationID, userID).Take(cc).Error,
"",
@@ -172,7 +169,6 @@ func (c *ConversationGorm) GetUserRecvMsgOpt(
ownerUserID, conversationID string,
) (opt int, err error) {
var conversation relation.ConversationModel
return int(
conversation.RecvMsgOpt,
), utils.Wrap(
@@ -223,7 +219,6 @@ func (c *ConversationGorm) GetConversationIDsNeedDestruct(
func (c *ConversationGorm) GetConversationRecvMsgOpt(ctx context.Context, userID string, conversationID string) (int32, error) {
var recvMsgOpt int32
return recvMsgOpt, errs.Wrap(
c.db(ctx).
Model(&relation.ConversationModel{}).
@@ -235,7 +230,6 @@ func (c *ConversationGorm) GetConversationRecvMsgOpt(ctx context.Context, userID
func (c *ConversationGorm) GetConversationNotReceiveMessageUserIDs(ctx context.Context, conversationID string) ([]string, error) {
var userIDs []string
return userIDs, errs.Wrap(
c.db(ctx).
Model(&relation.ConversationModel{}).
-5
View File
@@ -50,7 +50,6 @@ func (f *FriendGorm) Delete(ctx context.Context, ownerUserID string, friendUserI
Error,
"",
)
return err
}
@@ -85,7 +84,6 @@ func (f *FriendGorm) UpdateRemark(ctx context.Context, ownerUserID, friendUserID
}
m := make(map[string]interface{}, 1)
m["remark"] = ""
return utils.Wrap(f.db(ctx).Where("owner_user_id = ?", ownerUserID).Updates(m).Error, "")
}
@@ -95,7 +93,6 @@ func (f *FriendGorm) Take(
ownerUserID, friendUserID string,
) (friend *relation.FriendModel, err error) {
friend = &relation.FriendModel{}
return friend, utils.Wrap(
f.db(ctx).Where("owner_user_id = ? and friend_user_id", ownerUserID, friendUserID).Take(friend).Error,
"",
@@ -159,7 +156,6 @@ func (f *FriendGorm) FindOwnerFriends(
Error,
"",
)
return
}
@@ -182,7 +178,6 @@ func (f *FriendGorm) FindInWhoseFriends(
Error,
"",
)
return
}
@@ -74,7 +74,6 @@ func (f *FriendRequestGorm) Update(ctx context.Context, friendRequest *relation.
fr2 := *friendRequest
fr2.FromUserID = ""
fr2.ToUserID = ""
return utils.Wrap(
f.db(ctx).
Where("from_user_id = ? AND to_user_id =?", friendRequest.FromUserID, friendRequest.ToUserID).
@@ -94,7 +93,6 @@ func (f *FriendRequestGorm) Find(
f.db(ctx).Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Find(friendRequest).Error,
"",
)
return friendRequest, err
}
@@ -107,7 +105,6 @@ func (f *FriendRequestGorm) Take(
f.db(ctx).Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Take(friendRequest).Error,
"",
)
return friendRequest, err
}
@@ -130,7 +127,6 @@ func (f *FriendRequestGorm) FindToUserID(
Error,
"",
)
return
}
@@ -153,7 +149,6 @@ func (f *FriendRequestGorm) FindFromUserID(
Error,
"",
)
return
}
@@ -165,6 +160,5 @@ func (f *FriendRequestGorm) FindBothFriendRequests(ctx context.Context, fromUser
Error,
"",
)
return
}
@@ -68,7 +68,6 @@ func (g *GroupMemberGorm) UpdateRoleLevel(
db := g.db(ctx).Where("group_id = ? and user_id = ?", groupID, userID).Updates(map[string]any{
"role_level": roleLevel,
})
return db.RowsAffected, utils.Wrap(db.Error, "")
}
@@ -88,7 +87,6 @@ func (g *GroupMemberGorm) Find(
if len(roleLevels) > 0 {
db = db.Where("role_level in (?)", roleLevels)
}
return groupMembers, utils.Wrap(db.Find(&groupMembers).Error, "")
}
@@ -98,7 +96,6 @@ func (g *GroupMemberGorm) Take(
userID string,
) (groupMember *relation.GroupMemberModel, err error) {
groupMember = &relation.GroupMemberModel{}
return groupMember, utils.Wrap(
g.db(ctx).Where("group_id = ? and user_id = ?", groupID, userID).Take(groupMember).Error,
"",
@@ -110,7 +107,6 @@ func (g *GroupMemberGorm) TakeOwner(
groupID string,
) (groupMember *relation.GroupMemberModel, err error) {
groupMember = &relation.GroupMemberModel{}
return groupMember, utils.Wrap(
g.db(ctx).Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error,
"",
@@ -129,7 +125,6 @@ func (g *GroupMemberGorm) SearchMember(
ormutil.GormIn(&db, "group_id", groupIDs)
ormutil.GormIn(&db, "user_id", userIDs)
ormutil.GormIn(&db, "role_level", roleLevels)
return ormutil.GormSearch[relation.GroupMemberModel](db, []string{"nickname"}, keyword, pageNumber, showNumber)
}
@@ -157,7 +152,6 @@ func (g *GroupMemberGorm) FindJoinUserID(
groupUsers[item.GroupID] = append(v, item.UserID)
}
}
return groupUsers, nil
}
@@ -188,7 +182,6 @@ func (g *GroupMemberGorm) FindUsersJoinedGroupID(ctx context.Context, userIDs []
result[groupMember.UserID] = append(v, groupMember.GroupID)
}
}
return result, nil
}
-4
View File
@@ -61,14 +61,12 @@ func (g *GroupGorm) Find(ctx context.Context, groupIDs []string) (groups []*rela
func (g *GroupGorm) Take(ctx context.Context, groupID string) (group *relation.GroupModel, err error) {
group = &relation.GroupModel{}
return group, utils.Wrap(g.DB.Where("group_id = ?", groupID).Take(group).Error, "")
}
func (g *GroupGorm) Search(ctx context.Context, keyword string, pageNumber, showNumber int32) (total uint32, groups []*relation.GroupModel, err error) {
db := g.DB
db = db.WithContext(ctx).Where("status!=?", constant.GroupStatusDismissed)
return ormutil.GormSearch[relation.GroupModel](db, []string{"name"}, keyword, pageNumber, showNumber)
}
@@ -84,7 +82,6 @@ func (g *GroupGorm) CountTotal(ctx context.Context, before *time.Time) (count in
if err := db.Count(&count).Error; err != nil {
return 0, err
}
return count, nil
}
@@ -101,7 +98,6 @@ func (g *GroupGorm) CountRangeEverydayTotal(ctx context.Context, start time.Time
for _, r := range res {
v[r.Date.Format("2006-01-02")] = r.Count
}
return v, nil
}
@@ -80,7 +80,6 @@ func (g *GroupRequestGorm) Take(
userID string,
) (groupRequest *relation.GroupRequestModel, err error) {
groupRequest = &relation.GroupRequestModel{}
return groupRequest, utils.Wrap(
g.DB.WithContext(ctx).Where("group_id = ? and user_id = ? ", groupID, userID).Take(groupRequest).Error,
utils.GetSelfFuncName(),
@@ -115,6 +114,5 @@ func (g *GroupRequestGorm) PageGroup(
func (g *GroupRequestGorm) FindGroupRequests(ctx context.Context, groupID string, userIDs []string) (total int64, groupRequests []*relation.GroupRequestModel, err error) {
err = g.DB.WithContext(ctx).Where("group_id = ? and user_id in ?", groupID, userIDs).Find(&groupRequests).Error
return int64(len(groupRequests)), groupRequests, utils.Wrap(err, utils.GetSelfFuncName())
}
+1 -8
View File
@@ -25,7 +25,6 @@ func (l *LogGorm) Search(ctx context.Context, keyword string, start time.Time, e
db = l.db.WithContext(ctx).Where("create_time <= ?", end)
}
db = db.Order("create_time desc")
return ormutil.GormSearch[relationtb.Log](db, []string{"user_id"}, keyword, pageNumber, showNumber)
}
@@ -33,7 +32,6 @@ func (l *LogGorm) Delete(ctx context.Context, logIDs []string, userID string) er
if userID == "" {
return errs.Wrap(l.db.WithContext(ctx).Where("log_id in ?", logIDs).Delete(&relationtb.Log{}).Error)
}
return errs.Wrap(l.db.WithContext(ctx).Where("log_id in ? and user_id=?", logIDs, userID).Delete(&relationtb.Log{}).Error)
}
@@ -42,15 +40,10 @@ func (l *LogGorm) Get(ctx context.Context, logIDs []string, userID string) ([]*r
if userID == "" {
return logs, errs.Wrap(l.db.WithContext(ctx).Where("log_id in ?", logIDs).Find(&logs).Error)
}
return logs, errs.Wrap(l.db.WithContext(ctx).Where("log_id in ? and user_id=?", logIDs, userID).Find(&logs).Error)
}
func NewLogGorm(db *gorm.DB) relationtb.LogInterface {
err := db.AutoMigrate(&relationtb.Log{})
if err != nil {
panic(err)
}
db.AutoMigrate(&relationtb.Log{})
return &LogGorm{db: db}
}
-1
View File
@@ -34,6 +34,5 @@ func NewMetaDB(db *gorm.DB, table any) *MetaDB {
func (g *MetaDB) db(ctx context.Context) *gorm.DB {
db := g.DB.WithContext(ctx).Model(g.table)
return db
}
+2 -10
View File
@@ -15,7 +15,6 @@
package relation
import (
"errors"
"fmt"
"time"
@@ -83,7 +82,6 @@ func newMysqlGormDB() (*gorm.DB, error) {
sqlDB.SetConnMaxLifetime(time.Second * time.Duration(config.Config.Mysql.MaxLifeTime))
sqlDB.SetMaxOpenConns(config.Config.Mysql.MaxOpenConn)
sqlDB.SetMaxIdleConns(config.Config.Mysql.MaxIdleConn)
return db, nil
}
@@ -96,13 +94,11 @@ func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) {
if err == nil {
return db, nil
}
var mysqlErr *mysqldriver.MySQLError
if errors.As(err, &mysqlErr) && mysqlErr.Number == 1045 {
if mysqlErr, ok := err.(*mysqldriver.MySQLError); ok && mysqlErr.Number == 1045 {
return nil, err
}
time.Sleep(time.Duration(1) * time.Second)
}
return nil, err
}
@@ -110,7 +106,6 @@ func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) {
func NewGormDB() (*gorm.DB, error) {
specialerror.AddReplace(gorm.ErrRecordNotFound, errs.ErrRecordNotFound)
specialerror.AddErrHandler(replaceDuplicateKey)
return newMysqlGormDB()
}
@@ -118,15 +113,12 @@ func replaceDuplicateKey(err error) errs.CodeError {
if IsMysqlDuplicateKey(err) {
return errs.ErrDuplicateKey
}
return nil
}
func IsMysqlDuplicateKey(err error) bool {
var mysqlErr *mysqldriver.MySQLError
if errors.As(err, &mysqlErr) {
if mysqlErr, ok := err.(*mysqldriver.MySQLError); ok {
return mysqlErr.Number == 1062
}
return false
}
-2
View File
@@ -44,12 +44,10 @@ func (o *ObjectInfoGorm) SetObject(ctx context.Context, obj *relation.ObjectMode
if err := o.DB.WithContext(ctx).Where("name = ?", obj.Name).FirstOrCreate(obj).Error; err != nil {
return errs.Wrap(err)
}
return nil
}
func (o *ObjectInfoGorm) Take(ctx context.Context, name string) (info *relation.ObjectModel, err error) {
info = &relation.ObjectModel{}
return info, errs.Wrap(o.DB.WithContext(ctx).Where("name = ?", name).Take(info).Error)
}
+2 -8
View File
@@ -53,7 +53,6 @@ func (u *UserGorm) Update(ctx context.Context, user *relation.UserModel) (err er
// 获取指定用户信息 不存在,也不返回错误.
func (u *UserGorm) Find(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error) {
err = utils.Wrap(u.db(ctx).Where("user_id in (?)", userIDs).Find(&users).Error, "")
return users, err
}
@@ -61,7 +60,6 @@ func (u *UserGorm) Find(ctx context.Context, userIDs []string) (users []*relatio
func (u *UserGorm) Take(ctx context.Context, userID string) (user *relation.UserModel, err error) {
user = &relation.UserModel{}
err = utils.Wrap(u.db(ctx).Where("user_id = ?", userID).Take(&user).Error, "")
return user, err
}
@@ -83,7 +81,6 @@ func (u *UserGorm) Page(
Error,
"",
)
return
}
@@ -91,14 +88,13 @@ func (u *UserGorm) Page(
func (u *UserGorm) GetAllUserID(ctx context.Context, pageNumber, showNumber int32) (userIDs []string, err error) {
if pageNumber == 0 || showNumber == 0 {
return userIDs, errs.Wrap(u.db(ctx).Pluck("user_id", &userIDs).Error)
} else {
return userIDs, errs.Wrap(u.db(ctx).Limit(int(showNumber)).Offset(int((pageNumber-1)*showNumber)).Pluck("user_id", &userIDs).Error)
}
return userIDs, errs.Wrap(u.db(ctx).Limit(int(showNumber)).Offset(int((pageNumber-1)*showNumber)).Pluck("user_id", &userIDs).Error)
}
func (u *UserGorm) GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error) {
err = u.db(ctx).Model(&relation.UserModel{}).Where("user_id = ?", userID).Pluck("global_recv_msg_opt", &opt).Error
return opt, err
}
@@ -110,7 +106,6 @@ func (u *UserGorm) CountTotal(ctx context.Context, before *time.Time) (count int
if err := db.Count(&count).Error; err != nil {
return 0, err
}
return count, nil
}
@@ -137,6 +132,5 @@ func (u *UserGorm) CountRangeEverydayTotal(
for _, r := range res {
v[r.Date.Format("2006-01-02")] = r.Count
}
return v, nil
}