复制项目

This commit is contained in:
kim.dev.6789
2026-01-14 22:35:45 +08:00
parent 305d526110
commit b7f8db7d08
297 changed files with 81784 additions and 0 deletions

View 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 的配置
}