diff --git a/config.yaml.example b/config.yaml.example index d765719b..fb1beb5d 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -13,12 +13,3 @@ redis: port: 6379 # Redis端口 password: mNhgeSk32fUf69C6 db: 0 - -# AI回复 -ai: - # 模型,不填默认gpt-3.5-turbo-0613 - model: gpt-3.5-turbo-0613 - # 接口代理域名,不填默认ChatGPT官方地址 - baseUrl: https://sxxx - # 人设 - personality: 你的名字叫张三,你是一个百科机器人,你的爱好是看电影,你的性格是开朗的,你的专长是讲故事,你的梦想是当一名童话故事作家。你对政治没有一点儿兴趣,也不会讨论任何与政治相关的话题,你甚至可以拒绝回答这一类话题。 diff --git a/config/ai.go b/config/ai.go deleted file mode 100644 index c6ce0af7..00000000 --- a/config/ai.go +++ /dev/null @@ -1,9 +0,0 @@ -package config - -// ai -// @description: AI配置 -type ai struct { - Model string `json:"model" yaml:"model"` // 模型 - BaseUrl string `json:"baseUrl" yaml:"baseUrl"` // API地址 - Personality string `json:"personality" yaml:"personality"` // 默认人设 -} diff --git a/config/config.go b/config/config.go index f1297fc5..15602777 100644 --- a/config/config.go +++ b/config/config.go @@ -8,5 +8,4 @@ var Conf conf type conf struct { Database db `json:"database" yaml:"database"` // 数据库 配置 Redis redis `json:"redis" yaml:"redis"` // Redis 配置 - Ai ai `json:"ai" yaml:"ai"` // AI配置 } diff --git a/internal/initialize/datatable.go b/internal/initialize/datatable.go index 48862d94..f02ff6f6 100644 --- a/internal/initialize/datatable.go +++ b/internal/initialize/datatable.go @@ -15,7 +15,9 @@ func databaseTable() { new(entity.Role), // 角色表 new(entity.RoleMenu), // 角色菜单表 new(entity.AdminUserRole), // 用户角色表 + new(entity.SystemConfig), // 系统配置表 new(entity.Robot), // 机器人表 + new(entity.AiAssistant), // AI助手表 } // 同步表结构 diff --git a/model/entity/aiassistant.go b/model/entity/aiassistant.go new file mode 100644 index 00000000..e1fb78ee --- /dev/null +++ b/model/entity/aiassistant.go @@ -0,0 +1,20 @@ +package entity + +import "wechat-robot/pkg/types" + +// AiAssistant +// @description: AI助手表 +type AiAssistant struct { + types.BaseDbModel + Name string `json:"name" gorm:"type:varchar(10);not null;comment:'名称'"` + Personality string `json:"personality" gorm:"type:varchar(999);not null;comment:'人设'"` + Model string `json:"setting" gorm:"type:varchar(50);not null;comment:'使用的模型'"` +} + +// TableName +// @description: 表名 +// @receiver AiAssistant +// @return string +func (AiAssistant) TableName() string { + return "t_ai_assistant" +} diff --git a/model/entity/systemconfig.go b/model/entity/systemconfig.go new file mode 100644 index 00000000..cdab3b3e --- /dev/null +++ b/model/entity/systemconfig.go @@ -0,0 +1,19 @@ +package entity + +import "wechat-robot/pkg/types" + +// SystemConfig +// @description: 系统配置 +type SystemConfig struct { + types.BaseDbModelWithReal + Code string `json:"code" gorm:"type:varchar(255);not null;comment:'配置编码'"` + Content string `json:"content" gorm:"type:text;comment:'配置内容'"` +} + +// TableName +// @description: 表名 +// @receiver SystemConfig +// @return string +func (SystemConfig) TableName() string { + return "t_system_config" +} diff --git a/pkg/auth/handle/oauth2.go b/pkg/auth/handle/oauth2.go index 82108d5f..b930f2c2 100644 --- a/pkg/auth/handle/oauth2.go +++ b/pkg/auth/handle/oauth2.go @@ -64,7 +64,7 @@ func ExtensionFields(ti oauth2.TokenInfo) (fieldsValue map[string]any) { _ = database.Client.Take(&ui, "id = ?", ti.GetUserID()).Error fieldsValue["username"] = ui.Username fieldsValue["id"] = ui.Id - //fieldsValue["roles"] = strings.Split(ui.Role, ",") + fieldsValue["roles"] = []string{"admin"} return } diff --git a/pkg/types/userinfo.go b/pkg/types/userinfo.go new file mode 100644 index 00000000..ebbf0aac --- /dev/null +++ b/pkg/types/userinfo.go @@ -0,0 +1,25 @@ +package types + +import "fmt" + +// UserSex 用户性别 +type UserSex int + +const ( + UserSexMale UserSex = iota + 1 // 男 + UserSexFemale // 女 + UserSexUnknown // 未知 +) + +var userSexMap = map[UserSex]string{ + UserSexMale: "男", + UserSexFemale: "女", + UserSexUnknown: "未知", +} + +func (u UserSex) String() string { + if v, ok := userSexMap[u]; ok { + return v + } + return fmt.Sprintf("性别<%d>", u) +} diff --git a/service/menu/utils.go b/service/menu/utils.go index 5325e902..c5e82a9e 100644 --- a/service/menu/utils.go +++ b/service/menu/utils.go @@ -25,9 +25,10 @@ func toTree(records []menuRecordItem, pid string) (tree []menu.Item) { var node menu.Item node.Id = record.Id node.Path = record.Path + node.Name = record.Name var meta menu.ItemMeta - meta.Title = record.Name + meta.Title = record.Title meta.Icon = record.Icon meta.Rank = record.Sort if record.RoleCode != "" {