复制项目
This commit is contained in:
51
pkg/common/db/table/admin/admin.go
Normal file
51
pkg/common/db/table/admin/admin.go
Normal file
@@ -0,0 +1,51 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
)
|
||||
|
||||
// Admin user
|
||||
type Admin struct {
|
||||
Account string `bson:"account"`
|
||||
Password string `bson:"password"`
|
||||
OperationPassword string `bson:"operation_password"`
|
||||
FaceURL string `bson:"face_url"`
|
||||
Nickname string `bson:"nickname"`
|
||||
UserID string `bson:"user_id"`
|
||||
Level int32 `bson:"level"`
|
||||
GoogleAuthKey string `bson:"google_auth_key"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
}
|
||||
|
||||
func (Admin) TableName() string {
|
||||
return "admins"
|
||||
}
|
||||
|
||||
type AdminInterface interface {
|
||||
Create(ctx context.Context, admins []*Admin) error
|
||||
Take(ctx context.Context, account string) (*Admin, error)
|
||||
TakeUserID(ctx context.Context, userID string) (*Admin, error)
|
||||
Update(ctx context.Context, account string, update map[string]any) error
|
||||
ChangePassword(ctx context.Context, userID string, newPassword string) error
|
||||
ChangeOperationPassword(ctx context.Context, userID string, newPassword string) error
|
||||
ClearGoogleAuthKey(ctx context.Context, userID string) error
|
||||
Delete(ctx context.Context, userIDs []string) error
|
||||
Search(ctx context.Context, keyword string, pagination pagination.Pagination) (int64, []*Admin, error)
|
||||
}
|
||||
49
pkg/common/db/table/admin/applet.go
Normal file
49
pkg/common/db/table/admin/applet.go
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Applet struct {
|
||||
ID string `bson:"id"`
|
||||
Name string `bson:"name"`
|
||||
AppID string `bson:"app_id"`
|
||||
Icon string `bson:"icon"`
|
||||
URL string `bson:"url"`
|
||||
MD5 string `bson:"md5"`
|
||||
Size int64 `bson:"size"`
|
||||
Version string `bson:"version"`
|
||||
Priority uint32 `bson:"priority"`
|
||||
Status uint8 `bson:"status"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
}
|
||||
|
||||
func (Applet) TableName() string {
|
||||
return "applets"
|
||||
}
|
||||
|
||||
type AppletInterface interface {
|
||||
Create(ctx context.Context, applets []*Applet) error
|
||||
Del(ctx context.Context, ids []string) error
|
||||
Update(ctx context.Context, id string, data map[string]any) error
|
||||
Take(ctx context.Context, id string) (*Applet, error)
|
||||
Search(ctx context.Context, keyword string, pagination pagination.Pagination) (int64, []*Applet, error)
|
||||
FindOnShelf(ctx context.Context) ([]*Applet, error)
|
||||
FindID(ctx context.Context, ids []string) ([]*Applet, error)
|
||||
}
|
||||
29
pkg/common/db/table/admin/application.go
Normal file
29
pkg/common/db/table/admin/application.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Application struct {
|
||||
ID primitive.ObjectID `bson:"_id"`
|
||||
Platform string `bson:"platform"`
|
||||
Hot bool `bson:"hot"`
|
||||
Version string `bson:"version"`
|
||||
Url string `bson:"url"`
|
||||
Text string `bson:"text"`
|
||||
Force bool `bson:"force"`
|
||||
Latest bool `bson:"latest"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
}
|
||||
|
||||
type ApplicationInterface interface {
|
||||
LatestVersion(ctx context.Context, platform string) (*Application, error)
|
||||
AddVersion(ctx context.Context, val *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, []*Application, error)
|
||||
FindPlatform(ctx context.Context, id []primitive.ObjectID) ([]string, error)
|
||||
}
|
||||
33
pkg/common/db/table/admin/client_config.go
Normal file
33
pkg/common/db/table/admin/client_config.go
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package admin
|
||||
|
||||
import "context"
|
||||
|
||||
// ClientConfig config
|
||||
type ClientConfig struct {
|
||||
Key string `bson:"key"`
|
||||
Value string `bson:"value"`
|
||||
}
|
||||
|
||||
func (ClientConfig) TableName() string {
|
||||
return "client_config"
|
||||
}
|
||||
|
||||
type ClientConfigInterface interface {
|
||||
Set(ctx context.Context, config map[string]string) error
|
||||
Get(ctx context.Context) (map[string]string, error)
|
||||
Del(ctx context.Context, keys []string) error
|
||||
}
|
||||
42
pkg/common/db/table/admin/forbidden_account.go
Normal file
42
pkg/common/db/table/admin/forbidden_account.go
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ForbiddenAccount table
|
||||
type ForbiddenAccount struct {
|
||||
UserID string `bson:"user_id"`
|
||||
Reason string `bson:"reason"`
|
||||
OperatorUserID string `bson:"operator_user_id"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
}
|
||||
|
||||
func (ForbiddenAccount) TableName() string {
|
||||
return "forbidden_accounts"
|
||||
}
|
||||
|
||||
type ForbiddenAccountInterface interface {
|
||||
Create(ctx context.Context, ms []*ForbiddenAccount) error
|
||||
Take(ctx context.Context, userID string) (*ForbiddenAccount, error)
|
||||
Delete(ctx context.Context, userIDs []string) error
|
||||
Find(ctx context.Context, userIDs []string) ([]*ForbiddenAccount, error)
|
||||
Search(ctx context.Context, keyword string, pagination pagination.Pagination) (int64, []*ForbiddenAccount, error)
|
||||
FindAllIDs(ctx context.Context) ([]string, error)
|
||||
}
|
||||
40
pkg/common/db/table/admin/invitation_register.go
Normal file
40
pkg/common/db/table/admin/invitation_register.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
"time"
|
||||
)
|
||||
|
||||
type InvitationRegister struct {
|
||||
InvitationCode string `bson:"invitation_code"`
|
||||
UsedByUserID string `bson:"used_by_user_id"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
}
|
||||
|
||||
func (InvitationRegister) TableName() string {
|
||||
return "invitation_registers"
|
||||
}
|
||||
|
||||
type InvitationRegisterInterface interface {
|
||||
Find(ctx context.Context, codes []string) ([]*InvitationRegister, error)
|
||||
Del(ctx context.Context, codes []string) error
|
||||
Create(ctx context.Context, v []*InvitationRegister) error
|
||||
Take(ctx context.Context, code string) (*InvitationRegister, error)
|
||||
Update(ctx context.Context, code string, data map[string]any) error
|
||||
Search(ctx context.Context, keyword string, state int32, userIDs []string, codes []string, pagination pagination.Pagination) (int64, []*InvitationRegister, error)
|
||||
}
|
||||
40
pkg/common/db/table/admin/ip_forbidden.go
Normal file
40
pkg/common/db/table/admin/ip_forbidden.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
"time"
|
||||
)
|
||||
|
||||
type IPForbidden struct {
|
||||
IP string `bson:"ip"`
|
||||
LimitRegister bool `bson:"limit_register"`
|
||||
LimitLogin bool `bson:"limit_login"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
}
|
||||
|
||||
func (IPForbidden) IPForbidden() string {
|
||||
return "ip_forbiddens"
|
||||
}
|
||||
|
||||
type IPForbiddenInterface interface {
|
||||
Take(ctx context.Context, ip string) (*IPForbidden, error)
|
||||
Find(ctx context.Context, ips []string) ([]*IPForbidden, error)
|
||||
Search(ctx context.Context, keyword string, state int32, pagination pagination.Pagination) (int64, []*IPForbidden, error)
|
||||
Create(ctx context.Context, ms []*IPForbidden) error
|
||||
Delete(ctx context.Context, ips []string) error
|
||||
}
|
||||
39
pkg/common/db/table/admin/limit_user_login_ip.go
Normal file
39
pkg/common/db/table/admin/limit_user_login_ip.go
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
"time"
|
||||
)
|
||||
|
||||
type LimitUserLoginIP struct {
|
||||
UserID string `bson:"user_id"`
|
||||
IP string `bson:"ip"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
}
|
||||
|
||||
func (LimitUserLoginIP) TableName() string {
|
||||
return "limit_user_login_ips"
|
||||
}
|
||||
|
||||
type LimitUserLoginIPInterface interface {
|
||||
Create(ctx context.Context, ms []*LimitUserLoginIP) error
|
||||
Delete(ctx context.Context, ms []*LimitUserLoginIP) error
|
||||
Count(ctx context.Context, userID string) (uint32, error)
|
||||
Take(ctx context.Context, userID string, ip string) (*LimitUserLoginIP, error)
|
||||
Search(ctx context.Context, keyword string, pagination pagination.Pagination) (int64, []*LimitUserLoginIP, error)
|
||||
}
|
||||
39
pkg/common/db/table/admin/register_add_friend.go
Normal file
39
pkg/common/db/table/admin/register_add_friend.go
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
)
|
||||
|
||||
type RegisterAddFriend struct {
|
||||
UserID string `bson:"user_id"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
}
|
||||
|
||||
func (RegisterAddFriend) TableName() string {
|
||||
return "register_add_friends"
|
||||
}
|
||||
|
||||
type RegisterAddFriendInterface interface {
|
||||
Add(ctx context.Context, registerAddFriends []*RegisterAddFriend) error
|
||||
Del(ctx context.Context, userIDs []string) error
|
||||
FindUserID(ctx context.Context, userIDs []string) ([]string, error)
|
||||
Search(ctx context.Context, keyword string, pagination pagination.Pagination) (int64, []*RegisterAddFriend, error)
|
||||
CountTotal(ctx context.Context) (int64, error) // 统计好友总数
|
||||
}
|
||||
40
pkg/common/db/table/admin/register_add_group.go
Normal file
40
pkg/common/db/table/admin/register_add_group.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
)
|
||||
|
||||
type RegisterAddGroup struct {
|
||||
GroupID string `bson:"group_id"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
}
|
||||
|
||||
func (RegisterAddGroup) TableName() string {
|
||||
return "register_add_groups"
|
||||
}
|
||||
|
||||
type RegisterAddGroupInterface interface {
|
||||
Add(ctx context.Context, registerAddGroups []*RegisterAddGroup) error
|
||||
Del(ctx context.Context, groupIDs []string) error
|
||||
FindGroupID(ctx context.Context, groupIDs []string) ([]string, error)
|
||||
Search(ctx context.Context, keyword string, pagination pagination.Pagination) (int64, []*RegisterAddGroup, error)
|
||||
CountTotal(ctx context.Context) (int64, error) // 统计群组总数
|
||||
CountToday(ctx context.Context) (int64, error) // 统计今天新建的群组数
|
||||
}
|
||||
33
pkg/common/db/table/bot/agent.go
Normal file
33
pkg/common/db/table/bot/agent.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package bot
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
)
|
||||
|
||||
type Agent struct {
|
||||
UserID string `bson:"user_id"`
|
||||
NickName string `bson:"nick_name"`
|
||||
FaceURL string `bson:"face_url"`
|
||||
Key string `bson:"key"`
|
||||
Url string `bson:"url"`
|
||||
Identity string `bson:"identity"`
|
||||
Model string `bson:"model"`
|
||||
Prompts string `bson:"prompts"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
}
|
||||
|
||||
func (Agent) TableName() string {
|
||||
return "agent"
|
||||
}
|
||||
|
||||
type AgentInterface interface {
|
||||
Create(ctx context.Context, elems ...*Agent) error
|
||||
Take(ctx context.Context, userID string) (*Agent, error)
|
||||
Find(ctx context.Context, userIDs []string) ([]*Agent, error)
|
||||
Update(ctx context.Context, userID string, data map[string]any) error
|
||||
Delete(ctx context.Context, userIDs []string) error
|
||||
Page(ctx context.Context, userIDs []string, pagination pagination.Pagination) (int64, []*Agent, error)
|
||||
}
|
||||
22
pkg/common/db/table/bot/conversation_resp_id.go
Normal file
22
pkg/common/db/table/bot/conversation_resp_id.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package bot
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type ConversationRespID struct {
|
||||
ConversationID string `bson:"conversation_id"`
|
||||
AgentID string `bson:"agent_id"`
|
||||
PreviousResponseID string `bson:"previous_response_id"`
|
||||
}
|
||||
|
||||
func (ConversationRespID) TableName() string {
|
||||
return "conversation_resp_id"
|
||||
}
|
||||
|
||||
type ConversationRespIDInterface interface {
|
||||
Create(ctx context.Context, elems ...*ConversationRespID) error
|
||||
Take(ctx context.Context, convID, agentID string) (*ConversationRespID, error)
|
||||
Update(ctx context.Context, convID, agentID string, data map[string]any) error
|
||||
Delete(ctx context.Context, convID, agentID string) error
|
||||
}
|
||||
40
pkg/common/db/table/chat/account.go
Normal file
40
pkg/common/db/table/chat/account.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Account struct {
|
||||
UserID string `bson:"user_id"`
|
||||
Password string `bson:"password"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
ChangeTime time.Time `bson:"change_time"`
|
||||
OperatorUserID string `bson:"operator_user_id"`
|
||||
}
|
||||
|
||||
func (Account) TableName() string {
|
||||
return "accounts"
|
||||
}
|
||||
|
||||
type AccountInterface interface {
|
||||
Create(ctx context.Context, accounts ...*Account) error
|
||||
Take(ctx context.Context, userId string) (*Account, error)
|
||||
Update(ctx context.Context, userID string, data map[string]any) error
|
||||
UpdatePassword(ctx context.Context, userId string, password string) error
|
||||
Delete(ctx context.Context, userIDs []string) error
|
||||
}
|
||||
51
pkg/common/db/table/chat/attribute.go
Normal file
51
pkg/common/db/table/chat/attribute.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
)
|
||||
|
||||
type Attribute struct {
|
||||
UserID string `bson:"user_id"`
|
||||
Account string `bson:"account"`
|
||||
PhoneNumber string `bson:"phone_number"`
|
||||
AreaCode string `bson:"area_code"`
|
||||
Email string `bson:"email"`
|
||||
Nickname string `bson:"nickname"`
|
||||
FaceURL string `bson:"face_url"`
|
||||
Gender int32 `bson:"gender"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
ChangeTime time.Time `bson:"change_time"`
|
||||
BirthTime time.Time `bson:"birth_time"`
|
||||
Level int32 `bson:"level"`
|
||||
UserType int32 `bson:"user_type"` // 用户类型: 0=普通用户, 1=企业用户, 2=机器人, 3=管理员
|
||||
UserFlag string `bson:"user_flag"` // 用户标签/标识,类似UserType的字符串版本
|
||||
AllowVibration int32 `bson:"allow_vibration"`
|
||||
AllowBeep int32 `bson:"allow_beep"`
|
||||
AllowAddFriend int32 `bson:"allow_add_friend"`
|
||||
GlobalRecvMsgOpt int32 `bson:"global_recv_msg_opt"`
|
||||
RegisterType int32 `bson:"register_type"`
|
||||
}
|
||||
|
||||
func (Attribute) TableName() string {
|
||||
return "attributes"
|
||||
}
|
||||
|
||||
type AttributeInterface interface {
|
||||
// NewTx(tx any) AttributeInterface
|
||||
Create(ctx context.Context, attribute ...*Attribute) error
|
||||
Update(ctx context.Context, userID string, data map[string]any) error
|
||||
Find(ctx context.Context, userIds []string) ([]*Attribute, error)
|
||||
FindAccount(ctx context.Context, accounts []string) ([]*Attribute, error)
|
||||
Search(ctx context.Context, keyword string, genders []int32, pagination pagination.Pagination) (int64, []*Attribute, error)
|
||||
TakePhone(ctx context.Context, areaCode string, phoneNumber string) (*Attribute, error)
|
||||
TakeEmail(ctx context.Context, email string) (*Attribute, error)
|
||||
TakeAccount(ctx context.Context, account string) (*Attribute, error)
|
||||
Take(ctx context.Context, userID string) (*Attribute, error)
|
||||
SearchNormalUser(ctx context.Context, keyword string, forbiddenID []string, gender int32, startTime, endTime *time.Time, pagination pagination.Pagination) (int64, []*Attribute, error)
|
||||
SearchNormalUserWithUserIDs(ctx context.Context, keyword string, forbiddenID []string, gender int32, startTime, endTime *time.Time, userIDs []string, pagination pagination.Pagination) (int64, []*Attribute, error) // 按条件搜索用户(支持额外的userIDs过滤)
|
||||
SearchUser(ctx context.Context, keyword string, userIDs []string, genders []int32, pagination pagination.Pagination) (int64, []*Attribute, error)
|
||||
Delete(ctx context.Context, userIDs []string) error
|
||||
}
|
||||
32
pkg/common/db/table/chat/credential.go
Normal file
32
pkg/common/db/table/chat/credential.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
)
|
||||
|
||||
type Credential struct {
|
||||
UserID string `bson:"user_id"`
|
||||
Account string `bson:"account"`
|
||||
Type int `bson:"type"` // 1:phone;2:email
|
||||
AllowChange bool `bson:"allow_change"`
|
||||
}
|
||||
|
||||
func (Credential) TableName() string {
|
||||
return "credentials"
|
||||
}
|
||||
|
||||
type CredentialInterface interface {
|
||||
Create(ctx context.Context, credential ...*Credential) error
|
||||
CreateOrUpdateAccount(ctx context.Context, credential *Credential) error
|
||||
Update(ctx context.Context, userID string, data map[string]any) error
|
||||
Find(ctx context.Context, userID string) ([]*Credential, error)
|
||||
FindAccount(ctx context.Context, accounts []string) ([]*Credential, error)
|
||||
Search(ctx context.Context, keyword string, pagination pagination.Pagination) (int64, []*Credential, error)
|
||||
TakeAccount(ctx context.Context, account string) (*Credential, error)
|
||||
Take(ctx context.Context, userID string) (*Credential, error)
|
||||
SearchNormalUser(ctx context.Context, keyword string, forbiddenID []string, pagination pagination.Pagination) (int64, []*Credential, error)
|
||||
SearchUser(ctx context.Context, keyword string, userIDs []string, pagination pagination.Pagination) (int64, []*Credential, error)
|
||||
Delete(ctx context.Context, userIDs []string) error
|
||||
DeleteByUserIDType(ctx context.Context, credentials ...*Credential) error
|
||||
}
|
||||
69
pkg/common/db/table/chat/favorite.go
Normal file
69
pkg/common/db/table/chat/favorite.go
Normal file
@@ -0,0 +1,69 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
)
|
||||
|
||||
// FavoriteType 收藏类型
|
||||
const (
|
||||
FavoriteTypeText = 1 // 文本
|
||||
FavoriteTypeImage = 2 // 图片
|
||||
FavoriteTypeLink = 3 // 链接
|
||||
FavoriteTypeFile = 4 // 文件
|
||||
FavoriteTypeVoice = 5 // 语音
|
||||
FavoriteTypeVideo = 6 // 视频
|
||||
FavoriteTypeLocation = 7 // 位置
|
||||
)
|
||||
|
||||
type Favorite struct {
|
||||
ID string `bson:"_id"` // 收藏ID(MongoDB ObjectID)
|
||||
UserID string `bson:"user_id"` // 用户ID(收藏者)
|
||||
Type int32 `bson:"type"` // 收藏类型:1-文本,2-图片,3-链接,4-文件,5-语音,6-视频,7-位置
|
||||
Title string `bson:"title"` // 标题(可选)
|
||||
Content string `bson:"content"` // 内容(根据类型不同,可能是文本、图片URL、链接URL、文件路径等)
|
||||
Description string `bson:"description"` // 摘要/描述(可选)
|
||||
Thumbnail string `bson:"thumbnail"` // 缩略图URL(用于图片、视频、链接等)
|
||||
LinkURL string `bson:"link_url"` // 链接URL(用于链接类型)
|
||||
FileSize int64 `bson:"file_size"` // 文件大小(字节,用于文件、语音、视频等)
|
||||
Duration int32 `bson:"duration"` // 时长(秒,用于语音、视频等)
|
||||
Location string `bson:"location"` // 位置信息(JSON格式,用于位置类型)
|
||||
Tags []string `bson:"tags"` // 标签列表
|
||||
Remark string `bson:"remark"` // 备注(可选)
|
||||
Status int32 `bson:"status"` // 状态:0-已删除,1-正常
|
||||
CreateTime time.Time `bson:"create_time"` // 创建时间
|
||||
UpdateTime time.Time `bson:"update_time"` // 更新时间
|
||||
}
|
||||
|
||||
func (Favorite) TableName() string {
|
||||
return "favorites"
|
||||
}
|
||||
|
||||
type FavoriteInterface interface {
|
||||
Create(ctx context.Context, favorites ...*Favorite) error
|
||||
Take(ctx context.Context, favoriteID string) (*Favorite, error)
|
||||
FindByUserID(ctx context.Context, userID string, pagination pagination.Pagination) (int64, []*Favorite, error)
|
||||
FindByUserIDAndType(ctx context.Context, userID string, favoriteType int32, pagination pagination.Pagination) (int64, []*Favorite, error)
|
||||
SearchByKeyword(ctx context.Context, userID string, keyword string, pagination pagination.Pagination) (int64, []*Favorite, error)
|
||||
Update(ctx context.Context, favoriteID string, data map[string]any) error
|
||||
Delete(ctx context.Context, favoriteIDs []string) error
|
||||
DeleteByUserID(ctx context.Context, userID string) error
|
||||
CountByUserID(ctx context.Context, userID string) (int64, error)
|
||||
FindByTags(ctx context.Context, userID string, tags []string, pagination pagination.Pagination) (int64, []*Favorite, error)
|
||||
}
|
||||
67
pkg/common/db/table/chat/livekit.go
Normal file
67
pkg/common/db/table/chat/livekit.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// LiveKit 表示一台LiveKit服务器配置
|
||||
type LiveKit struct {
|
||||
ID string `bson:"_id" json:"id"` // 服务器唯一标识
|
||||
Name string `bson:"name" json:"name"` // 服务器名称
|
||||
URL string `bson:"url" json:"url"` // LiveKit服务器地址
|
||||
Key string `bson:"key" json:"key"` // API Key
|
||||
Secret string `bson:"secret" json:"secret"` // API Secret
|
||||
Region string `bson:"region" json:"region"` // 服务器区域
|
||||
Status int `bson:"status" json:"status"` // 状态:0-禁用,1-启用
|
||||
Priority int `bson:"priority" json:"priority"` // 优先级,数字越小优先级越高
|
||||
MaxRooms int `bson:"max_rooms" json:"max_rooms"` // 最大房间数
|
||||
MaxUsers int `bson:"max_users" json:"max_users"` // 最大用户数
|
||||
Description string `bson:"description" json:"description"` // 描述信息
|
||||
CreateTime time.Time `bson:"create_time" json:"create_time"` // 创建时间
|
||||
UpdateTime time.Time `bson:"update_time" json:"update_time"` // 更新时间
|
||||
}
|
||||
|
||||
// TableName 返回表名
|
||||
func (LiveKit) TableName() string {
|
||||
return "livekits"
|
||||
}
|
||||
|
||||
// LiveKitInterface 定义LiveKit数据库操作接口
|
||||
type LiveKitInterface interface {
|
||||
// Create 创建LiveKit服务器配置
|
||||
Create(ctx context.Context, livekits ...*LiveKit) error
|
||||
// Delete 删除LiveKit服务器配置
|
||||
Delete(ctx context.Context, ids []string) error
|
||||
// Update 更新LiveKit服务器配置
|
||||
Update(ctx context.Context, livekit *LiveKit) error
|
||||
// FindByID 根据ID查找LiveKit配置
|
||||
FindByID(ctx context.Context, id string) (*LiveKit, error)
|
||||
// FindByStatus 根据状态查找LiveKit配置列表
|
||||
FindByStatus(ctx context.Context, status int) ([]*LiveKit, error)
|
||||
// FindAll 查找所有LiveKit配置
|
||||
FindAll(ctx context.Context) ([]*LiveKit, error)
|
||||
// FindAvailable 查找可用的LiveKit服务器(按优先级排序)
|
||||
FindAvailable(ctx context.Context) ([]*LiveKit, error)
|
||||
// FindByRegion 根据区域查找LiveKit配置
|
||||
FindByRegion(ctx context.Context, region string) ([]*LiveKit, error)
|
||||
// UpdateStatus 更新服务器状态
|
||||
UpdateStatus(ctx context.Context, id string, status int) error
|
||||
// UpdatePriority 更新服务器优先级
|
||||
UpdatePriority(ctx context.Context, id string, priority int) error
|
||||
// GetNextAvailable 获取下一个可用的LiveKit服务器(负载均衡)
|
||||
GetNextAvailable(ctx context.Context) (*LiveKit, error)
|
||||
}
|
||||
|
||||
// 状态常量
|
||||
const (
|
||||
LiveKitStatusDisabled = 0 // 禁用
|
||||
LiveKitStatusEnabled = 1 // 启用
|
||||
)
|
||||
|
||||
// 默认值
|
||||
const (
|
||||
DefaultMaxRooms = 1000 // 默认最大房间数
|
||||
DefaultMaxUsers = 100 // 默认最大用户数
|
||||
DefaultPriority = 100 // 默认优先级
|
||||
)
|
||||
42
pkg/common/db/table/chat/register.go
Normal file
42
pkg/common/db/table/chat/register.go
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Register struct {
|
||||
UserID string `bson:"user_id"`
|
||||
DeviceID string `bson:"device_id"`
|
||||
IP string `bson:"ip"`
|
||||
Platform string `bson:"platform"`
|
||||
AccountType string `bson:"account_type"`
|
||||
Mode string `bson:"mode"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
}
|
||||
|
||||
func (Register) TableName() string {
|
||||
return "registers"
|
||||
}
|
||||
|
||||
type RegisterInterface interface {
|
||||
// NewTx(tx any) RegisterInterface
|
||||
Create(ctx context.Context, registers ...*Register) error
|
||||
CountTotal(ctx context.Context, before *time.Time) (int64, error)
|
||||
CountToday(ctx context.Context) (int64, error) // 统计今天注册的用户数
|
||||
Delete(ctx context.Context, userIDs []string) error
|
||||
}
|
||||
78
pkg/common/db/table/chat/scheduled_task.go
Normal file
78
pkg/common/db/table/chat/scheduled_task.go
Normal file
@@ -0,0 +1,78 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
)
|
||||
|
||||
// ScheduledTaskStatus 定时任务状态
|
||||
const (
|
||||
ScheduledTaskStatusDisabled = 0 // 已禁用
|
||||
ScheduledTaskStatusEnabled = 1 // 已启用
|
||||
)
|
||||
|
||||
// MessageType 消息类型
|
||||
const (
|
||||
MessageTypeText = 1 // 文本消息
|
||||
MessageTypeImage = 2 // 图片消息
|
||||
MessageTypeVideo = 3 // 视频消息
|
||||
)
|
||||
|
||||
// ScheduledTask 定时任务配置
|
||||
// CronExpression格式:分 时 日 月 周
|
||||
// 例如:"0 9 * * *" 表示每天9点执行
|
||||
//
|
||||
// "*/5 * * * *" 表示每5分钟执行
|
||||
// "0 0 * * 1" 表示每周一0点执行
|
||||
type ScheduledTask struct {
|
||||
ID string `bson:"_id"` // 任务ID
|
||||
UserID string `bson:"user_id"` // 用户ID
|
||||
Name string `bson:"name"` // 任务名称
|
||||
CronExpression string `bson:"cron_expression"` // Crontab表达式:分 时 日 月 周(例如:"0 9 * * *")
|
||||
Messages []Message `bson:"messages"` // 消息列表(支持多条消息一起发送)
|
||||
RecvIDs []string `bson:"recv_ids"` // 接收者ID列表(单聊,可以多个)
|
||||
GroupIDs []string `bson:"group_ids"` // 群组ID列表(群聊,可以多个)
|
||||
Status int32 `bson:"status"` // 状态:0-已禁用,1-已启用
|
||||
CreateTime time.Time `bson:"create_time"` // 创建时间
|
||||
UpdateTime time.Time `bson:"update_time"` // 更新时间
|
||||
}
|
||||
|
||||
// Message 消息内容
|
||||
type Message struct {
|
||||
Type int32 `bson:"type"` // 消息类型:1-文本,2-图片,3-视频
|
||||
Content string `bson:"content"` // 消息内容(文本内容、图片URL、视频URL等)
|
||||
Thumbnail string `bson:"thumbnail"` // 缩略图URL(用于图片和视频)
|
||||
Duration int32 `bson:"duration"` // 时长(秒,用于视频)
|
||||
FileSize int64 `bson:"file_size"` // 文件大小(字节,用于图片和视频)
|
||||
Width int32 `bson:"width"` // 宽度(像素,用于图片和视频)
|
||||
Height int32 `bson:"height"` // 高度(像素,用于图片和视频)
|
||||
}
|
||||
|
||||
func (ScheduledTask) TableName() string {
|
||||
return "scheduled_tasks"
|
||||
}
|
||||
|
||||
type ScheduledTaskInterface interface {
|
||||
Create(ctx context.Context, tasks ...*ScheduledTask) error
|
||||
Take(ctx context.Context, taskID string) (*ScheduledTask, error)
|
||||
FindByUserID(ctx context.Context, userID string, pagination pagination.Pagination) (int64, []*ScheduledTask, error)
|
||||
FindAll(ctx context.Context, pagination pagination.Pagination) (int64, []*ScheduledTask, error)
|
||||
Update(ctx context.Context, taskID string, data map[string]any) error
|
||||
Delete(ctx context.Context, taskIDs []string) error
|
||||
}
|
||||
144
pkg/common/db/table/chat/sensitive_word.go
Normal file
144
pkg/common/db/table/chat/sensitive_word.go
Normal file
@@ -0,0 +1,144 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// 敏感词相关结构体定义
|
||||
type SensitiveWord struct {
|
||||
ID string `bson:"_id" json:"id"` // 主键ID
|
||||
Word string `bson:"word" json:"word"` // 敏感词内容
|
||||
Level int32 `bson:"level" json:"level"` // 敏感词级别 1:低 2:中 3:高
|
||||
Type int32 `bson:"type" json:"type"` // 敏感词类型 1:政治 2:色情 3:暴力 4:广告 5:其他
|
||||
Action int32 `bson:"action" json:"action"` // 处理动作 1:替换为*** 2:拦截不发
|
||||
Status int32 `bson:"status" json:"status"` // 状态 1:启用 0:禁用
|
||||
Creator string `bson:"creator" json:"creator"` // 创建者
|
||||
Updater string `bson:"updater" json:"updater"` // 更新者
|
||||
CreateTime time.Time `bson:"create_time" json:"create_time"` // 创建时间
|
||||
UpdateTime time.Time `bson:"update_time" json:"update_time"` // 更新时间
|
||||
Remark string `bson:"remark" json:"remark"` // 备注
|
||||
}
|
||||
|
||||
func (SensitiveWord) TableName() string {
|
||||
return "sensitive_words"
|
||||
}
|
||||
|
||||
type SensitiveWordLog struct {
|
||||
ID primitive.ObjectID `bson:"_id,omitempty"`
|
||||
UserID string `bson:"user_id"` // 触发用户ID
|
||||
GroupID string `bson:"group_id"` // 触发群组ID (如果是在群聊中)
|
||||
Content string `bson:"content"` // 原始消息内容
|
||||
MatchedWords []string `bson:"matched_words"` // 匹配到的敏感词
|
||||
Action int32 `bson:"action"` // 采取的动作
|
||||
ProcessedText string `bson:"processed_text"` // 处理后的文本 (如果被替换)
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
}
|
||||
|
||||
func (SensitiveWordLog) TableName() string {
|
||||
return "sensitive_word_logs"
|
||||
}
|
||||
|
||||
type SensitiveWordGroup struct {
|
||||
ID primitive.ObjectID `bson:"_id,omitempty"`
|
||||
Name string `bson:"name"` // 分组名称
|
||||
Remark string `bson:"remark"` // 备注
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
UpdateTime time.Time `bson:"update_time"`
|
||||
}
|
||||
|
||||
func (SensitiveWordGroup) TableName() string {
|
||||
return "sensitive_word_groups"
|
||||
}
|
||||
|
||||
type SensitiveWordConfig struct {
|
||||
ID string `bson:"_id" json:"id"` // 主键ID
|
||||
EnableFilter bool `bson:"enable_filter" json:"enable_filter"` // 是否启用过滤
|
||||
FilterMode int32 `bson:"filter_mode" json:"filter_mode"` // 过滤模式
|
||||
ReplaceChar string `bson:"replace_char" json:"replace_char"` // 替换字符,默认***
|
||||
WhitelistUsers []string `bson:"whitelist_users" json:"whitelist_users"` // 白名单用户
|
||||
WhitelistGroups []string `bson:"whitelist_groups" json:"whitelist_groups"` // 白名单群组
|
||||
LogEnabled bool `bson:"log_enabled" json:"log_enabled"` // 是否记录日志
|
||||
AutoApprove bool `bson:"auto_approve" json:"auto_approve"` // 是否自动审核
|
||||
UpdateTime time.Time `bson:"update_time" json:"update_time"` // 更新时间
|
||||
}
|
||||
|
||||
func (SensitiveWordConfig) TableName() string {
|
||||
return "sensitive_word_configs"
|
||||
}
|
||||
|
||||
// 敏感词级别常量
|
||||
const (
|
||||
SensitiveLevelLow = 1 // 低级别
|
||||
SensitiveLevelMedium = 2 // 中级别
|
||||
SensitiveLevelHigh = 3 // 高级别
|
||||
)
|
||||
|
||||
// 敏感词类型常量
|
||||
const (
|
||||
SensitiveTypePolitical = 1 // 政治
|
||||
SensitiveTypePorn = 2 // 色情
|
||||
SensitiveTypeViolence = 3 // 暴力
|
||||
SensitiveTypeAd = 4 // 广告
|
||||
SensitiveTypeOther = 5 // 其他
|
||||
)
|
||||
|
||||
// 处理动作常量
|
||||
const (
|
||||
SensitiveActionReplace = 1 // 替换为***
|
||||
SensitiveActionBlock = 2 // 拦截不发
|
||||
)
|
||||
|
||||
// 状态常量
|
||||
const (
|
||||
SensitiveStatusDisabled = 0 // 禁用
|
||||
SensitiveStatusEnabled = 1 // 启用
|
||||
)
|
||||
|
||||
type SensitiveWordInterface interface {
|
||||
// 敏感词管理
|
||||
CreateSensitiveWord(ctx context.Context, word *SensitiveWord) error
|
||||
UpdateSensitiveWord(ctx context.Context, id string, data map[string]any) error
|
||||
DeleteSensitiveWord(ctx context.Context, ids []string) error
|
||||
GetSensitiveWord(ctx context.Context, id string) (*SensitiveWord, error)
|
||||
SearchSensitiveWords(ctx context.Context, keyword string, action int32, status int32, pagination pagination.Pagination) (int64, []*SensitiveWord, error)
|
||||
GetAllSensitiveWords(ctx context.Context) ([]*SensitiveWord, error)
|
||||
GetEnabledSensitiveWords(ctx context.Context) ([]*SensitiveWord, error)
|
||||
|
||||
// 敏感词检测
|
||||
CheckSensitiveWords(ctx context.Context, content string) ([]*SensitiveWord, error)
|
||||
FilterContent(ctx context.Context, content string) (string, []*SensitiveWord, error)
|
||||
|
||||
// 敏感词日志
|
||||
CreateSensitiveWordLog(ctx context.Context, log *SensitiveWordLog) error
|
||||
GetSensitiveWordLogs(ctx context.Context, userID string, groupID string, pagination pagination.Pagination) (int64, []*SensitiveWordLog, error)
|
||||
DeleteSensitiveWordLogs(ctx context.Context, ids []string) error
|
||||
|
||||
// 敏感词分组管理
|
||||
CreateSensitiveWordGroup(ctx context.Context, group *SensitiveWordGroup) error
|
||||
UpdateSensitiveWordGroup(ctx context.Context, id string, data map[string]any) error
|
||||
DeleteSensitiveWordGroup(ctx context.Context, ids []string) error
|
||||
GetSensitiveWordGroup(ctx context.Context, id string) (*SensitiveWordGroup, error)
|
||||
GetAllSensitiveWordGroups(ctx context.Context) ([]*SensitiveWordGroup, error)
|
||||
|
||||
// 敏感词配置管理
|
||||
GetSensitiveWordConfig(ctx context.Context) (*SensitiveWordConfig, error)
|
||||
UpdateSensitiveWordConfig(ctx context.Context, config *SensitiveWordConfig) error
|
||||
IsFilterEnabled(ctx context.Context) (bool, error)
|
||||
GetFilterMode(ctx context.Context) (int32, error)
|
||||
GetReplaceChar(ctx context.Context) (string, error)
|
||||
IsUserInWhitelist(ctx context.Context, userID string) (bool, error)
|
||||
IsGroupInWhitelist(ctx context.Context, groupID string) (bool, error)
|
||||
|
||||
// 批量操作
|
||||
BatchCreateSensitiveWords(ctx context.Context, words []*SensitiveWord) error
|
||||
BatchUpdateSensitiveWords(ctx context.Context, updates map[string]map[string]any) error
|
||||
BatchDeleteSensitiveWords(ctx context.Context, ids []string) error
|
||||
|
||||
// 统计信息
|
||||
GetSensitiveWordStats(ctx context.Context) (map[string]int64, error)
|
||||
GetSensitiveWordLogStats(ctx context.Context, startTime, endTime time.Time) (map[string]int64, error)
|
||||
}
|
||||
69
pkg/common/db/table/chat/system_config.go
Normal file
69
pkg/common/db/table/chat/system_config.go
Normal file
@@ -0,0 +1,69 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
)
|
||||
|
||||
// ConfigValueType 配置值类型
|
||||
const (
|
||||
ConfigValueTypeString = 1 // 字符串类型
|
||||
ConfigValueTypeNumber = 2 // 数字类型
|
||||
ConfigValueTypeBool = 3 // 布尔类型
|
||||
ConfigValueTypeJSON = 4 // JSON类型
|
||||
)
|
||||
|
||||
// ConfigKey 常用配置键
|
||||
const (
|
||||
// 钱包相关配置
|
||||
ConfigKeyWalletEnabled = "wallet.enabled" // 是否开启钱包功能
|
||||
|
||||
// 注册相关配置
|
||||
ConfigKeyPhoneRegisterVerifyCodeEnabled = "register.phone.verify_code.enabled" // 手机号注册验证码功能是否开启
|
||||
)
|
||||
|
||||
// SystemConfig 系统配置模型
|
||||
type SystemConfig struct {
|
||||
Key string `bson:"key"` // 配置键(唯一标识)
|
||||
Title string `bson:"title"` // 配置标题
|
||||
Value string `bson:"value"` // 配置值(字符串形式存储,根据ValueType解析)
|
||||
ValueType int32 `bson:"value_type"` // 配置值类型:1-字符串,2-数字,3-布尔,4-JSON
|
||||
Description string `bson:"description"` // 配置描述
|
||||
Enabled bool `bson:"enabled"` // 是否启用(用于开关类配置)
|
||||
ShowInApp bool `bson:"show_in_app"` // 是否在APP端展示
|
||||
CreateTime time.Time `bson:"create_time"` // 创建时间
|
||||
UpdateTime time.Time `bson:"update_time"` // 更新时间
|
||||
}
|
||||
|
||||
func (SystemConfig) TableName() string {
|
||||
return "system_configs"
|
||||
}
|
||||
|
||||
type SystemConfigInterface interface {
|
||||
Create(ctx context.Context, configs ...*SystemConfig) error
|
||||
Take(ctx context.Context, key string) (*SystemConfig, error)
|
||||
FindByKeys(ctx context.Context, keys []string) ([]*SystemConfig, error)
|
||||
FindAll(ctx context.Context, pagination pagination.Pagination) (int64, []*SystemConfig, error)
|
||||
Update(ctx context.Context, key string, data map[string]any) error
|
||||
UpdateValue(ctx context.Context, key string, value string) error
|
||||
UpdateEnabled(ctx context.Context, key string, enabled bool) error
|
||||
Delete(ctx context.Context, keys []string) error
|
||||
GetEnabledConfigs(ctx context.Context) ([]*SystemConfig, error)
|
||||
GetAppConfigs(ctx context.Context) ([]*SystemConfig, error) // 获取所有 show_in_app=true 的配置
|
||||
}
|
||||
43
pkg/common/db/table/chat/user_login_record.go
Normal file
43
pkg/common/db/table/chat/user_login_record.go
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
)
|
||||
|
||||
type UserLoginRecord struct {
|
||||
UserID string `bson:"user_id"`
|
||||
LoginTime time.Time `bson:"login_time"`
|
||||
IP string `bson:"ip"`
|
||||
DeviceID string `bson:"device_id"`
|
||||
Platform string `bson:"platform"`
|
||||
}
|
||||
|
||||
func (UserLoginRecord) TableName() string {
|
||||
return "user_login_records"
|
||||
}
|
||||
|
||||
type UserLoginRecordInterface interface {
|
||||
Create(ctx context.Context, records ...*UserLoginRecord) error
|
||||
CountTotal(ctx context.Context, before *time.Time) (int64, error)
|
||||
CountRangeEverydayTotal(ctx context.Context, start *time.Time, end *time.Time) (map[string]int64, int64, error)
|
||||
CountTodayActiveUsers(ctx context.Context) (int64, error) // 统计今天活跃用户数(今天登录的不同用户数)
|
||||
GetLatestLoginIP(ctx context.Context, userID string) (string, error) // 获取用户最新登录IP
|
||||
Search(ctx context.Context, userID, ip string, pagination pagination.Pagination) (int64, []*UserLoginRecord, error) // 查询登录记录(支持按用户ID或IP查询)
|
||||
}
|
||||
43
pkg/common/db/table/chat/verify_code.go
Normal file
43
pkg/common/db/table/chat/verify_code.go
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
type VerifyCode struct {
|
||||
ID string `bson:"_id"`
|
||||
Account string `bson:"account"`
|
||||
Platform string `bson:"platform"`
|
||||
Code string `bson:"code"`
|
||||
Duration uint `bson:"duration"`
|
||||
Count int `bson:"count"`
|
||||
Used bool `bson:"used"`
|
||||
CreateTime time.Time `bson:"create_time"`
|
||||
}
|
||||
|
||||
func (VerifyCode) TableName() string {
|
||||
return "verify_codes"
|
||||
}
|
||||
|
||||
type VerifyCodeInterface interface {
|
||||
Add(ctx context.Context, ms []*VerifyCode) error
|
||||
RangeNum(ctx context.Context, account string, start time.Time, end time.Time) (int64, error)
|
||||
TakeLast(ctx context.Context, account string) (*VerifyCode, error)
|
||||
Incr(ctx context.Context, id string) error
|
||||
Delete(ctx context.Context, id string) error
|
||||
}
|
||||
116
pkg/common/db/table/chat/wallet.go
Normal file
116
pkg/common/db/table/chat/wallet.go
Normal file
@@ -0,0 +1,116 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
)
|
||||
|
||||
// BalanceRecordType 余额变动类型
|
||||
const (
|
||||
BalanceRecordTypeRecharge = 1 // 充值
|
||||
BalanceRecordTypeWithdraw = 2 // 提现/提款
|
||||
BalanceRecordTypeConsume = 3 // 消费
|
||||
BalanceRecordTypeRefund = 4 // 退款
|
||||
BalanceRecordTypeReward = 5 // 奖励
|
||||
BalanceRecordTypeAdminRecharge = 6 // 后台充值
|
||||
BalanceRecordTypeSendRedPacket = 7 // 发红包(减少余额)
|
||||
BalanceRecordTypeGrabRedPacket = 8 // 抢红包(增加余额)
|
||||
BalanceRecordTypeOther = 99 // 其他
|
||||
)
|
||||
|
||||
// WithdrawAccountType 提现账号类型
|
||||
const (
|
||||
WithdrawAccountTypeAlipay = 1 // 支付宝
|
||||
WithdrawAccountTypeWeChat = 2 // 微信
|
||||
WithdrawAccountTypeBankCard = 3 // 银行卡
|
||||
)
|
||||
|
||||
// RealNameAuth 实名认证信息
|
||||
type RealNameAuth struct {
|
||||
IDCard string `bson:"id_card"` // 身份证号
|
||||
IDCardPhotoFront string `bson:"id_card_photo_front"` // 身份证正面照片URL
|
||||
IDCardPhotoBack string `bson:"id_card_photo_back"` // 身份证反面照片URL
|
||||
Name string `bson:"name"` // 真实姓名
|
||||
AuditStatus int32 `bson:"audit_status"` // 审核状态:0-未审核,1-审核通过,2-审核拒绝
|
||||
}
|
||||
|
||||
// Wallet 钱包模型
|
||||
type Wallet struct {
|
||||
UserID string `bson:"user_id"` // 用户ID
|
||||
Balance int64 `bson:"balance"` // 用户余额(单位:分)
|
||||
PaymentPassword string `bson:"payment_password"` // 支付密码(加密存储)
|
||||
WithdrawAccount string `bson:"withdraw_account"` // 提现账号
|
||||
WithdrawAccountType int32 `bson:"withdraw_account_type"` // 提现账号类型:1-支付宝,2-微信,3-银行卡
|
||||
RealNameAuth RealNameAuth `bson:"real_name_auth"` // 实名认证信息
|
||||
WithdrawReceiveAccount string `bson:"withdraw_receive_account"` // 提现收款账号
|
||||
CreateTime time.Time `bson:"create_time"` // 创建时间
|
||||
UpdateTime time.Time `bson:"update_time"` // 更新时间
|
||||
}
|
||||
|
||||
func (Wallet) TableName() string {
|
||||
return "wallets"
|
||||
}
|
||||
|
||||
type WalletInterface interface {
|
||||
Create(ctx context.Context, wallets ...*Wallet) error
|
||||
Take(ctx context.Context, userID string) (*Wallet, error)
|
||||
Find(ctx context.Context, userIDs []string) ([]*Wallet, error)
|
||||
Update(ctx context.Context, userID string, data map[string]any) error
|
||||
UpdateBalance(ctx context.Context, userID string, balance int64) error
|
||||
IncrementBalance(ctx context.Context, userID string, amount int64) (beforeBalance int64, afterBalance int64, err error) // 原子更新余额,返回更新前后的余额
|
||||
UpdatePaymentPassword(ctx context.Context, userID string, paymentPassword string) error
|
||||
UpdateWithdrawAccount(ctx context.Context, userID string, withdrawAccount string) error // 更新提款账号(兼容旧接口)
|
||||
UpdateWithdrawAccountWithType(ctx context.Context, userID string, withdrawAccount string, accountType int32) error // 更新提款账号(带类型)
|
||||
UpdateRealNameAuth(ctx context.Context, userID string, realNameAuth RealNameAuth) error // 更新实名认证信息
|
||||
Delete(ctx context.Context, userIDs []string) error
|
||||
Page(ctx context.Context, pagination pagination.Pagination) (int64, []*Wallet, error)
|
||||
PageByRealNameAuthAuditStatus(ctx context.Context, auditStatus int32, userID string, pagination pagination.Pagination) (int64, []*Wallet, error) // 按实名认证审核状态分页查询(支持用户ID搜索)
|
||||
SearchByRealNameAuth(ctx context.Context, realNameKeyword string, idCardKeyword string) ([]string, error) // 按实名认证信息搜索钱包(返回userIDs)
|
||||
}
|
||||
|
||||
// WalletBalanceRecord 钱包余额记录
|
||||
type WalletBalanceRecord struct {
|
||||
ID string `bson:"_id"` // 记录ID
|
||||
UserID string `bson:"user_id"` // 用户ID
|
||||
Amount int64 `bson:"amount"` // 变动金额(单位:分,正数表示增加,负数表示减少)
|
||||
Type int32 `bson:"type"` // 变动类型:1-充值,2-提现/提款,3-消费,4-退款,5-奖励,6-后台充值,7-发红包,8-抢红包,99-其他
|
||||
BeforeBalance int64 `bson:"before_balance"` // 变动前余额(单位:分)
|
||||
AfterBalance int64 `bson:"after_balance"` // 变动后余额(单位:分)
|
||||
OrderID string `bson:"order_id"` // 关联订单ID(可选)
|
||||
TransactionID string `bson:"transaction_id"` // 交易ID(可选)
|
||||
RedPacketID string `bson:"red_packet_id"` // 红包ID(用于发红包和抢红包记录关联,可选)
|
||||
Remark string `bson:"remark"` // 备注
|
||||
CreateTime time.Time `bson:"create_time"` // 创建时间
|
||||
}
|
||||
|
||||
func (WalletBalanceRecord) TableName() string {
|
||||
return "wallet_balance_records"
|
||||
}
|
||||
|
||||
type WalletBalanceRecordInterface interface {
|
||||
Create(ctx context.Context, records ...*WalletBalanceRecord) error
|
||||
Take(ctx context.Context, recordID string) (*WalletBalanceRecord, error)
|
||||
FindByUserID(ctx context.Context, userID string, pagination pagination.Pagination) (int64, []*WalletBalanceRecord, error)
|
||||
FindByUserIDAndType(ctx context.Context, userID string, recordType int32, pagination pagination.Pagination) (int64, []*WalletBalanceRecord, error)
|
||||
FindByOrderID(ctx context.Context, orderID string) (*WalletBalanceRecord, error)
|
||||
FindByTransactionID(ctx context.Context, transactionID string) (*WalletBalanceRecord, error)
|
||||
FindByRedPacketID(ctx context.Context, redPacketID string) ([]*WalletBalanceRecord, error)
|
||||
GetUserBalanceHistory(ctx context.Context, userID string, startTime, endTime *time.Time, pagination pagination.Pagination) (int64, []*WalletBalanceRecord, error)
|
||||
CountByUserID(ctx context.Context, userID string) (int64, error)
|
||||
}
|
||||
63
pkg/common/db/table/chat/withdraw.go
Normal file
63
pkg/common/db/table/chat/withdraw.go
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
)
|
||||
|
||||
// WithdrawStatus 提现状态
|
||||
const (
|
||||
WithdrawStatusPending = 1 // 待审核
|
||||
WithdrawStatusApproved = 2 // 已通过
|
||||
WithdrawStatusRejected = 3 // 已拒绝
|
||||
)
|
||||
|
||||
// Withdraw 提现记录
|
||||
type Withdraw struct {
|
||||
ID string `bson:"_id"` // 提现ID
|
||||
UserID string `bson:"user_id"` // 用户ID
|
||||
Amount int64 `bson:"amount"` // 提现金额(单位:分)
|
||||
WithdrawAccount string `bson:"withdraw_account"` // 提现账号
|
||||
Status int32 `bson:"status"` // 审核状态:1-待审核,2-已通过,3-已拒绝
|
||||
AuditorID string `bson:"auditor_id"` // 审核人ID(管理员ID)
|
||||
AuditTime time.Time `bson:"audit_time"` // 审核时间
|
||||
AuditRemark string `bson:"audit_remark"` // 审核备注
|
||||
IP string `bson:"ip"` // 提现IP
|
||||
DeviceID string `bson:"device_id"` // 设备ID
|
||||
Platform string `bson:"platform"` // 平台(iOS、Android、Web等)
|
||||
DeviceModel string `bson:"device_model"` // 设备型号(如:iPhone 14 Pro、Samsung Galaxy S23等)
|
||||
DeviceBrand string `bson:"device_brand"` // 设备品牌(如:Apple、Samsung、Huawei等)
|
||||
OSVersion string `bson:"os_version"` // 操作系统版本(如:iOS 17.0、Android 13等)
|
||||
AppVersion string `bson:"app_version"` // 应用版本
|
||||
CreateTime time.Time `bson:"create_time"` // 创建时间
|
||||
UpdateTime time.Time `bson:"update_time"` // 更新时间
|
||||
}
|
||||
|
||||
func (Withdraw) TableName() string {
|
||||
return "withdraws"
|
||||
}
|
||||
|
||||
type WithdrawInterface interface {
|
||||
Create(ctx context.Context, withdraws ...*Withdraw) error
|
||||
Take(ctx context.Context, withdrawID string) (*Withdraw, error)
|
||||
FindByUserID(ctx context.Context, userID string, pagination pagination.Pagination) (int64, []*Withdraw, error)
|
||||
FindByStatus(ctx context.Context, status int32, pagination pagination.Pagination) (int64, []*Withdraw, error)
|
||||
UpdateStatus(ctx context.Context, withdrawID string, status int32, auditorID string, auditRemark string) error
|
||||
Page(ctx context.Context, pagination pagination.Pagination) (int64, []*Withdraw, error)
|
||||
}
|
||||
68
pkg/common/db/table/chat/withdraw_application.go
Normal file
68
pkg/common/db/table/chat/withdraw_application.go
Normal file
@@ -0,0 +1,68 @@
|
||||
// Copyright © 2023 OpenIM open source community. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/openimsdk/tools/db/pagination"
|
||||
)
|
||||
|
||||
// WithdrawApplicationStatus 提现申请状态
|
||||
const (
|
||||
WithdrawApplicationStatusPending = 1 // 待审核
|
||||
WithdrawApplicationStatusApproved = 2 // 已通过
|
||||
WithdrawApplicationStatusRejected = 3 // 已拒绝
|
||||
WithdrawApplicationStatusProcessing = 4 // 处理中
|
||||
WithdrawApplicationStatusCompleted = 5 // 已完成
|
||||
)
|
||||
|
||||
// WithdrawApplication 提现申请
|
||||
type WithdrawApplication struct {
|
||||
ID string `bson:"_id"` // 申请ID
|
||||
UserID string `bson:"user_id"` // 用户ID
|
||||
Amount int64 `bson:"amount"` // 提现金额(单位:分)
|
||||
WithdrawAccount string `bson:"withdraw_account"` // 提现账号
|
||||
WithdrawAccountType int32 `bson:"withdraw_account_type"` // 提现账号类型:1-支付宝,2-微信,3-银行卡
|
||||
Status int32 `bson:"status"` // 申请状态:1-待审核,2-已通过,3-已拒绝,4-处理中,5-已完成
|
||||
AuditorID string `bson:"auditor_id"` // 审核人ID(管理员ID)
|
||||
AuditTime time.Time `bson:"audit_time"` // 审核时间
|
||||
AuditRemark string `bson:"audit_remark"` // 审核备注
|
||||
IP string `bson:"ip"` // 申请IP
|
||||
DeviceID string `bson:"device_id"` // 设备ID
|
||||
Platform string `bson:"platform"` // 平台(iOS、Android、Web等)
|
||||
DeviceModel string `bson:"device_model"` // 设备型号(如:iPhone 14 Pro、Samsung Galaxy S23等)
|
||||
DeviceBrand string `bson:"device_brand"` // 设备品牌(如:Apple、Samsung、Huawei等)
|
||||
OSVersion string `bson:"os_version"` // 操作系统版本(如:iOS 17.0、Android 13等)
|
||||
AppVersion string `bson:"app_version"` // 应用版本
|
||||
Remark string `bson:"remark"` // 申请备注
|
||||
CreateTime time.Time `bson:"create_time"` // 创建时间
|
||||
UpdateTime time.Time `bson:"update_time"` // 更新时间
|
||||
}
|
||||
|
||||
func (WithdrawApplication) TableName() string {
|
||||
return "withdraw_applications"
|
||||
}
|
||||
|
||||
type WithdrawApplicationInterface interface {
|
||||
Create(ctx context.Context, applications ...*WithdrawApplication) error
|
||||
Take(ctx context.Context, applicationID string) (*WithdrawApplication, error)
|
||||
FindByUserID(ctx context.Context, userID string, pagination pagination.Pagination) (int64, []*WithdrawApplication, error)
|
||||
FindByStatus(ctx context.Context, status int32, pagination pagination.Pagination) (int64, []*WithdrawApplication, error)
|
||||
UpdateStatus(ctx context.Context, applicationID string, status int32, auditorID string, auditRemark string) error
|
||||
Page(ctx context.Context, pagination pagination.Pagination) (int64, []*WithdrawApplication, error)
|
||||
Update(ctx context.Context, applicationID string, data map[string]any) error
|
||||
}
|
||||
Reference in New Issue
Block a user