添加mongodb使用,添加用户前端配置的上传及获取接口
This commit is contained in:
parent
0897d1e562
commit
a265cd459b
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
|
|
@ -300,6 +301,7 @@ func CreateUserUIConfigInfo(config proto.UserUIConfigInfo) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUserUIConfigInfo(userID int) (proto.UserUIConfigInfo, error) {
|
func GetUserUIConfigInfo(userID int) (proto.UserUIConfigInfo, error) {
|
||||||
|
log.Println("get user ui config info database:", proto.Config.MONGO_DATABASE, " collection:", UserUIConfigCollection)
|
||||||
collection := mongoClient.Database(proto.Config.MONGO_DATABASE).Collection(UserUIConfigCollection)
|
collection := mongoClient.Database(proto.Config.MONGO_DATABASE).Collection(UserUIConfigCollection)
|
||||||
var config proto.UserUIConfigInfo
|
var config proto.UserUIConfigInfo
|
||||||
err := collection.FindOne(context.TODO(), bson.M{"user_id": userID}).Decode(&config)
|
err := collection.FindOne(context.TODO(), bson.M{"user_id": userID}).Decode(&config)
|
||||||
|
|
|
||||||
1
main.go
1
main.go
|
|
@ -47,6 +47,7 @@ func main() {
|
||||||
handler.SetUpIMGroup(r) // IM
|
handler.SetUpIMGroup(r) // IM
|
||||||
defer dao.Close()
|
defer dao.Close()
|
||||||
defer worker.CloseRedis()
|
defer worker.CloseRedis()
|
||||||
|
defer dao.CloseMongoDB()
|
||||||
//定时任务
|
//定时任务
|
||||||
c := cron.New(cron.WithSeconds())
|
c := cron.New(cron.WithSeconds())
|
||||||
// 添加每 10 秒执行一次的任务
|
// 添加每 10 秒执行一次的任务
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package proto
|
package proto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -125,15 +126,16 @@ type DeleteThirdPartyLoginReq struct {
|
||||||
|
|
||||||
// 用户对前端交互的配置信息结构,mongodb
|
// 用户对前端交互的配置信息结构,mongodb
|
||||||
type UserUIConfigInfo struct {
|
type UserUIConfigInfo struct {
|
||||||
UserID int `json:"user_id" form:"user_id"` // 用户ID
|
ID primitive.ObjectID `bson:"_id,omitempty"` // 自动生成ID
|
||||||
Theme string `json:"theme" form:"theme"` // 主题
|
UserID int `json:"user_id" form:"user_id" bson:"user_id"` // 用户ID
|
||||||
Language string `json:"language" form:"language"` // 语言
|
Theme string `json:"theme" form:"theme" bson:"theme"` // 主题
|
||||||
FontSize int `json:"font_size" form:"font_size"` // 字体大小
|
Language string `json:"language" form:"language" bson:"language"` // 语言
|
||||||
GenAIFunction UserUIFunctionConfigInfo `json:"gen_ai_function" form:"gen_ai_function"` // 生成AI功能配置
|
FontSize int `json:"font_size" form:"font_size" bson:"font_size"` // 字体大小
|
||||||
KBaseFunction UserUIFunctionConfigInfo `json:"k_base_function" form:"k_base_function"` // 知识库功能配置
|
GenAIFunction UserUIFunctionConfigInfo `json:"gen_ai_function" form:"gen_ai_function" bson:"gen_ai_function"` // 生成AI功能配置
|
||||||
|
KBaseFunction UserUIFunctionConfigInfo `json:"k_base_function" form:"k_base_function" bson:"k_base_function"` // 知识库功能配置
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserUIFunctionConfigInfo struct {
|
type UserUIFunctionConfigInfo struct {
|
||||||
ModelID int `json:"model_id" form:"model_id"` // 模型ID,选择的模型
|
ModelID int `json:"model_id" form:"model_id" bson:"model_id"` // 模型ID,选择的模型
|
||||||
SessionID int `json:"session_id" form:"session_id"` // 会话ID,上一次的会话
|
SessionID int `json:"session_id" form:"session_id" bson:"session_id"` // 会话ID,上一次的会话
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue