Skip to content

发布dev2.8.2版本 #2025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c668055
refactor(server): 重构服务器启动和重载逻辑
piexlmax Apr 21, 2025
70f68d0
refactor: 重构系统事件处理、JWT和Casbin相关逻辑
piexlmax Apr 21, 2025
e9234a8
refactor(server): 重构服务初始化和关闭逻辑
piexlmax Apr 21, 2025
e6db46f
fix: 修复自动化代码enum查询条件的bug
piexlmax Apr 21, 2025
19fd16d
fix: 修复组合模式下,顶部菜单重复bug
Gor-c Apr 28, 2025
6cb3927
Merge branch 'refs/heads/main' into dev-282
piexlmax Apr 28, 2025
3a84455
refactor: 修改名称 RunWindowsServer ==> RunServer
piexlmax Apr 28, 2025
57d4fe5
Merge pull request #2019 from Gor-c/patch-2
pixelmaxQm Apr 29, 2025
da0eb2f
新增mcp
QINsring Apr 29, 2025
d151d9b
Merge pull request #2021 from QINsring/dev-282
pixelmaxQm Apr 29, 2025
7619270
feat: 支持mcp服务
piexlmax May 8, 2025
c33f0ea
Merge remote-tracking branch 'refs/remotes/origin/main' into dev-282
pixelmaxQm May 8, 2025
4735e1f
feat:调整mcp结构,增加客户端和测试用例
pixelmaxQm May 8, 2025
a004788
feat:更换mcp基础包和结构
pixelmaxQm May 8, 2025
3970b88
feat:提交客户端工具测试用例
pixelmaxQm May 8, 2025
b6c8c50
feat: 增加自动创建 mcp Tool模板 功能
piexlmax May 9, 2025
9df778f
fix: 增加默认值属性
piexlmax May 9, 2025
6860395
feat: 调整初始化menu的逻辑
piexlmax May 9, 2025
cbc140d
feat: 调整初始config.yaml
piexlmax May 9, 2025
a67a8b9
feat: 增加全局GVA_MCP_SERVER属性,方便灵活化开发。
piexlmax May 9, 2025
2fcb429
feat: 优化自动化mcp逻辑和成功展示
piexlmax May 9, 2025
ba221e5
feat: 优化mcp tool nickname工具
piexlmax May 12, 2025
39a6709
feat: 发布2.8.2 Beta版本
piexlmax May 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions server/api/v1/system/auto_code_mcp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package system

import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
"github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
"github.com/gin-gonic/gin"
)

