feat: The 'chat_models' field of user table, holds the model IDS in place of the model values

This commit is contained in:
RockYang
2024-03-18 15:37:46 +08:00
parent 172d498618
commit c72d963f45
13 changed files with 73 additions and 76 deletions

View File

@@ -32,7 +32,7 @@ func (h *ChatModelHandler) List(c *gin.Context) {
return
}
var models []string
var models []int
err = utils.JsonDecode(user.ChatModels, &models)
if err != nil {
resp.ERROR(c, "当前用户没有订阅任何模型")
@@ -41,7 +41,7 @@ func (h *ChatModelHandler) List(c *gin.Context) {
// 查询用户有权限访问的模型以及所有开放的模型
res := h.db.Where("enabled = ?", true).Where(
h.db.Where("value IN ?", models).Or("open =?", true),
h.db.Where("id IN ?", models).Or("open =?", true),
).Order("sort_num ASC").Find(&items)
if res.Error == nil {
for _, item := range items {