mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-03 00:25:59 +08:00
style: add format
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
@@ -5,9 +5,10 @@ import (
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/ormutil"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type GroupRequestGorm struct {
|
||||
@@ -29,25 +30,69 @@ func (g *GroupRequestGorm) Create(ctx context.Context, groupRequests []*relation
|
||||
}
|
||||
|
||||
func (g *GroupRequestGorm) Delete(ctx context.Context, groupID string, userID string) (err error) {
|
||||
return utils.Wrap(g.DB.WithContext(ctx).Where("group_id = ? and user_id = ? ", groupID, userID).Delete(&relation.GroupRequestModel{}).Error, utils.GetSelfFuncName())
|
||||
return utils.Wrap(
|
||||
g.DB.WithContext(ctx).
|
||||
Where("group_id = ? and user_id = ? ", groupID, userID).
|
||||
Delete(&relation.GroupRequestModel{}).
|
||||
Error,
|
||||
utils.GetSelfFuncName(),
|
||||
)
|
||||
}
|
||||
|
||||
func (g *GroupRequestGorm) UpdateHandler(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32) (err error) {
|
||||
return utils.Wrap(g.DB.WithContext(ctx).Model(&relation.GroupRequestModel{}).Where("group_id = ? and user_id = ? ", groupID, userID).Updates(map[string]any{
|
||||
"handle_msg": handledMsg,
|
||||
"handle_result": handleResult,
|
||||
}).Error, utils.GetSelfFuncName())
|
||||
func (g *GroupRequestGorm) UpdateHandler(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
userID string,
|
||||
handledMsg string,
|
||||
handleResult int32,
|
||||
) (err error) {
|
||||
return utils.Wrap(
|
||||
g.DB.WithContext(ctx).
|
||||
Model(&relation.GroupRequestModel{}).
|
||||
Where("group_id = ? and user_id = ? ", groupID, userID).
|
||||
Updates(map[string]any{
|
||||
"handle_msg": handledMsg,
|
||||
"handle_result": handleResult,
|
||||
}).
|
||||
Error,
|
||||
utils.GetSelfFuncName(),
|
||||
)
|
||||
}
|
||||
|
||||
func (g *GroupRequestGorm) Take(ctx context.Context, groupID string, userID string) (groupRequest *relation.GroupRequestModel, err error) {
|
||||
func (g *GroupRequestGorm) Take(
|
||||
ctx context.Context,
|
||||
groupID string,
|
||||
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())
|
||||
return groupRequest, utils.Wrap(
|
||||
g.DB.WithContext(ctx).Where("group_id = ? and user_id = ? ", groupID, userID).Take(groupRequest).Error,
|
||||
utils.GetSelfFuncName(),
|
||||
)
|
||||
}
|
||||
|
||||
func (g *GroupRequestGorm) Page(ctx context.Context, userID string, pageNumber, showNumber int32) (total uint32, groups []*relation.GroupRequestModel, err error) {
|
||||
return ormutil.GormSearch[relation.GroupRequestModel](g.DB.WithContext(ctx).Where("user_id = ?", userID), nil, "", pageNumber, showNumber)
|
||||
func (g *GroupRequestGorm) Page(
|
||||
ctx context.Context,
|
||||
userID string,
|
||||
pageNumber, showNumber int32,
|
||||
) (total uint32, groups []*relation.GroupRequestModel, err error) {
|
||||
return ormutil.GormSearch[relation.GroupRequestModel](
|
||||
g.DB.WithContext(ctx).Where("user_id = ?", userID),
|
||||
nil,
|
||||
"",
|
||||
pageNumber,
|
||||
showNumber,
|
||||
)
|
||||
}
|
||||
|
||||
func (g *GroupRequestGorm) PageGroup(ctx context.Context, groupIDs []string, pageNumber, showNumber int32) (total uint32, groups []*relation.GroupRequestModel, err error) {
|
||||
return ormutil.GormPage[relation.GroupRequestModel](g.DB.WithContext(ctx).Where("group_id in ?", groupIDs), pageNumber, showNumber)
|
||||
func (g *GroupRequestGorm) PageGroup(
|
||||
ctx context.Context,
|
||||
groupIDs []string,
|
||||
pageNumber, showNumber int32,
|
||||
) (total uint32, groups []*relation.GroupRequestModel, err error) {
|
||||
return ormutil.GormPage[relation.GroupRequestModel](
|
||||
g.DB.WithContext(ctx).Where("group_id in ?", groupIDs),
|
||||
pageNumber,
|
||||
showNumber,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user