55 "fmt"
66 "gin-vue-admin/global"
77 "gin-vue-admin/model"
8+ "gin-vue-admin/model/request"
89 "gin-vue-admin/model/response"
910 "gin-vue-admin/service"
1011 "gin-vue-admin/utils"
@@ -15,6 +16,89 @@ import (
1516 "go.uber.org/zap"
1617)
1718
19+ // @Tags AutoCode
20+ // @Summary 删除回滚记录
21+ // @Security ApiKeyAuth
22+ // @accept application/json
23+ // @Produce application/json
24+ // @Param data body request.AutoHistoryByID true "删除回滚记录"
25+ // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
26+ // @Router /autoCode/delSysHistory [post]
27+ func DelSysHistory (c * gin.Context ) {
28+ var id request.AutoHistoryByID
29+ _ = c .ShouldBindJSON (& id )
30+ err := service .DeletePage (id .ID )
31+ if err != nil {
32+ global .GVA_LOG .Error ("获取失败!" , zap .Any ("err" , err ))
33+ response .FailWithMessage ("获取失败" , c )
34+ }
35+ response .OkWithMessage ("删除成功" , c )
36+
37+ }
38+
39+ // @Tags AutoCode
40+ // @Summary 查询回滚记录
41+ // @Security ApiKeyAuth
42+ // @accept application/json
43+ // @Produce application/json
44+ // @Param data body request.SysAutoHistory true "查询回滚记录"
45+ // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
46+ // @Router /autoCode/getSysHistory [post]
47+ func GetSysHistory (c * gin.Context ) {
48+ var search request.SysAutoHistory
49+ _ = c .ShouldBindJSON (& search )
50+ err , list , total := service .GetSysHistoryPage (search .PageInfo )
51+ if err != nil {
52+ global .GVA_LOG .Error ("获取失败!" , zap .Any ("err" , err ))
53+ response .FailWithMessage ("获取失败" , c )
54+ } else {
55+ response .OkWithDetailed (response.PageResult {
56+ List : list ,
57+ Total : total ,
58+ Page : search .Page ,
59+ PageSize : search .PageSize ,
60+ }, "获取成功" , c )
61+ }
62+ }
63+
64+ // @Tags AutoCode
65+ // @Summary 回滚
66+ // @Security ApiKeyAuth
67+ // @accept application/json
68+ // @Produce application/json
69+ // @Param data body request.AutoHistoryByID true "回滚自动生成代码"
70+ // @Success 200 {string} string "{"success":true,"data":{},"msg":"回滚成功"}"
71+ // @Router /autoCode/rollback [post]
72+ func RollBack (c * gin.Context ) {
73+ var id request.AutoHistoryByID
74+ _ = c .ShouldBindJSON (& id )
75+ if err := service .RollBack (id .ID ); err != nil {
76+ response .FailWithMessage (err .Error (), c )
77+ return
78+ }
79+ response .OkWithMessage ("回滚成功" , c )
80+ }
81+
82+ // @Tags AutoCode
83+ // @Summary 回滚
84+ // @Security ApiKeyAuth
85+ // @accept application/json
86+ // @Produce application/json
87+ // @Param data body request.AutoHistoryByID true "获取meta信息"
88+ // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
89+ // @Router /autoCode/getMeta [post]
90+ func GetMeta (c * gin.Context ) {
91+ var id request.AutoHistoryByID
92+ _ = c .ShouldBindJSON (& id )
93+ if v , err := service .GetMeta (id .ID ); err != nil {
94+ response .FailWithMessage (err .Error (), c )
95+ return
96+ } else {
97+ response .OkWithDetailed (gin.H {"meta" : v }, "获取成功" , c )
98+ }
99+
100+ }
101+
18102// @Tags AutoCode
19103// @Summary 预览创建后的代码
20104// @Security ApiKeyAuth
@@ -54,15 +138,18 @@ func CreateTemp(c *gin.Context) {
54138 response .FailWithMessage (err .Error (), c )
55139 return
56140 }
141+ var apiIds []uint
57142 if a .AutoCreateApiToSql {
58- if err := service .AutoCreateApi (& a ); err != nil {
143+ if ids , err := service .AutoCreateApi (& a ); err != nil {
59144 global .GVA_LOG .Error ("自动化创建失败!请自行清空垃圾数据!" , zap .Any ("err" , err ))
60145 c .Writer .Header ().Add ("success" , "false" )
61146 c .Writer .Header ().Add ("msg" , url .QueryEscape ("自动化创建失败!请自行清空垃圾数据!" ))
62147 return
148+ } else {
149+ apiIds = ids
63150 }
64151 }
65- err := service .CreateTemp (a )
152+ err := service .CreateTemp (a , apiIds ... )
66153 if err != nil {
67154 if errors .Is (err , model .AutoMoveErr ) {
68155 c .Writer .Header ().Add ("success" , "false" )
0 commit comments