mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-10-31 08:29:33 +08:00 
			
		
		
		
	* fix: GroupApplicationAcceptedNotification * fix: GroupApplicationAcceptedNotification * fix: NotificationUserInfoUpdate * cicd: robot automated Change * fix: component * fix: getConversationInfo * feat: cron task * feat: cron task * feat: cron task * feat: cron task * feat: cron task * fix: minio config url recognition error * update gomake version * update gomake version * fix: seq conversion bug * fix: redis pipe exec * fix: ImportFriends * fix: A large number of logs keysAndValues length is not even * feat: mark read aggregate write * feat: online status supports redis cluster * feat: online status supports redis cluster * feat: online status supports redis cluster * merge * merge * read seq is written to mongo * read seq is written to mongo * fix: invitation to join group notification * fix: friend op_user_id * feat: optimizing asynchronous context * feat: optimizing memamq size * feat: add GetSeqMessage * feat: GroupApplicationAgreeMemberEnterNotification * feat: GroupApplicationAgreeMemberEnterNotification * feat: go.mod * feat: go.mod * feat: join group notification and get seq * feat: join group notification and get seq * feat: avoid pulling messages from sessions with a large number of max seq values of 0 * feat: API supports gzip * go.mod * fix: nil pointer error on close * fix: listen error * fix: listen error * update go.mod * feat: add log * fix: token parse token value * fix: GetMsgBySeqs boundary issues * fix: sn_ not sort * fix: sn_ not sort * fix: sn_ not sort * fix: jssdk add * fix: jssdk support * fix: jssdk support * fix: jssdk support * fix: the message I sent is not set to read seq in mongodb * fix: cannot modify group member avatars * fix: MemberEnterNotification * fix: MemberEnterNotification * fix: MsgData status * feat: add ApplicationVersion --------- Co-authored-by: withchao <withchao@users.noreply.github.com>
		
			
				
	
	
		
			70 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package controller
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache"
 | |
| 	"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
 | |
| 	"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
 | |
| 	"github.com/openimsdk/tools/db/pagination"
 | |
| 	"go.mongodb.org/mongo-driver/bson/primitive"
 | |
| )
 | |
| 
 | |
| type ApplicationDatabase interface {
 | |
| 	LatestVersion(ctx context.Context, platform string) (*model.Application, error)
 | |
| 	AddVersion(ctx context.Context, val *model.Application) error
 | |
| 	UpdateVersion(ctx context.Context, id primitive.ObjectID, update map[string]any) error
 | |
| 	DeleteVersion(ctx context.Context, id []primitive.ObjectID) error
 | |
| 	PageVersion(ctx context.Context, platforms []string, page pagination.Pagination) (int64, []*model.Application, error)
 | |
| }
 | |
| 
 | |
| func NewApplicationDatabase(db database.Application, cache cache.ApplicationCache) ApplicationDatabase {
 | |
| 	return &applicationDatabase{db: db, cache: cache}
 | |
| }
 | |
| 
 | |
| type applicationDatabase struct {
 | |
| 	db    database.Application
 | |
| 	cache cache.ApplicationCache
 | |
| }
 | |
| 
 | |
| func (a *applicationDatabase) LatestVersion(ctx context.Context, platform string) (*model.Application, error) {
 | |
| 	return a.cache.LatestVersion(ctx, platform)
 | |
| }
 | |
| 
 | |
| func (a *applicationDatabase) AddVersion(ctx context.Context, val *model.Application) error {
 | |
| 	if err := a.db.AddVersion(ctx, val); err != nil {
 | |
| 		return err
 | |
| 	}
 | |
| 	return a.cache.DeleteCache(ctx, []string{val.Platform})
 | |
| }
 | |
| 
 | |
| func (a *applicationDatabase) UpdateVersion(ctx context.Context, id primitive.ObjectID, update map[string]any) error {
 | |
| 	platforms, err := a.db.FindPlatform(ctx, []primitive.ObjectID{id})
 | |
| 	if err != nil {
 | |
| 		return err
 | |
| 	}
 | |
| 	if err := a.db.UpdateVersion(ctx, id, update); err != nil {
 | |
| 		return err
 | |
| 	}
 | |
| 	if p, ok := update["platform"]; ok {
 | |
| 		if val, ok := p.(string); ok {
 | |
| 			platforms = append(platforms, val)
 | |
| 		}
 | |
| 	}
 | |
| 	return a.cache.DeleteCache(ctx, platforms)
 | |
| }
 | |
| 
 | |
| func (a *applicationDatabase) DeleteVersion(ctx context.Context, id []primitive.ObjectID) error {
 | |
| 	platforms, err := a.db.FindPlatform(ctx, id)
 | |
| 	if err != nil {
 | |
| 		return err
 | |
| 	}
 | |
| 	if err := a.db.DeleteVersion(ctx, id); err != nil {
 | |
| 		return err
 | |
| 	}
 | |
| 	return a.cache.DeleteCache(ctx, platforms)
 | |
| }
 | |
| 
 | |
| func (a *applicationDatabase) PageVersion(ctx context.Context, platforms []string, page pagination.Pagination) (int64, []*model.Application, error) {
 | |
| 	return a.db.PageVersion(ctx, platforms, page)
 | |
| }
 |