mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-18 01:06:39 +08:00
merge conflicts for v4.0.5
This commit is contained in:
commit
27c816cf3b
23
CHANGELOG.md
23
CHANGELOG.md
@ -1,5 +1,21 @@
|
|||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
## v4.0.5
|
||||||
|
|
||||||
|
* 功能优化:已授权系统在后台显示授权信息
|
||||||
|
* 功能优化:使用思维链提示词生成思维导图,确保生成的思维导图不会出现格式错误
|
||||||
|
* 功能优化:优化首页登录注册页面的 UI
|
||||||
|
* BUG修复:修复License验证的逻辑漏洞
|
||||||
|
* Bug修复:后台添加用户的时候密码规则限制跟前台注册保持一致
|
||||||
|
* 功能新增:管理后台支持切换主题,支持 light 和 dark 两种主题
|
||||||
|
* 功能新增:移动端新增 DALL-E 绘画功能
|
||||||
|
* 功能新增:新增移动端首页功能,移动端支持 light 和 dark 两种主题
|
||||||
|
* 功能新增:移动支持免登录预览功能
|
||||||
|
* Bug修复:解决在同一个浏览器开启多个对话时候对话内容会相互乱串的问题
|
||||||
|
* Bug修复:修复部分中转 API 模型会出现第一输出的字符被淹没的Bug
|
||||||
|
|
||||||
## v4.0.4
|
## v4.0.4
|
||||||
|
|
||||||
* Bug修复:修复统一千问第二句不回复的问题
|
* Bug修复:修复统一千问第二句不回复的问题
|
||||||
* 功能优化:MJ 和 SD 任务正在执行时不更新已完成任务列表,加快页面渲染速度
|
* 功能优化:MJ 和 SD 任务正在执行时不更新已完成任务列表,加快页面渲染速度
|
||||||
* 功能新增:Dalle AI 绘画功能实现
|
* 功能新增:Dalle AI 绘画功能实现
|
||||||
@ -21,15 +37,14 @@
|
|||||||
* 功能新增:支持为模型绑定 API KEY,比如为 GPT3.5 模型绑定免费的 API KEY 给用户免费使用来引流不至于消耗你的收费 KEY。
|
* 功能新增:支持为模型绑定 API KEY,比如为 GPT3.5 模型绑定免费的 API KEY 给用户免费使用来引流不至于消耗你的收费 KEY。
|
||||||
* 功能新增:支持管理后台 Logo 修改
|
* 功能新增:支持管理后台 Logo 修改
|
||||||
|
|
||||||
## v4.0.2
|
## 4.0.2
|
||||||
|
|
||||||
* 功能新增:支持前端菜单可以配置
|
* 功能新增:支持前端菜单可以配置
|
||||||
* 功能优化:在登录和注册界面标题显示软件版本号
|
* 功能优化:在登录和注册界面标题显示软件版本号
|
||||||
* 功能优化:MJ 绘画支持 --sref 和 --cref 图片一致性参数
|
* 功能优化:MJ 绘画支持 --sref 和 --cref 图片一致性参数
|
||||||
* 功能优化:使用 leveldb 解决 SD 绘图进度图片预览问题
|
* 功能优化:使用 leveldb 解决 SD 绘图进度图片预览问题
|
||||||
* Bug修复:解决因为图片上传使用相对路径而导致融图失败的问题
|
* Bug修复:解决因为图片上传使用相对路径而导致融图失败的问题。
|
||||||
* 功能新增:手机端支持 Stable-Diffusion 绘画
|
* 功能新增:手机端支持 Stable-Diffusion 绘画
|
||||||
* Bug修复:修复管理后台 API KEY 删除失败的问题
|
* 功能新增:管理后台登录页面增加行为验证码,防止爆破
|
||||||
|
|
||||||
## v4.0.1
|
## v4.0.1
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
SHELL=/usr/bin/env bash
|
SHELL=/usr/bin/env bash
|
||||||
NAME := chatgpt-plus
|
NAME := geekai
|
||||||
all: amd64 arm64
|
all: amd64 arm64
|
||||||
|
|
||||||
amd64:
|
amd64:
|
||||||
|
@ -108,7 +108,8 @@ WeChatBot = false
|
|||||||
ApiURL = "https://api.xunhupay.com"
|
ApiURL = "https://api.xunhupay.com"
|
||||||
NotifyURL = "https://ai.r9it.com/api/payment/hupipay/notify"
|
NotifyURL = "https://ai.r9it.com/api/payment/hupipay/notify"
|
||||||
|
|
||||||
[SmtpConfig] # 注意,阿里云服务器禁用了25号端口,所以如果需要使用邮件功能,请别用阿里云服务器
|
[SmtpConfig] # 注意,阿里云服务器禁用了25号端口,请使用 465 端口,并开启 TLS 连接
|
||||||
|
UseTls = false
|
||||||
Host = "smtp.163.com"
|
Host = "smtp.163.com"
|
||||||
Port = 25
|
Port = 25
|
||||||
AppName = "极客学长"
|
AppName = "极客学长"
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -200,10 +207,13 @@ func authorizeMiddleware(s *AppServer, client *redis.Client) gin.HandlerFunc {
|
|||||||
|
|
||||||
func needLogin(c *gin.Context) bool {
|
func needLogin(c *gin.Context) bool {
|
||||||
if c.Request.URL.Path == "/api/user/login" ||
|
if c.Request.URL.Path == "/api/user/login" ||
|
||||||
|
c.Request.URL.Path == "/api/user/logout" ||
|
||||||
c.Request.URL.Path == "/api/user/resetPass" ||
|
c.Request.URL.Path == "/api/user/resetPass" ||
|
||||||
c.Request.URL.Path == "/api/admin/login" ||
|
c.Request.URL.Path == "/api/admin/login" ||
|
||||||
|
c.Request.URL.Path == "/api/admin/logout" ||
|
||||||
c.Request.URL.Path == "/api/admin/login/captcha" ||
|
c.Request.URL.Path == "/api/admin/login/captcha" ||
|
||||||
c.Request.URL.Path == "/api/user/register" ||
|
c.Request.URL.Path == "/api/user/register" ||
|
||||||
|
c.Request.URL.Path == "/api/user/session" ||
|
||||||
c.Request.URL.Path == "/api/chat/history" ||
|
c.Request.URL.Path == "/api/chat/history" ||
|
||||||
c.Request.URL.Path == "/api/chat/detail" ||
|
c.Request.URL.Path == "/api/chat/detail" ||
|
||||||
c.Request.URL.Path == "/api/chat/list" ||
|
c.Request.URL.Path == "/api/chat/list" ||
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
logger2 "chatplus/logger"
|
logger2 "geekai/logger"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
// ApiRequest API 请求实体
|
// ApiRequest API 请求实体
|
||||||
type ApiRequest struct {
|
type ApiRequest struct {
|
||||||
Model string `json:"model,omitempty"` // 兼容百度文心一言
|
Model string `json:"model,omitempty"` // 兼容百度文心一言
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
@ -119,11 +126,11 @@ type RedisConfig struct {
|
|||||||
const LicenseKey = "Geek-AI-License"
|
const LicenseKey = "Geek-AI-License"
|
||||||
|
|
||||||
type License struct {
|
type License struct {
|
||||||
Key string // 许可证书密钥
|
Key string `json:"key"` // 许可证书密钥
|
||||||
MachineId string // 机器码
|
MachineId string `json:"machine_id"` // 机器码
|
||||||
UserNum int // 用户数量
|
UserNum int `json:"user_num"` // 用户数量
|
||||||
ExpiredAt int64 // 过期时间
|
ExpiredAt int64 `json:"expired_at"` // 过期时间
|
||||||
IsActive bool // 是否激活
|
IsActive bool `json:"is_active"` // 是否激活
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c RedisConfig) Url() string {
|
func (c RedisConfig) Url() string {
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
type ToolCall struct {
|
type ToolCall struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Function struct {
|
Function struct {
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
type OrderStatus int
|
type OrderStatus int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
type OSSConfig struct {
|
type OSSConfig struct {
|
||||||
Active string
|
Active string
|
||||||
Local LocalStorageConfig
|
Local LocalStorageConfig
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
const LoginUserID = "LOGIN_USER_ID"
|
const LoginUserID = "LOGIN_USER_ID"
|
||||||
const LoginUserCache = "LOGIN_USER_CACHE"
|
const LoginUserCache = "LOGIN_USER_CACHE"
|
||||||
|
|
||||||
const UserAuthHeader = "Authorization"
|
const UserAuthHeader = "Authorization"
|
||||||
const AdminAuthHeader = "Admin-Authorization"
|
const AdminAuthHeader = "Admin-Authorization"
|
||||||
const ChatTokenHeader = "Chat-Token"
|
|
||||||
|
|
||||||
// Session configs struct
|
// Session configs struct
|
||||||
type Session struct {
|
type Session struct {
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
type SMSConfig struct {
|
type SMSConfig struct {
|
||||||
Active string
|
Active string
|
||||||
Ali SmsConfigAli
|
Ali SmsConfigAli
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
// TaskType 任务类别
|
// TaskType 任务类别
|
||||||
type TaskType string
|
type TaskType string
|
||||||
|
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
// BizVo 业务返回 VO
|
// BizVo 业务返回 VO
|
||||||
type BizVo struct {
|
type BizVo struct {
|
||||||
Code BizCode `json:"code"`
|
Code BizCode `json:"code"`
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module chatplus
|
module geekai
|
||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/handler"
|
"geekai/handler"
|
||||||
logger2 "chatplus/logger"
|
logger2 "geekai/logger"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/handler"
|
"geekai/handler"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/handler"
|
"geekai/handler"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/mojocn/base64Captcha"
|
"github.com/mojocn/base64Captcha"
|
||||||
)
|
)
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/handler"
|
"geekai/handler"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/handler"
|
"geekai/handler"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/handler"
|
"geekai/handler"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
@ -1,24 +1,34 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/handler"
|
"geekai/handler"
|
||||||
"chatplus/store"
|
"geekai/service"
|
||||||
"chatplus/store/model"
|
"geekai/store"
|
||||||
"chatplus/utils"
|
"geekai/store/model"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils"
|
||||||
|
"geekai/utils/resp"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/shirou/gopsutil/host"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ConfigHandler struct {
|
type ConfigHandler struct {
|
||||||
handler.BaseHandler
|
handler.BaseHandler
|
||||||
levelDB *store.LevelDB
|
levelDB *store.LevelDB
|
||||||
|
licenseService *service.LicenseService
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfigHandler(app *core.AppServer, db *gorm.DB, levelDB *store.LevelDB) *ConfigHandler {
|
func NewConfigHandler(app *core.AppServer, db *gorm.DB, levelDB *store.LevelDB, licenseService *service.LicenseService) *ConfigHandler {
|
||||||
return &ConfigHandler{BaseHandler: handler.BaseHandler{App: app, DB: db}, levelDB: levelDB}
|
return &ConfigHandler{BaseHandler: handler.BaseHandler{App: app, DB: db}, levelDB: levelDB, licenseService: licenseService}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ConfigHandler) Update(c *gin.Context) {
|
func (h *ConfigHandler) Update(c *gin.Context) {
|
||||||
@ -88,3 +98,33 @@ func (h *ConfigHandler) Get(c *gin.Context) {
|
|||||||
|
|
||||||
resp.SUCCESS(c, value)
|
resp.SUCCESS(c, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Active 激活系统
|
||||||
|
func (h *ConfigHandler) Active(c *gin.Context) {
|
||||||
|
var data struct {
|
||||||
|
License string `json:"license"`
|
||||||
|
}
|
||||||
|
if err := c.ShouldBindJSON(&data); err != nil {
|
||||||
|
resp.ERROR(c, types.InvalidArgs)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
info, err := host.Info()
|
||||||
|
if err != nil {
|
||||||
|
resp.ERROR(c, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = h.licenseService.ActiveLicense(data.License, info.HostID)
|
||||||
|
if err != nil {
|
||||||
|
resp.ERROR(c, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.SUCCESS(c, info.HostID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLicense 获取 License 信息
|
||||||
|
func (h *ConfigHandler) GetLicense(c *gin.Context) {
|
||||||
|
license := h.licenseService.GetLicense()
|
||||||
|
resp.SUCCESS(c, license)
|
||||||
|
}
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/handler"
|
"geekai/handler"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/shopspring/decimal"
|
"github.com/shopspring/decimal"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/handler"
|
"geekai/handler"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
|
|
||||||
"github.com/golang-jwt/jwt/v5"
|
"github.com/golang-jwt/jwt/v5"
|
||||||
|
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/handler"
|
"geekai/handler"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/handler"
|
"geekai/handler"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/handler"
|
"geekai/handler"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/handler"
|
"geekai/handler"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"time"
|
"time"
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/handler"
|
"geekai/handler"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/handler"
|
"geekai/handler"
|
||||||
"chatplus/service/oss"
|
"geekai/service/oss"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"time"
|
"time"
|
||||||
|
@ -1,13 +1,21 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/handler"
|
"geekai/handler"
|
||||||
"chatplus/store/model"
|
"geekai/service"
|
||||||
"chatplus/store/vo"
|
"geekai/store/model"
|
||||||
"chatplus/utils"
|
"geekai/store/vo"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils"
|
||||||
|
"geekai/utils/resp"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -17,10 +25,11 @@ import (
|
|||||||
|
|
||||||
type UserHandler struct {
|
type UserHandler struct {
|
||||||
handler.BaseHandler
|
handler.BaseHandler
|
||||||
|
licenseService *service.LicenseService
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserHandler(app *core.AppServer, db *gorm.DB) *UserHandler {
|
func NewUserHandler(app *core.AppServer, db *gorm.DB, licenseService *service.LicenseService) *UserHandler {
|
||||||
return &UserHandler{BaseHandler: handler.BaseHandler{App: app, DB: db}}
|
return &UserHandler{BaseHandler: handler.BaseHandler{App: app, DB: db}, licenseService: licenseService}
|
||||||
}
|
}
|
||||||
|
|
||||||
// List 用户列表
|
// List 用户列表
|
||||||
@ -75,6 +84,13 @@ func (h *UserHandler) Save(c *gin.Context) {
|
|||||||
resp.ERROR(c, types.InvalidArgs)
|
resp.ERROR(c, types.InvalidArgs)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// 检测最大注册人数
|
||||||
|
var totalUser int64
|
||||||
|
h.DB.Model(&model.User{}).Count(&totalUser)
|
||||||
|
if int(totalUser) >= h.licenseService.GetLicense().UserNum {
|
||||||
|
resp.ERROR(c, "当前注册用户数已达上限,请请升级 License")
|
||||||
|
return
|
||||||
|
}
|
||||||
var user = model.User{}
|
var user = model.User{}
|
||||||
var res *gorm.DB
|
var res *gorm.DB
|
||||||
var userVo vo.User
|
var userVo vo.User
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
logger2 "chatplus/logger"
|
logger2 "geekai/logger"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/service"
|
"geekai/service"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package chatimpl
|
package chatimpl
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package chatimpl
|
package chatimpl
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,20 +1,28 @@
|
|||||||
package chatimpl
|
package chatimpl
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"chatplus/core"
|
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/handler"
|
|
||||||
logger2 "chatplus/logger"
|
|
||||||
"chatplus/service/oss"
|
|
||||||
"chatplus/store/model"
|
|
||||||
"chatplus/store/vo"
|
|
||||||
"chatplus/utils"
|
|
||||||
"chatplus/utils/resp"
|
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/handler"
|
||||||
|
logger2 "geekai/logger"
|
||||||
|
"geekai/service"
|
||||||
|
"geekai/service/oss"
|
||||||
|
"geekai/store/model"
|
||||||
|
"geekai/store/vo"
|
||||||
|
"geekai/utils"
|
||||||
|
"geekai/utils/resp"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
@ -35,15 +43,17 @@ var logger = logger2.GetLogger()
|
|||||||
|
|
||||||
type ChatHandler struct {
|
type ChatHandler struct {
|
||||||
handler.BaseHandler
|
handler.BaseHandler
|
||||||
redis *redis.Client
|
redis *redis.Client
|
||||||
uploadManager *oss.UploaderManager
|
uploadManager *oss.UploaderManager
|
||||||
|
licenseService *service.LicenseService
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewChatHandler(app *core.AppServer, db *gorm.DB, redis *redis.Client, manager *oss.UploaderManager) *ChatHandler {
|
func NewChatHandler(app *core.AppServer, db *gorm.DB, redis *redis.Client, manager *oss.UploaderManager, licenseService *service.LicenseService) *ChatHandler {
|
||||||
return &ChatHandler{
|
return &ChatHandler{
|
||||||
BaseHandler: handler.BaseHandler{App: app, DB: db},
|
BaseHandler: handler.BaseHandler{App: app, DB: db},
|
||||||
redis: redis,
|
redis: redis,
|
||||||
uploadManager: manager,
|
uploadManager: manager,
|
||||||
|
licenseService: licenseService,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,8 +144,10 @@ func (h *ChatHandler) ChatHandle(c *gin.Context) {
|
|||||||
for {
|
for {
|
||||||
_, msg, err := client.Receive()
|
_, msg, err := client.Receive()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logger.Debugf("close connection: %s", client.Conn.RemoteAddr())
|
||||||
client.Close()
|
client.Close()
|
||||||
h.App.ChatClients.Delete(sessionId)
|
h.App.ChatClients.Delete(sessionId)
|
||||||
|
h.App.ChatSession.Delete(sessionId)
|
||||||
cancelFunc := h.App.ReqCancelFunc.Get(sessionId)
|
cancelFunc := h.App.ReqCancelFunc.Get(sessionId)
|
||||||
if cancelFunc != nil {
|
if cancelFunc != nil {
|
||||||
cancelFunc()
|
cancelFunc()
|
||||||
@ -469,16 +481,24 @@ func (h *ChatHandler) StopGenerate(c *gin.Context) {
|
|||||||
func (h *ChatHandler) doRequest(ctx context.Context, req types.ApiRequest, session *types.ChatSession, apiKey *model.ApiKey) (*http.Response, error) {
|
func (h *ChatHandler) doRequest(ctx context.Context, req types.ApiRequest, session *types.ChatSession, apiKey *model.ApiKey) (*http.Response, error) {
|
||||||
// if the chat model bind a KEY, use it directly
|
// if the chat model bind a KEY, use it directly
|
||||||
if session.Model.KeyId > 0 {
|
if session.Model.KeyId > 0 {
|
||||||
h.DB.Debug().Where("id", session.Model.KeyId).Find(apiKey)
|
h.DB.Debug().Where("id", session.Model.KeyId).Where("enabled", true).Find(apiKey)
|
||||||
}
|
}
|
||||||
// use the last unused key
|
// use the last unused key
|
||||||
if apiKey.Id == 0 {
|
if apiKey.Id == 0 {
|
||||||
h.DB.Debug().Where("platform = ?", session.Model.Platform).Where("type = ?", "chat").Where("enabled = ?", true).Order("last_used_at ASC").First(apiKey)
|
h.DB.Debug().Where("platform", session.Model.Platform).Where("type", "chat").Where("enabled", true).Order("last_used_at ASC").First(apiKey)
|
||||||
}
|
}
|
||||||
if apiKey.Id == 0 {
|
if apiKey.Id == 0 {
|
||||||
return nil, errors.New("no available key, please import key")
|
return nil, errors.New("no available key, please import key")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ONLY allow apiURL in blank list
|
||||||
|
if session.Model.Platform == types.OpenAI {
|
||||||
|
err := h.licenseService.IsValidApiURL(apiKey.ApiURL)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var apiURL string
|
var apiURL string
|
||||||
switch session.Model.Platform {
|
switch session.Model.Platform {
|
||||||
case types.Azure:
|
case types.Azure:
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package chatimpl
|
package chatimpl
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
@ -187,12 +194,20 @@ func (h *ChatHandler) Detail(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 填充角色名称
|
||||||
|
var role model.ChatRole
|
||||||
|
res = h.DB.Where("id", chatItem.RoleId).First(&role)
|
||||||
|
if res.Error != nil {
|
||||||
|
resp.ERROR(c, "Role not found")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var chatItemVo vo.ChatItem
|
var chatItemVo vo.ChatItem
|
||||||
err := utils.CopyObject(chatItem, &chatItemVo)
|
err := utils.CopyObject(chatItem, &chatItemVo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resp.ERROR(c, err.Error())
|
resp.ERROR(c, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
chatItemVo.RoleName = role.Name
|
||||||
resp.SUCCESS(c, chatItemVo)
|
resp.SUCCESS(c, chatItemVo)
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package chatimpl
|
package chatimpl
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
package chatimpl
|
package chatimpl
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/store/model"
|
|
||||||
"chatplus/store/vo"
|
|
||||||
"chatplus/utils"
|
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/store/model"
|
||||||
|
"geekai/store/vo"
|
||||||
|
"geekai/utils"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
@ -68,12 +75,16 @@ func (h *ChatHandler) sendOpenAiMessage(
|
|||||||
|
|
||||||
var responseBody = types.ApiResponse{}
|
var responseBody = types.ApiResponse{}
|
||||||
err = json.Unmarshal([]byte(line[6:]), &responseBody)
|
err = json.Unmarshal([]byte(line[6:]), &responseBody)
|
||||||
if err != nil || len(responseBody.Choices) == 0 { // 数据解析出错
|
if err != nil { // 数据解析出错
|
||||||
logger.Error(err, line)
|
logger.Error(err, line)
|
||||||
utils.ReplyMessage(ws, ErrorMsg)
|
utils.ReplyMessage(ws, ErrorMsg)
|
||||||
utils.ReplyMessage(ws, ErrImg)
|
utils.ReplyMessage(ws, ErrImg)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if len(responseBody.Choices) == 0 { // Fixed: 兼容 Azure API 第一个输出空行
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if responseBody.Choices[0].FinishReason == "stop" && len(contents) == 0 {
|
if responseBody.Choices[0].FinishReason == "stop" && len(contents) == 0 {
|
||||||
utils.ReplyMessage(ws, "抱歉😔😔😔,AI助手由于未知原因已经停止输出内容。")
|
utils.ReplyMessage(ws, "抱歉😔😔😔,AI助手由于未知原因已经停止输出内容。")
|
||||||
break
|
break
|
||||||
@ -115,11 +126,8 @@ func (h *ChatHandler) sendOpenAiMessage(
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化 role
|
// output stopped
|
||||||
if responseBody.Choices[0].Delta.Role != "" && message.Role == "" {
|
if responseBody.Choices[0].FinishReason != "" {
|
||||||
message.Role = responseBody.Choices[0].Delta.Role
|
|
||||||
continue
|
|
||||||
} else if responseBody.Choices[0].FinishReason != "" {
|
|
||||||
break // 输出完成或者输出中断了
|
break // 输出完成或者输出中断了
|
||||||
} else {
|
} else {
|
||||||
content := responseBody.Choices[0].Delta.Content
|
content := responseBody.Choices[0].Delta.Content
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package chatimpl
|
package chatimpl
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,16 +1,23 @@
|
|||||||
package chatimpl
|
package chatimpl
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/store/model"
|
|
||||||
"chatplus/store/vo"
|
|
||||||
"chatplus/utils"
|
|
||||||
"context"
|
"context"
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/store/model"
|
||||||
|
"geekai/store/vo"
|
||||||
|
"geekai/utils"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"html/template"
|
"html/template"
|
||||||
@ -73,11 +80,11 @@ func (h *ChatHandler) sendXunFeiMessage(
|
|||||||
var res *gorm.DB
|
var res *gorm.DB
|
||||||
// use the bind key
|
// use the bind key
|
||||||
if session.Model.KeyId > 0 {
|
if session.Model.KeyId > 0 {
|
||||||
res = h.DB.Where("id", session.Model.KeyId).Find(&apiKey)
|
res = h.DB.Where("id", session.Model.KeyId).Where("enabled", true).Find(&apiKey)
|
||||||
}
|
}
|
||||||
// use the last unused key
|
// use the last unused key
|
||||||
if res.Error != nil {
|
if res.Error != nil {
|
||||||
res = h.DB.Where("platform = ?", session.Model.Platform).Where("type = ?", "chat").Where("enabled = ?", true).Order("last_used_at ASC").First(&apiKey)
|
res = h.DB.Where("platform", session.Model.Platform).Where("type", "chat").Where("enabled", true).Order("last_used_at ASC").First(&apiKey)
|
||||||
}
|
}
|
||||||
if res.Error != nil {
|
if res.Error != nil {
|
||||||
utils.ReplyMessage(ws, "抱歉😔😔😔,系统已经没有可用的 API KEY,请联系管理员!")
|
utils.ReplyMessage(ws, "抱歉😔😔😔,系统已经没有可用的 API KEY,请联系管理员!")
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/service/dalle"
|
"geekai/service/dalle"
|
||||||
"chatplus/service/oss"
|
"geekai/service/oss"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
@ -86,7 +93,7 @@ func (h *DallJobHandler) preCheck(c *gin.Context) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if user.Power < h.App.SysConfig.DallPower {
|
if user.Power < h.App.SysConfig.SdPower {
|
||||||
resp.ERROR(c, "当前用户剩余算力不足以完成本次绘画!")
|
resp.ERROR(c, "当前用户剩余算力不足以完成本次绘画!")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/service/dalle"
|
"geekai/service/dalle"
|
||||||
"chatplus/service/oss"
|
"geekai/service/oss"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
@ -181,6 +188,11 @@ func (h *FunctionHandler) Dall3(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if user.Power < h.App.SysConfig.DallPower {
|
||||||
|
resp.ERROR(c, "创建 DALL-E 绘图任务失败,算力不足")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// create dall task
|
// create dall task
|
||||||
prompt := utils.InterfaceToString(params["prompt"])
|
prompt := utils.InterfaceToString(params["prompt"])
|
||||||
job := model.DallJob{
|
job := model.DallJob{
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -1,15 +1,22 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"chatplus/core"
|
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/store/model"
|
|
||||||
"chatplus/utils"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/store/model"
|
||||||
|
"geekai/utils"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
@ -199,25 +206,6 @@ func (h *MarkMapHandler) sendMessage(client *types.WsClient, prompt string, mode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 扣减算力
|
|
||||||
res = h.DB.Model(&model.User{}).Where("id", userId).UpdateColumn("power", gorm.Expr("power - ?", chatModel.Power))
|
|
||||||
if res.Error == nil {
|
|
||||||
// 记录算力消费日志
|
|
||||||
var u model.User
|
|
||||||
h.DB.Where("id", userId).First(&u)
|
|
||||||
h.DB.Create(&model.PowerLog{
|
|
||||||
UserId: u.Id,
|
|
||||||
Username: u.Username,
|
|
||||||
Type: types.PowerConsume,
|
|
||||||
Amount: chatModel.Power,
|
|
||||||
Mark: types.PowerSub,
|
|
||||||
Balance: u.Power,
|
|
||||||
Model: chatModel.Value,
|
|
||||||
Remark: fmt.Sprintf("AI绘制思维导图,模型名称:%s, ", chatModel.Value),
|
|
||||||
CreatedAt: time.Now(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,11 +213,13 @@ func (h *MarkMapHandler) doRequest(req types.ApiRequest, chatModel model.ChatMod
|
|||||||
// if the chat model bind a KEY, use it directly
|
// if the chat model bind a KEY, use it directly
|
||||||
var res *gorm.DB
|
var res *gorm.DB
|
||||||
if chatModel.KeyId > 0 {
|
if chatModel.KeyId > 0 {
|
||||||
res = h.DB.Where("id", chatModel.KeyId).Find(apiKey)
|
res = h.DB.Where("id", chatModel.KeyId).Where("enabled", true).Find(apiKey)
|
||||||
}
|
}
|
||||||
// use the last unused key
|
// use the last unused key
|
||||||
if apiKey.Id == 0 {
|
if apiKey.Id == 0 {
|
||||||
res = h.DB.Where("platform = ?", types.OpenAI).Where("type = ?", "chat").Where("enabled = ?", true).Order("last_used_at ASC").First(apiKey)
|
res = h.DB.Where("platform", types.OpenAI).
|
||||||
|
Where("type", "chat").
|
||||||
|
Where("enabled", true).Order("last_used_at ASC").First(apiKey)
|
||||||
}
|
}
|
||||||
if res.Error != nil {
|
if res.Error != nil {
|
||||||
return nil, errors.New("no available key, please import key")
|
return nil, errors.New("no available key, please import key")
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
@ -1,15 +1,22 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/service"
|
"geekai/service"
|
||||||
"chatplus/service/mj"
|
"geekai/service/mj"
|
||||||
"chatplus/service/oss"
|
"geekai/service/oss"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/service"
|
"geekai/service"
|
||||||
"chatplus/service/payment"
|
"geekai/service/payment"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"embed"
|
"embed"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -1,16 +1,23 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/service"
|
"geekai/service"
|
||||||
"chatplus/service/oss"
|
"geekai/service/oss"
|
||||||
"chatplus/service/sd"
|
"geekai/service/sd"
|
||||||
"chatplus/store"
|
"geekai/store"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/service"
|
"geekai/service"
|
||||||
"chatplus/service/sms"
|
"geekai/service/sms"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/service"
|
"geekai/service"
|
||||||
"chatplus/service/payment"
|
"geekai/service/payment"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/service/oss"
|
"geekai/service/oss"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/store/vo"
|
"geekai/store/vo"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils/resp"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"time"
|
"time"
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
"geekai/core"
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"chatplus/store/model"
|
"geekai/service"
|
||||||
"chatplus/store/vo"
|
"geekai/store/model"
|
||||||
"chatplus/utils"
|
"geekai/store/vo"
|
||||||
"chatplus/utils/resp"
|
"geekai/utils"
|
||||||
|
"geekai/utils/resp"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -21,16 +29,23 @@ import (
|
|||||||
|
|
||||||
type UserHandler struct {
|
type UserHandler struct {
|
||||||
BaseHandler
|
BaseHandler
|
||||||
searcher *xdb.Searcher
|
searcher *xdb.Searcher
|
||||||
redis *redis.Client
|
redis *redis.Client
|
||||||
|
licenseService *service.LicenseService
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserHandler(
|
func NewUserHandler(
|
||||||
app *core.AppServer,
|
app *core.AppServer,
|
||||||
db *gorm.DB,
|
db *gorm.DB,
|
||||||
searcher *xdb.Searcher,
|
searcher *xdb.Searcher,
|
||||||
client *redis.Client) *UserHandler {
|
client *redis.Client,
|
||||||
return &UserHandler{BaseHandler: BaseHandler{DB: db, App: app}, searcher: searcher, redis: client}
|
licenseService *service.LicenseService) *UserHandler {
|
||||||
|
return &UserHandler{
|
||||||
|
BaseHandler: BaseHandler{DB: db, App: app},
|
||||||
|
searcher: searcher,
|
||||||
|
redis: client,
|
||||||
|
licenseService: licenseService,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register user register
|
// Register user register
|
||||||
@ -53,9 +68,17 @@ func (h *UserHandler) Register(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检测最大注册人数
|
||||||
|
var totalUser int64
|
||||||
|
h.DB.Model(&model.User{}).Count(&totalUser)
|
||||||
|
if int(totalUser) >= h.licenseService.GetLicense().UserNum {
|
||||||
|
resp.ERROR(c, "当前注册用户数已达上限,请请升级 License")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 检查验证码
|
// 检查验证码
|
||||||
var key string
|
var key string
|
||||||
if data.RegWay == "email" || data.RegWay == "mobile" || data.Code != "" {
|
if data.RegWay == "email" || data.RegWay == "mobile" {
|
||||||
key = CodeStorePrefix + data.Username
|
key = CodeStorePrefix + data.Username
|
||||||
code, err := h.redis.Get(c, key).Result()
|
code, err := h.redis.Get(c, key).Result()
|
||||||
if err != nil || code != data.Code {
|
if err != nil || code != data.Code {
|
||||||
@ -216,18 +239,10 @@ func (h *UserHandler) Login(c *gin.Context) {
|
|||||||
|
|
||||||
// Logout 注 销
|
// Logout 注 销
|
||||||
func (h *UserHandler) Logout(c *gin.Context) {
|
func (h *UserHandler) Logout(c *gin.Context) {
|
||||||
sessionId := c.GetHeader(types.ChatTokenHeader)
|
|
||||||
key := h.GetUserKey(c)
|
key := h.GetUserKey(c)
|
||||||
if _, err := h.redis.Del(c, key).Result(); err != nil {
|
if _, err := h.redis.Del(c, key).Result(); err != nil {
|
||||||
logger.Error("error with delete session: ", err)
|
logger.Error("error with delete session: ", err)
|
||||||
}
|
}
|
||||||
// 删除 websocket 会话列表
|
|
||||||
h.App.ChatSession.Delete(sessionId)
|
|
||||||
// 关闭 socket 连接
|
|
||||||
client := h.App.ChatClients.Get(sessionId)
|
|
||||||
if client != nil {
|
|
||||||
client.Close()
|
|
||||||
}
|
|
||||||
resp.SUCCESS(c)
|
resp.SUCCESS(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package logger
|
package logger
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
|
44
api/main.go
44
api/main.go
@ -1,23 +1,30 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core"
|
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/handler"
|
|
||||||
"chatplus/handler/admin"
|
|
||||||
"chatplus/handler/chatimpl"
|
|
||||||
logger2 "chatplus/logger"
|
|
||||||
"chatplus/service"
|
|
||||||
"chatplus/service/dalle"
|
|
||||||
"chatplus/service/mj"
|
|
||||||
"chatplus/service/oss"
|
|
||||||
"chatplus/service/payment"
|
|
||||||
"chatplus/service/sd"
|
|
||||||
"chatplus/service/sms"
|
|
||||||
"chatplus/service/wx"
|
|
||||||
"chatplus/store"
|
|
||||||
"context"
|
"context"
|
||||||
"embed"
|
"embed"
|
||||||
|
"geekai/core"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/handler"
|
||||||
|
"geekai/handler/admin"
|
||||||
|
"geekai/handler/chatimpl"
|
||||||
|
logger2 "geekai/logger"
|
||||||
|
"geekai/service"
|
||||||
|
"geekai/service/dalle"
|
||||||
|
"geekai/service/mj"
|
||||||
|
"geekai/service/oss"
|
||||||
|
"geekai/service/payment"
|
||||||
|
"geekai/service/sd"
|
||||||
|
"geekai/service/sms"
|
||||||
|
"geekai/service/wx"
|
||||||
|
"geekai/store"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
@ -164,6 +171,11 @@ func main() {
|
|||||||
|
|
||||||
// 邮件服务
|
// 邮件服务
|
||||||
fx.Provide(service.NewSmtpService),
|
fx.Provide(service.NewSmtpService),
|
||||||
|
// License 服务
|
||||||
|
fx.Provide(service.NewLicenseService),
|
||||||
|
fx.Invoke(func(licenseService *service.LicenseService) {
|
||||||
|
licenseService.SyncLicense()
|
||||||
|
}),
|
||||||
|
|
||||||
// 微信机器人服务
|
// 微信机器人服务
|
||||||
fx.Provide(wx.NewWeChatBot),
|
fx.Provide(wx.NewWeChatBot),
|
||||||
@ -288,6 +300,8 @@ func main() {
|
|||||||
group := s.Engine.Group("/api/admin/")
|
group := s.Engine.Group("/api/admin/")
|
||||||
group.POST("config/update", h.Update)
|
group.POST("config/update", h.Update)
|
||||||
group.GET("config/get", h.Get)
|
group.GET("config/get", h.Get)
|
||||||
|
group.POST("active", h.Active)
|
||||||
|
group.GET("config/get/license", h.GetLicense)
|
||||||
}),
|
}),
|
||||||
fx.Invoke(func(s *core.AppServer, h *admin.ManagerHandler) {
|
fx.Invoke(func(s *core.AppServer, h *admin.ManagerHandler) {
|
||||||
group := s.Engine.Group("/api/admin/")
|
group := s.Engine.Group("/api/admin/")
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
"github.com/imroc/req/v3"
|
"github.com/imroc/req/v3"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
package dalle
|
package dalle
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
logger2 "chatplus/logger"
|
logger2 "geekai/logger"
|
||||||
"chatplus/service"
|
"geekai/service"
|
||||||
"chatplus/service/oss"
|
"geekai/service/oss"
|
||||||
"chatplus/service/sd"
|
"geekai/service/sd"
|
||||||
"chatplus/store"
|
"geekai/store"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"chatplus/utils"
|
"geekai/utils"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
@ -263,7 +270,7 @@ func (s *Service) CheckTaskStatus() {
|
|||||||
go func() {
|
go func() {
|
||||||
logger.Info("Running Stable-Diffusion task status checking ...")
|
logger.Info("Running Stable-Diffusion task status checking ...")
|
||||||
for {
|
for {
|
||||||
var jobs []model.SdJob
|
var jobs []model.DallJob
|
||||||
res := s.db.Where("progress < ?", 100).Find(&jobs)
|
res := s.db.Where("progress < ?", 100).Find(&jobs)
|
||||||
if res.Error != nil {
|
if res.Error != nil {
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
@ -287,7 +294,7 @@ func (s *Service) CheckTaskStatus() {
|
|||||||
Balance: user.Power + job.Power,
|
Balance: user.Power + job.Power,
|
||||||
Mark: types.PowerAdd,
|
Mark: types.PowerAdd,
|
||||||
Model: "dall-e-3",
|
Model: "dall-e-3",
|
||||||
Remark: fmt.Sprintf("任务失败,退回算力。任务ID:%s", job.TaskId),
|
Remark: fmt.Sprintf("任务失败,退回算力。任务ID:%d", job.Id),
|
||||||
CreatedAt: time.Now(),
|
CreatedAt: time.Now(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
195
api/service/license_service.go
Normal file
195
api/service/license_service.go
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"geekai/core"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/store"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/imroc/req/v3"
|
||||||
|
"github.com/shirou/gopsutil/host"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LicenseService struct {
|
||||||
|
config types.ApiConfig
|
||||||
|
levelDB *store.LevelDB
|
||||||
|
license *types.License
|
||||||
|
urlWhiteList []string
|
||||||
|
machineId string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewLicenseService(server *core.AppServer, levelDB *store.LevelDB) *LicenseService {
|
||||||
|
var license types.License
|
||||||
|
var machineId string
|
||||||
|
_ = levelDB.Get(types.LicenseKey, &license)
|
||||||
|
info, err := host.Info()
|
||||||
|
if err == nil {
|
||||||
|
machineId = info.HostID
|
||||||
|
}
|
||||||
|
logger.Infof("License: %+v", license)
|
||||||
|
return &LicenseService{
|
||||||
|
config: server.Config.ApiConfig,
|
||||||
|
levelDB: levelDB,
|
||||||
|
license: &license,
|
||||||
|
machineId: machineId,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type License struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
License string `json:"license"`
|
||||||
|
Mid string `json:"mid"`
|
||||||
|
ActiveAt int64 `json:"active_at"`
|
||||||
|
ExpiredAt int64 `json:"expired_at"`
|
||||||
|
UserNum int `json:"user_num"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActiveLicense 激活 License
|
||||||
|
func (s *LicenseService) ActiveLicense(license string, machineId string) error {
|
||||||
|
var res struct {
|
||||||
|
Code types.BizCode `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
Data License `json:"data"`
|
||||||
|
}
|
||||||
|
apiURL := fmt.Sprintf("%s/%s", s.config.ApiURL, "api/license/active")
|
||||||
|
response, err := req.C().R().
|
||||||
|
SetBody(map[string]string{"license": license, "machine_id": machineId}).
|
||||||
|
SetSuccessResult(&res).Post(apiURL)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("发送激活请求失败: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if response.IsErrorState() {
|
||||||
|
return fmt.Errorf("发送激活请求失败:%v", response.Status)
|
||||||
|
}
|
||||||
|
|
||||||
|
if res.Code != types.Success {
|
||||||
|
return fmt.Errorf("激活失败:%v", res.Message)
|
||||||
|
}
|
||||||
|
|
||||||
|
s.license = &types.License{
|
||||||
|
Key: license,
|
||||||
|
MachineId: machineId,
|
||||||
|
UserNum: res.Data.UserNum,
|
||||||
|
ExpiredAt: res.Data.ExpiredAt,
|
||||||
|
IsActive: true,
|
||||||
|
}
|
||||||
|
err = s.levelDB.Put(types.LicenseKey, s.license)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("保存许可证书失败:%v", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SyncLicense 定期同步 License
|
||||||
|
func (s *LicenseService) SyncLicense() {
|
||||||
|
go func() {
|
||||||
|
retryCounter := 0
|
||||||
|
for {
|
||||||
|
license, err := s.fetchLicense()
|
||||||
|
if err != nil {
|
||||||
|
retryCounter++
|
||||||
|
if retryCounter < 5 {
|
||||||
|
logger.Error(err)
|
||||||
|
}
|
||||||
|
s.license.IsActive = false
|
||||||
|
} else {
|
||||||
|
s.license = license
|
||||||
|
}
|
||||||
|
|
||||||
|
urls, err := s.fetchUrlWhiteList()
|
||||||
|
if err == nil {
|
||||||
|
s.urlWhiteList = urls
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(time.Second * 10)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *LicenseService) fetchLicense() (*types.License, error) {
|
||||||
|
var res struct {
|
||||||
|
Code types.BizCode `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
Data License `json:"data"`
|
||||||
|
}
|
||||||
|
apiURL := fmt.Sprintf("%s/%s", s.config.ApiURL, "api/license/check")
|
||||||
|
response, err := req.C().R().
|
||||||
|
SetBody(map[string]string{"license": s.license.Key, "machine_id": s.machineId}).
|
||||||
|
SetSuccessResult(&res).Post(apiURL)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("发送激活请求失败: %v", err)
|
||||||
|
}
|
||||||
|
if response.IsErrorState() {
|
||||||
|
return nil, fmt.Errorf("激活失败:%v", response.Status)
|
||||||
|
}
|
||||||
|
if res.Code != types.Success {
|
||||||
|
return nil, fmt.Errorf("激活失败:%v", res.Message)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.License{
|
||||||
|
Key: res.Data.License,
|
||||||
|
MachineId: res.Data.Mid,
|
||||||
|
UserNum: res.Data.UserNum,
|
||||||
|
ExpiredAt: res.Data.ExpiredAt,
|
||||||
|
IsActive: true,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *LicenseService) fetchUrlWhiteList() ([]string, error) {
|
||||||
|
var res struct {
|
||||||
|
Code types.BizCode `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
Data []string `json:"data"`
|
||||||
|
}
|
||||||
|
apiURL := fmt.Sprintf("%s/%s", s.config.ApiURL, "api/license/urls")
|
||||||
|
response, err := req.C().R().SetSuccessResult(&res).Get(apiURL)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("发送请求失败: %v", err)
|
||||||
|
}
|
||||||
|
if response.IsErrorState() {
|
||||||
|
return nil, fmt.Errorf("发送请求失败:%v", response.Status)
|
||||||
|
}
|
||||||
|
if res.Code != types.Success {
|
||||||
|
return nil, fmt.Errorf("获取白名单失败:%v", res.Message)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.Data, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLicense 获取许可信息
|
||||||
|
func (s *LicenseService) GetLicense() *types.License {
|
||||||
|
return s.license
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsValidApiURL 判断是否合法的中转 URL
|
||||||
|
func (s *LicenseService) IsValidApiURL(uri string) error {
|
||||||
|
// 获得许可授权的直接放行
|
||||||
|
if s.license.IsActive {
|
||||||
|
if s.license.MachineId != s.machineId {
|
||||||
|
return errors.New("系统使用了盗版的许可证书")
|
||||||
|
}
|
||||||
|
|
||||||
|
if time.Now().Unix() > s.license.ExpiredAt {
|
||||||
|
return errors.New("系统许可证书已经过期")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range s.urlWhiteList {
|
||||||
|
if strings.HasPrefix(uri, v) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fmt.Errorf("当前 API 地址 %s 不在白名单列表当中。", uri)
|
||||||
|
}
|
@ -1,6 +1,13 @@
|
|||||||
package mj
|
package mj
|
||||||
|
|
||||||
import "chatplus/core/types"
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
|
import "geekai/core/types"
|
||||||
|
|
||||||
type Client interface {
|
type Client interface {
|
||||||
Imagine(task types.MjTask) (ImageRes, error)
|
Imagine(task types.MjTask) (ImageRes, error)
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package mj
|
package mj
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/utils"
|
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/utils"
|
||||||
"github.com/imroc/req/v3"
|
"github.com/imroc/req/v3"
|
||||||
"io"
|
"io"
|
||||||
"time"
|
"time"
|
||||||
|
@ -1,13 +1,21 @@
|
|||||||
package mj
|
package mj
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
logger2 "chatplus/logger"
|
|
||||||
"chatplus/service/oss"
|
|
||||||
"chatplus/service/sd"
|
|
||||||
"chatplus/store"
|
|
||||||
"chatplus/store/model"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
logger2 "geekai/logger"
|
||||||
|
"geekai/service"
|
||||||
|
"geekai/service/oss"
|
||||||
|
"geekai/service/sd"
|
||||||
|
"geekai/store"
|
||||||
|
"geekai/store/model"
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -26,7 +34,7 @@ type ServicePool struct {
|
|||||||
|
|
||||||
var logger = logger2.GetLogger()
|
var logger = logger2.GetLogger()
|
||||||
|
|
||||||
func NewServicePool(db *gorm.DB, redisCli *redis.Client, manager *oss.UploaderManager, appConfig *types.AppConfig) *ServicePool {
|
func NewServicePool(db *gorm.DB, redisCli *redis.Client, manager *oss.UploaderManager, appConfig *types.AppConfig, licenseService *service.LicenseService) *ServicePool {
|
||||||
services := make([]*Service, 0)
|
services := make([]*Service, 0)
|
||||||
taskQueue := store.NewRedisQueue("MidJourney_Task_Queue", redisCli)
|
taskQueue := store.NewRedisQueue("MidJourney_Task_Queue", redisCli)
|
||||||
notifyQueue := store.NewRedisQueue("MidJourney_Notify_Queue", redisCli)
|
notifyQueue := store.NewRedisQueue("MidJourney_Notify_Queue", redisCli)
|
||||||
@ -35,6 +43,11 @@ func NewServicePool(db *gorm.DB, redisCli *redis.Client, manager *oss.UploaderMa
|
|||||||
if config.Enabled == false {
|
if config.Enabled == false {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
err := licenseService.IsValidApiURL(config.ApiURL)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error(err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
cli := NewPlusClient(config)
|
cli := NewPlusClient(config)
|
||||||
name := fmt.Sprintf("mj-plus-service-%d", k)
|
name := fmt.Sprintf("mj-plus-service-%d", k)
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package mj
|
package mj
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/utils"
|
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/utils"
|
||||||
"github.com/imroc/req/v3"
|
"github.com/imroc/req/v3"
|
||||||
"io"
|
"io"
|
||||||
)
|
)
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
package mj
|
package mj
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/service"
|
|
||||||
"chatplus/service/sd"
|
|
||||||
"chatplus/store"
|
|
||||||
"chatplus/store/model"
|
|
||||||
"chatplus/utils"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/service"
|
||||||
|
"geekai/service/sd"
|
||||||
|
"geekai/store"
|
||||||
|
"geekai/store/model"
|
||||||
|
"geekai/utils"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package oss
|
package oss
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/utils"
|
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/utils"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
package oss
|
package oss
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/utils"
|
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/utils"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package oss
|
package oss
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/utils"
|
|
||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/utils"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
package oss
|
package oss
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/utils"
|
|
||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/utils"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package oss
|
package oss
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import "github.com/gin-gonic/gin"
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
const Local = "LOCAL"
|
const Local = "LOCAL"
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
package oss
|
package oss
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
package payment
|
package payment
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
logger2 "chatplus/logger"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
logger2 "geekai/logger"
|
||||||
"github.com/smartwalle/alipay/v3"
|
"github.com/smartwalle/alipay/v3"
|
||||||
"log"
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
package payment
|
package payment
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/utils"
|
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/utils"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
package payment
|
package payment
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/utils"
|
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/utils"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package sd
|
package sd
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/service/oss"
|
|
||||||
"chatplus/store"
|
|
||||||
"chatplus/store/model"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/service/oss"
|
||||||
|
"geekai/store"
|
||||||
|
"geekai/store/model"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
package sd
|
package sd
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/service"
|
|
||||||
"chatplus/service/oss"
|
|
||||||
"chatplus/store"
|
|
||||||
"chatplus/store/model"
|
|
||||||
"chatplus/utils"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/service"
|
||||||
|
"geekai/service/oss"
|
||||||
|
"geekai/store"
|
||||||
|
"geekai/store/model"
|
||||||
|
"geekai/utils"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
package sd
|
package sd
|
||||||
|
|
||||||
import logger2 "chatplus/logger"
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
|
import logger2 "geekai/logger"
|
||||||
|
|
||||||
var logger = logger2.GetLogger()
|
var logger = logger2.GetLogger()
|
||||||
|
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
package sms
|
package sms
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
"github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi"
|
"github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
package sms
|
package sms
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
"chatplus/utils"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
"geekai/utils"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package sms
|
package sms
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
const Ali = "ALI"
|
const Ali = "ALI"
|
||||||
const Bao = "BAO"
|
const Bao = "BAO"
|
||||||
|
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
package sms
|
package sms
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
logger2 "chatplus/logger"
|
logger2 "geekai/logger"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"chatplus/core/types"
|
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
"mime"
|
"mime"
|
||||||
"net/smtp"
|
"net/smtp"
|
||||||
"net/textproto"
|
"net/textproto"
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
package wx
|
package wx
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
logger2 "chatplus/logger"
|
logger2 "geekai/logger"
|
||||||
"chatplus/store/model"
|
"geekai/store/model"
|
||||||
"github.com/eatmoreapple/openwechat"
|
"github.com/eatmoreapple/openwechat"
|
||||||
"github.com/skip2/go-qrcode"
|
"github.com/skip2/go-qrcode"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package wx
|
package wx
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
logger2 "chatplus/logger"
|
|
||||||
"chatplus/store/model"
|
|
||||||
"chatplus/utils"
|
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"geekai/core/types"
|
||||||
|
logger2 "geekai/logger"
|
||||||
|
"geekai/store/model"
|
||||||
|
"geekai/utils"
|
||||||
"github.com/xxl-job/xxl-job-executor-go"
|
"github.com/xxl-job/xxl-job-executor-go"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"time"
|
"time"
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package store
|
package store
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
package store
|
package store
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
"geekai/core/types"
|
||||||
"gorm.io/driver/mysql"
|
"gorm.io/driver/mysql"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"gorm.io/gorm/logger"
|
"gorm.io/gorm/logger"
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
package store
|
package store
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/core/types"
|
|
||||||
"context"
|
"context"
|
||||||
|
"geekai/core/types"
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
package store
|
package store
|
||||||
|
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// * Copyright 2023 The Geek-AI Authors. All rights reserved.
|
||||||
|
// * Use of this source code is governed by a Apache-2.0 license
|
||||||
|
// * that can be found in the LICENSE file.
|
||||||
|
// * @Author yangjian102621@163.com
|
||||||
|
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"chatplus/utils"
|
|
||||||
"context"
|
"context"
|
||||||
|
"geekai/utils"
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,11 +2,12 @@ package vo
|
|||||||
|
|
||||||
type ChatItem struct {
|
type ChatItem struct {
|
||||||
BaseVo
|
BaseVo
|
||||||
UserId uint `json:"user_id"`
|
UserId uint `json:"user_id"`
|
||||||
Icon string `json:"icon"`
|
Icon string `json:"icon"`
|
||||||
RoleId uint `json:"role_id"`
|
RoleId uint `json:"role_id"`
|
||||||
ChatId string `json:"chat_id"`
|
RoleName string `json:"role_name"`
|
||||||
ModelId uint `json:"model_id"`
|
ChatId string `json:"chat_id"`
|
||||||
Model string `json:"model"`
|
ModelId uint `json:"model_id"`
|
||||||
Title string `json:"title"`
|
Model string `json:"model"`
|
||||||
|
Title string `json:"title"`
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user