// Create
// @Tags mcp
// @Summary 自动McpTool
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.AutoMcpTool true "创建自动代码"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
// @Router /autoCode/mcp [post]
func (a *AutoCodeTemplateApi) MCP(c *gin.Context) {
var info request.AutoMcpTool
err := c.ShouldBindJSON(&info)
if err != nil {
response.FailWithMessage(err.Error(), c)
return
}

toolFilePath, err := autoCodeTemplateService.CreateMcp(c.Request.Context(), info)
if err != nil {
response.FailWithMessage("创建失败", c)
global.GVA_LOG.Error(err.Error())
return
}
response.OkWithMessage("创建成功,MCP Tool路径:"+toolFilePath, c)
}
25 changes: 0 additions & 25 deletions server/api/v1/system/sys_operation_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,6 @@ import (

type OperationRecordApi struct{}

// CreateSysOperationRecord
// @Tags SysOperationRecord
// @Summary 创建SysOperationRecord
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body system.SysOperationRecord true "创建SysOperationRecord"
// @Success 200 {object} response.Response{msg=string} "创建SysOperationRecord"
// @Router /sysOperationRecord/createSysOperationRecord [post]
func (s *OperationRecordApi) CreateSysOperationRecord(c *gin.Context) {
var sysOperationRecord system.SysOperationRecord
err := c.ShouldBindJSON(&sysOperationRecord)
if err != nil {
response.FailWithMessage(err.Error(), c)
return
}
err = operationRecordService.CreateSysOperationRecord(sysOperationRecord)
if err != nil {
global.GVA_LOG.Error("创建失败!", zap.Error(err))
response.FailWithMessage("创建失败", c)
return
}
response.OkWithMessage("创建成功", c)
}

// DeleteSysOperationRecord
// @Tags SysOperationRecord
// @Summary 删除SysOperationRecord
Expand Down
13 changes: 7 additions & 6 deletions server/api/v1/system/sys_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,20 @@ func (s *SystemApi) SetSystemConfig(c *gin.Context) {

// ReloadSystem
// @Tags System
// @Summary 重启系统
// @Summary 重载系统
// @Security ApiKeyAuth
// @Produce application/json
// @Success 200 {object} response.Response{msg=string} "重启系统"
// @Success 200 {object} response.Response{msg=string} "重载系统"
// @Router /system/reloadSystem [post]
func (s *SystemApi) ReloadSystem(c *gin.Context) {
err := utils.Reload()
// 触发系统重载事件
err := utils.GlobalSystemEvents.TriggerReload()
if err != nil {
global.GVA_LOG.Error("重启系统失败!", zap.Error(err))
response.FailWithMessage("重启系统失败", c)
global.GVA_LOG.Error("重载系统失败!", zap.Error(err))
response.FailWithMessage("重载系统失败:"+err.Error(), c)
return
}
response.OkWithMessage("重启系统成功", c)
response.OkWithMessage("重载系统成功", c)
}

// GetServerInfo
Expand Down
4 changes: 2 additions & 2 deletions server/api/v1/system/sys_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (b *BaseApi) TokenNext(c *gin.Context, user system.SysUser) {
}

if jwtStr, err := jwtService.GetRedisJWT(user.Username); err == redis.Nil {
if err := jwtService.SetRedisJWT(token, user.Username); err != nil {
if err := utils.SetRedisJWT(token, user.Username); err != nil {
global.GVA_LOG.Error("设置登录状态失败!", zap.Error(err))
response.FailWithMessage("设置登录状态失败", c)
return
Expand All @@ -114,7 +114,7 @@ func (b *BaseApi) TokenNext(c *gin.Context, user system.SysUser) {
response.FailWithMessage("jwt作废失败", c)
return
}
if err := jwtService.SetRedisJWT(token, user.GetUsername()); err != nil {
if err := utils.SetRedisJWT(token, user.GetUsername()); err != nil {
response.FailWithMessage("设置登录状态失败", c)
return
}
Expand Down
8 changes: 7 additions & 1 deletion server/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,10 @@ cors:
allow-headers: content-type
allow-methods: GET, POST
expose-headers: Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type
allow-credentials: true # 布尔值
allow-credentials: true # 布尔值
mcp:
name: GVA_MCP
version: v1.0.0
sse_path: /sse
message_path: /message
url_prefix: ''
3 changes: 3 additions & 0 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ type Server struct {

// 跨域配置
Cors CORS `mapstructure:"cors" json:"cors" yaml:"cors"`

// MCP配置
MCP MCP `mapstructure:"mcp" json:"mcp" yaml:"mcp"`
}
9 changes: 9 additions & 0 deletions server/config/mcp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package config

type MCP struct {
Name string `mapstructure:"name" json:"name" yaml:"name"` // MCP名称
Version string `mapstructure:"version" json:"version" yaml:"version"` // MCP版本
SSEPath string `mapstructure:"sse_path" json:"sse_path" yaml:"sse_path"` // SSE路径
MessagePath string `mapstructure:"message_path" json:"message_path" yaml:"message_path"` // 消息路径
UrlPrefix string `mapstructure:"url_prefix" json:"url_prefix" yaml:"url_prefix"` // URL前缀
}
18 changes: 7 additions & 11 deletions server/core/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ import (
"github.com/flipped-aurora/gin-vue-admin/server/initialize"
"github.com/flipped-aurora/gin-vue-admin/server/service/system"
"go.uber.org/zap"
"time"
)

type server interface {
ListenAndServe() error
}

func RunWindowsServer() {
func RunServer() {
if global.GVA_CONFIG.System.UseRedis {
// 初始化redis服务
initialize.Redis()
Expand All @@ -35,23 +32,22 @@ func RunWindowsServer() {
Router := initialize.Routers()

address := fmt.Sprintf(":%d", global.GVA_CONFIG.System.Addr)
s := initServer(address, Router)

global.GVA_LOG.Info("server run success on ", zap.String("address", address))

fmt.Printf(`
欢迎使用 gin-vue-admin
当前版本:v2.8.1
当前版本:v2.8.2
加群方式:微信号:shouzi_1994 QQ群:470239250
项目地址:https://github.com/flipped-aurora/gin-vue-admin
插件市场:https://plugin.gin-vue-admin.com
GVA讨论社区:https://support.qq.com/products/371961
默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
默认MCP SSE地址:http://127.0.0.1%s%s
默认MCP Message地址:http://127.0.0.1%s%s
默认前端文件运行地址:http://127.0.0.1:8080
--------------------------------------版权声明--------------------------------------
** 版权所有方:flipped-aurora开源团队 **
** 版权持有公司:北京翻转极光科技有限责任公司 **
** 剔除授权标识需购买商用授权:https://gin-vue-admin.com/empower/index.html **
`, address)
global.GVA_LOG.Error(s.ListenAndServe().Error())
`, address, address, global.GVA_CONFIG.MCP.SSEPath, address, global.GVA_CONFIG.MCP.MessagePath)
initServer(address, Router, 10*time.Minute, 10*time.Minute)
}
19 changes: 0 additions & 19 deletions server/core/server_other.go

This file was deleted.

60 changes: 60 additions & 0 deletions server/core/server_run.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package core

import (
"context"
"fmt"
"net/http"
"os"
"os/signal"
"syscall"
"time"

"github.com/gin-gonic/gin"
"go.uber.org/zap"
)

type server interface {
ListenAndServe() error
Shutdown(context.Context) error
}

// initServer 启动服务并实现优雅关闭
func initServer(address string, router *gin.Engine, readTimeout, writeTimeout time.Duration) {
// 创建服务
srv := &http.Server{
Addr: address,
Handler: router,
ReadTimeout: readTimeout,
WriteTimeout: writeTimeout,
MaxHeaderBytes: 1 << 20,
}

// 在goroutine中启动服务
go func() {
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
fmt.Printf("listen: %s\n", err)
zap.L().Error("server启动失败", zap.Error(err))
os.Exit(1)
}
}()

// 等待中断信号以优雅地关闭服务器
quit := make(chan os.Signal, 1)
// kill (无参数) 默认发送 syscall.SIGTERM
// kill -2 发送 syscall.SIGINT
// kill -9 发送 syscall.SIGKILL,但是无法被捕获,所以不需要添加
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
zap.L().Info("关闭WEB服务...")

// 设置5秒的超时时间
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)

defer cancel()

if err := srv.Shutdown(ctx); err != nil {
zap.L().Fatal("WEB服务关闭异常", zap.Error(err))
}

zap.L().Info("WEB服务已关闭")
}
21 changes: 0 additions & 21 deletions server/core/server_win.go

This file was deleted.

2 changes: 1 addition & 1 deletion server/docs/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions server/global/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package global

import (
"fmt"
"github.com/mark3labs/mcp-go/server"
"sync"

"github.com/gin-gonic/gin"
Expand Down Expand Up @@ -35,6 +36,7 @@ var (
GVA_Concurrency_Control = &singleflight.Group{}
GVA_ROUTERS gin.RoutesInfo
GVA_ACTIVE_DBNAME *string
GVA_MCP_SERVER *server.MCPServer
BlackCache local_cache.Cache
lock sync.RWMutex
)
Expand Down
17 changes: 13 additions & 4 deletions server/go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
module github.com/flipped-aurora/gin-vue-admin/server

go 1.22.2
go 1.23

toolchain go1.23.9

require (
github.com/ThinkInAIXYZ/go-mcp v0.2.2
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible
github.com/aws/aws-sdk-go v1.55.6
github.com/casbin/casbin/v2 v2.103.0
github.com/casbin/gorm-adapter/v3 v3.32.0
github.com/fsnotify/fsnotify v1.8.0
github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6
github.com/gin-gonic/gin v1.10.0
github.com/glebarez/sqlite v1.11.0
github.com/go-sql-driver/mysql v1.8.1
Expand Down Expand Up @@ -55,7 +57,7 @@ require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/STARRY-S/zip v0.1.0 // indirect
github.com/STARRY-S/zip v0.2.1 // indirect
github.com/alex-ant/gomath v0.0.0-20160516115720-89013a210a82 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/bmatcuk/doublestar/v4 v4.8.0 // indirect
Expand Down Expand Up @@ -111,17 +113,20 @@ require (
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/mark3labs/mcp-go v0.26.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/microsoft/go-mssqldb v1.8.0 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/minlz v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/mozillazg/go-httpheader v0.4.0 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/nwaples/rardecode/v2 v2.0.1 // indirect
github.com/nwaples/rardecode/v2 v2.1.0 // indirect
github.com/orcaman/concurrent-map/v2 v2.0.1 // indirect
github.com/otiai10/mint v1.6.3 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
Expand All @@ -141,6 +146,9 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/therootcompany/xz v1.0.1 // indirect
github.com/tidwall/gjson v1.18.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.9.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
Expand All @@ -152,6 +160,7 @@ require (
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/xuri/efp v0.0.0-20241211021726-c4e992084aa6 // indirect
github.com/xuri/nfp v0.0.0-20250111060730-82a408b9aa71 // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.uber.org/multierr v1.11.0 // indirect
Expand Down
Loading
Loading