Skip to content

Commit 49af943

Browse files
authored
update: 2.8.7-beta发布
update: 2.8.7-beta发布
2 parents aa84605 + 1994497 commit 49af943

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3708
-559
lines changed

.aone_copilot/rules/project_rules.md

Lines changed: 761 additions & 0 deletions
Large diffs are not rendered by default.

server/api/v1/example/exa_breakpoint_continue.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io"
66
"mime/multipart"
77
"strconv"
8+
"strings"
89

910
"github.com/flipped-aurora/gin-vue-admin/server/model/example"
1011

@@ -135,6 +136,11 @@ func (b *FileUploadAndDownloadApi) RemoveChunk(c *gin.Context) {
135136
response.FailWithMessage(err.Error(), c)
136137
return
137138
}
139+
// 路径穿越拦截
140+
if strings.Contains(file.FilePath, "..") || strings.Contains(file.FilePath, "../") || strings.Contains(file.FilePath, "./") || strings.Contains(file.FilePath, ".\\") {
141+
response.FailWithMessage("非法路径,禁止删除", c)
142+
return
143+
}
138144
err = utils.RemoveChunk(file.FileMd5)
139145
if err != nil {
140146
global.GVA_LOG.Error("缓存切片删除失败!", zap.Error(err))

server/api/v1/system/enter.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type ApiGroup struct {
2323
AutoCodeTemplateApi
2424
SysParamsApi
2525
SysVersionApi
26+
SysErrorApi
2627
}
2728

2829
var (
@@ -46,4 +47,5 @@ var (
4647
autoCodeHistoryService = service.ServiceGroupApp.SystemServiceGroup.AutoCodeHistory
4748
autoCodeTemplateService = service.ServiceGroupApp.SystemServiceGroup.AutoCodeTemplate
4849
sysVersionService = service.ServiceGroupApp.SystemServiceGroup.SysVersionService
50+
sysErrorService = service.ServiceGroupApp.SystemServiceGroup.SysErrorService
4951
)

server/api/v1/system/sys_auto_code.go

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
package system
22

33
import (
4-
"fmt"
54
"github.com/flipped-aurora/gin-vue-admin/server/model/common"
6-
"github.com/goccy/go-json"
7-
"io"
8-
"strings"
95

106
"github.com/flipped-aurora/gin-vue-admin/server/global"
117
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
12-
"github.com/flipped-aurora/gin-vue-admin/server/utils/request"
138
"github.com/gin-gonic/gin"
149
"go.uber.org/zap"
1510
)
@@ -108,48 +103,15 @@ func (autoApi *AutoCodeApi) GetColumn(c *gin.Context) {
108103

109104
func (autoApi *AutoCodeApi) LLMAuto(c *gin.Context) {
110105
var llm common.JSONMap
111-
err := c.ShouldBindJSON(&llm)
112-
if err != nil {
106+
if err := c.ShouldBindJSON(&llm); err != nil {
113107
response.FailWithMessage(err.Error(), c)
114108
return
115109
}
116-
if global.GVA_CONFIG.AutoCode.AiPath == "" {
117-
response.FailWithMessage("请先前往插件市场个人中心获取AiPath并填入config.yaml中", c)
118-
return
119-
}
120-
121-
path := strings.ReplaceAll(global.GVA_CONFIG.AutoCode.AiPath, "{FUNC}", fmt.Sprintf("api/chat/%s", llm["mode"]))
122-
res, err := request.HttpRequest(
123-
path,
124-
"POST",
125-
nil,
126-
nil,
127-
llm,
128-
)
129-
if err != nil {
130-
global.GVA_LOG.Error("大模型生成失败!", zap.Error(err))
131-
response.FailWithMessage("大模型生成失败"+err.Error(), c)
132-
return
133-
}
134-
var resStruct response.Response
135-
b, err := io.ReadAll(res.Body)
136-
defer res.Body.Close()
110+
data, err := autoCodeService.LLMAuto(c.Request.Context(), llm)
137111
if err != nil {
138112
global.GVA_LOG.Error("大模型生成失败!", zap.Error(err))
139113
response.FailWithMessage("大模型生成失败"+err.Error(), c)
140114
return
141115
}
142-
err = json.Unmarshal(b, &resStruct)
143-
if err != nil {
144-
global.GVA_LOG.Error("大模型生成失败!", zap.Error(err))
145-
response.FailWithMessage("大模型生成失败"+err.Error(), c)
146-
return
147-
}
148-
149-
if resStruct.Code == 7 {
150-
global.GVA_LOG.Error("大模型生成失败!"+resStruct.Msg, zap.Error(err))
151-
response.FailWithMessage("大模型生成失败"+resStruct.Msg, c)
152-
return
153-
}
154-
response.OkWithData(resStruct.Data, c)
116+
response.OkWithData(data, c)
155117
}

server/api/v1/system/sys_dictionary.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,57 @@ func (s *DictionaryApi) GetSysDictionaryList(c *gin.Context) {
135135
}
136136
response.OkWithDetailed(list, "获取成功", c)
137137
}
138+
139+
// ExportSysDictionary
140+
// @Tags SysDictionary
141+
// @Summary 导出字典JSON(包含字典详情)
142+
// @Security ApiKeyAuth
143+
// @accept application/json
144+
// @Produce application/json
145+
// @Param data query system.SysDictionary true "字典ID"
146+
// @Success 200 {object} response.Response{data=map[string]interface{},msg=string} "导出字典JSON"
147+
// @Router /sysDictionary/exportSysDictionary [get]
148+
func (s *DictionaryApi) ExportSysDictionary(c *gin.Context) {
149+
var dictionary system.SysDictionary
150+
err := c.ShouldBindQuery(&dictionary)
151+
if err != nil {
152+
response.FailWithMessage(err.Error(), c)
153+
return
154+
}
155+
if dictionary.ID == 0 {
156+
response.FailWithMessage("字典ID不能为空", c)
157+
return
158+
}
159+
exportData, err := dictionaryService.ExportSysDictionary(dictionary.ID)
160+
if err != nil {
161+
global.GVA_LOG.Error("导出失败!", zap.Error(err))
162+
response.FailWithMessage("导出失败", c)
163+
return
164+
}
165+
response.OkWithDetailed(exportData, "导出成功", c)
166+
}
167+
168+
// ImportSysDictionary
169+
// @Tags SysDictionary
170+
// @Summary 导入字典JSON(包含字典详情)
171+
// @Security ApiKeyAuth
172+
// @accept application/json
173+
// @Produce application/json
174+
// @Param data body request.ImportSysDictionaryRequest true "字典JSON数据"
175+
// @Success 200 {object} response.Response{msg=string} "导入字典"
176+
// @Router /sysDictionary/importSysDictionary [post]
177+
func (s *DictionaryApi) ImportSysDictionary(c *gin.Context) {
178+
var req request.ImportSysDictionaryRequest
179+
err := c.ShouldBindJSON(&req)
180+
if err != nil {
181+
response.FailWithMessage(err.Error(), c)
182+
return
183+
}
184+
err = dictionaryService.ImportSysDictionary(req.Json)
185+
if err != nil {
186+
global.GVA_LOG.Error("导入失败!", zap.Error(err))
187+
response.FailWithMessage("导入失败: "+err.Error(), c)
188+
return
189+
}
190+
response.OkWithMessage("导入成功", c)
191+
}

server/api/v1/system/sys_error.go

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
package system
2+
3+
import (
4+
"github.com/flipped-aurora/gin-vue-admin/server/global"
5+
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
6+
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
7+
systemReq "github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
8+
"github.com/gin-gonic/gin"
9+
"go.uber.org/zap"
10+
)
11+
12+
type SysErrorApi struct{}
13+
14+
// CreateSysError 创建错误日志
15+
// @Tags SysError
16+
// @Summary 创建错误日志
17+
// @Security ApiKeyAuth
18+
// @Accept application/json
19+
// @Produce application/json
20+
// @Param data body system.SysError true "创建错误日志"
21+
// @Success 200 {object} response.Response{msg=string} "创建成功"
22+
// @Router /sysError/createSysError [post]
23+
func (sysErrorApi *SysErrorApi) CreateSysError(c *gin.Context) {
24+
// 创建业务用Context
25+
ctx := c.Request.Context()
26+
27+
var sysError system.SysError
28+
err := c.ShouldBindJSON(&sysError)
29+
if err != nil {
30+
response.FailWithMessage(err.Error(), c)
31+
return
32+
}
33+
err = sysErrorService.CreateSysError(ctx, &sysError)
34+
if err != nil {
35+
global.GVA_LOG.Error("创建失败!", zap.Error(err))
36+
response.FailWithMessage("创建失败:"+err.Error(), c)
37+
return
38+
}
39+
response.OkWithMessage("创建成功", c)
40+
}
41+
42+
// DeleteSysError 删除错误日志
43+
// @Tags SysError
44+
// @Summary 删除错误日志
45+
// @Security ApiKeyAuth
46+
// @Accept application/json
47+
// @Produce application/json
48+
// @Param data body system.SysError true "删除错误日志"
49+
// @Success 200 {object} response.Response{msg=string} "删除成功"
50+
// @Router /sysError/deleteSysError [delete]
51+
func (sysErrorApi *SysErrorApi) DeleteSysError(c *gin.Context) {
52+
// 创建业务用Context
53+
ctx := c.Request.Context()
54+
55+
ID := c.Query("ID")
56+
err := sysErrorService.DeleteSysError(ctx, ID)
57+
if err != nil {
58+
global.GVA_LOG.Error("删除失败!", zap.Error(err))
59+
response.FailWithMessage("删除失败:"+err.Error(), c)
60+
return
61+
}
62+
response.OkWithMessage("删除成功", c)
63+
}
64+
65+
// DeleteSysErrorByIds 批量删除错误日志
66+
// @Tags SysError
67+
// @Summary 批量删除错误日志
68+
// @Security ApiKeyAuth
69+
// @Accept application/json
70+
// @Produce application/json
71+
// @Success 200 {object} response.Response{msg=string} "批量删除成功"
72+
// @Router /sysError/deleteSysErrorByIds [delete]
73+
func (sysErrorApi *SysErrorApi) DeleteSysErrorByIds(c *gin.Context) {
74+
// 创建业务用Context
75+
ctx := c.Request.Context()
76+
77+
IDs := c.QueryArray("IDs[]")
78+
err := sysErrorService.DeleteSysErrorByIds(ctx, IDs)
79+
if err != nil {
80+
global.GVA_LOG.Error("批量删除失败!", zap.Error(err))
81+
response.FailWithMessage("批量删除失败:"+err.Error(), c)
82+
return
83+
}
84+
response.OkWithMessage("批量删除成功", c)
85+
}
86+
87+
// UpdateSysError 更新错误日志
88+
// @Tags SysError
89+
// @Summary 更新错误日志
90+
// @Security ApiKeyAuth
91+
// @Accept application/json
92+
// @Produce application/json
93+
// @Param data body system.SysError true "更新错误日志"
94+
// @Success 200 {object} response.Response{msg=string} "更新成功"
95+
// @Router /sysError/updateSysError [put]
96+
func (sysErrorApi *SysErrorApi) UpdateSysError(c *gin.Context) {
97+
// 从ctx获取标准context进行业务行为
98+
ctx := c.Request.Context()
99+
100+
var sysError system.SysError
101+
err := c.ShouldBindJSON(&sysError)
102+
if err != nil {
103+
response.FailWithMessage(err.Error(), c)
104+
return
105+
}
106+
err = sysErrorService.UpdateSysError(ctx, sysError)
107+
if err != nil {
108+
global.GVA_LOG.Error("更新失败!", zap.Error(err))
109+
response.FailWithMessage("更新失败:"+err.Error(), c)
110+
return
111+
}
112+
response.OkWithMessage("更新成功", c)
113+
}
114+
115+
// FindSysError 用id查询错误日志
116+
// @Tags SysError
117+
// @Summary 用id查询错误日志
118+
// @Security ApiKeyAuth
119+
// @Accept application/json
120+
// @Produce application/json
121+
// @Param ID query uint true "用id查询错误日志"
122+
// @Success 200 {object} response.Response{data=system.SysError,msg=string} "查询成功"
123+
// @Router /sysError/findSysError [get]
124+
func (sysErrorApi *SysErrorApi) FindSysError(c *gin.Context) {
125+
// 创建业务用Context
126+
ctx := c.Request.Context()
127+
128+
ID := c.Query("ID")
129+
resysError, err := sysErrorService.GetSysError(ctx, ID)
130+
if err != nil {
131+
global.GVA_LOG.Error("查询失败!", zap.Error(err))
132+
response.FailWithMessage("查询失败:"+err.Error(), c)
133+
return
134+
}
135+
response.OkWithData(resysError, c)
136+
}
137+
138+
// GetSysErrorList 分页获取错误日志列表
139+
// @Tags SysError
140+
// @Summary 分页获取错误日志列表
141+
// @Security ApiKeyAuth
142+
// @Accept application/json
143+
// @Produce application/json
144+
// @Param data query systemReq.SysErrorSearch true "分页获取错误日志列表"
145+
// @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取成功"
146+
// @Router /sysError/getSysErrorList [get]
147+
func (sysErrorApi *SysErrorApi) GetSysErrorList(c *gin.Context) {
148+
// 创建业务用Context
149+
ctx := c.Request.Context()
150+
151+
var pageInfo systemReq.SysErrorSearch
152+
err := c.ShouldBindQuery(&pageInfo)
153+
if err != nil {
154+
response.FailWithMessage(err.Error(), c)
155+
return
156+
}
157+
list, total, err := sysErrorService.GetSysErrorInfoList(ctx, pageInfo)
158+
if err != nil {
159+
global.GVA_LOG.Error("获取失败!", zap.Error(err))
160+
response.FailWithMessage("获取失败:"+err.Error(), c)
161+
return
162+
}
163+
response.OkWithDetailed(response.PageResult{
164+
List: list,
165+
Total: total,
166+
Page: pageInfo.Page,
167+
PageSize: pageInfo.PageSize,
168+
}, "获取成功", c)
169+
}
170+
171+
// GetSysErrorSolution 触发错误日志的异步处理
172+
// @Tags SysError
173+
// @Summary 根据ID触发处理:标记为处理中,1分钟后自动改为处理完成
174+
// @Security ApiKeyAuth
175+
// @Accept application/json
176+
// @Produce application/json
177+
// @Param id query string true "错误日志ID"
178+
// @Success 200 {object} response.Response{msg=string} "处理已提交"
179+
// @Router /sysError/getSysErrorSolution [get]
180+
func (sysErrorApi *SysErrorApi) GetSysErrorSolution(c *gin.Context) {
181+
// 创建业务用Context
182+
ctx := c.Request.Context()
183+
184+
// 兼容 id 与 ID 两种参数
185+
ID := c.Query("id")
186+
if ID == "" {
187+
response.FailWithMessage("缺少参数: id", c)
188+
return
189+
}
190+
191+
err := sysErrorService.GetSysErrorSolution(ctx, ID)
192+
if err != nil {
193+
global.GVA_LOG.Error("处理触发失败!", zap.Error(err))
194+
response.FailWithMessage("处理触发失败:"+err.Error(), c)
195+
return
196+
}
197+
198+
response.OkWithMessage("已提交至AI处理", c)
199+
}

server/api/v1/system/sys_export_template.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,34 @@ type SysExportTemplateApi struct {
5050

5151
var sysExportTemplateService = service.ServiceGroupApp.SystemServiceGroup.SysExportTemplateService
5252

53+
// PreviewSQL 预览最终生成的SQL
54+
// @Tags SysExportTemplate
55+
// @Summary 预览最终生成的SQL(不执行查询,仅返回SQL字符串)
56+
// @Security ApiKeyAuth
57+
// @accept application/json
58+
// @Produce application/json
59+
// @Param templateID query string true "导出模板ID"
60+
// @Param params query string false "查询参数编码字符串,参考 ExportExcel 组件"
61+
// @Success 200 {object} response.Response{data=map[string]string} "获取成功"
62+
// @Router /sysExportTemplate/previewSQL [get]
63+
func (sysExportTemplateApi *SysExportTemplateApi) PreviewSQL(c *gin.Context) {
64+
templateID := c.Query("templateID")
65+
if templateID == "" {
66+
response.FailWithMessage("模板ID不能为空", c)
67+
return
68+
}
69+
70+
// 直接复用导出接口的参数组织方式:使用 URL Query,其中 params 为内部编码的查询字符串
71+
queryParams := c.Request.URL.Query()
72+
73+
if sqlPreview, err := sysExportTemplateService.PreviewSQL(templateID, queryParams); err != nil {
74+
global.GVA_LOG.Error("获取失败!", zap.Error(err))
75+
response.FailWithMessage("获取失败", c)
76+
} else {
77+
response.OkWithData(gin.H{"sql": sqlPreview}, c)
78+
}
79+
}
80+
5381
// CreateSysExportTemplate 创建导出模板
5482
// @Tags SysExportTemplate
5583
// @Summary 创建导出模板

0 commit comments

Comments
 (0)