Skip to content

Commit 259178a

Browse files
author
奇淼(piexlmax
authored
Revert "修复了swag文档自动化生成失败的bug;完善了自动生成代码的swag部分"
1 parent d88e01b commit 259178a

File tree

9 files changed

+24
-64
lines changed

9 files changed

+24
-64
lines changed

server/api/v1/sys_api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func GetApiById(c *gin.Context) {
110110
}
111111

112112
// @Tags SysApi
113-
// @Summary 更新基础api
113+
// @Summary 创建基础api
114114
// @Security ApiKeyAuth
115115
// @accept application/json
116116
// @Produce application/json

server/api/v1/sys_operation_record.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"gin-vue-admin/model/response"
88
"gin-vue-admin/service"
99
"gin-vue-admin/utils"
10-
1110
"github.com/gin-gonic/gin"
1211
"go.uber.org/zap"
1312
)
@@ -17,7 +16,7 @@ import (
1716
// @Security ApiKeyAuth
1817
// @accept application/json
1918
// @Produce application/json
20-
// @Param data body request.SysOperationRecordCreate true "创建SysOperationRecord"
19+
// @Param data body model.SysOperationRecord true "创建SysOperationRecord"
2120
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
2221
// @Router /sysOperationRecord/createSysOperationRecord [post]
2322
func CreateSysOperationRecord(c *gin.Context) {
@@ -36,7 +35,7 @@ func CreateSysOperationRecord(c *gin.Context) {
3635
// @Security ApiKeyAuth
3736
// @accept application/json
3837
// @Produce application/json
39-
// @Param data body request.GetByIdUint true "SysOperationRecord模型"
38+
// @Param data body model.SysOperationRecord true "SysOperationRecord模型"
4039
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
4140
// @Router /sysOperationRecord/deleteSysOperationRecord [delete]
4241
func DeleteSysOperationRecord(c *gin.Context) {
@@ -74,17 +73,17 @@ func DeleteSysOperationRecordByIds(c *gin.Context) {
7473
// @Security ApiKeyAuth
7574
// @accept application/json
7675
// @Produce application/json
77-
// @Param data query request.GetByIdUint false "编号"
76+
// @Param data body model.SysOperationRecord true "Id"
7877
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
7978
// @Router /sysOperationRecord/findSysOperationRecord [get]
8079
func FindSysOperationRecord(c *gin.Context) {
81-
var sysOperationRecord request.GetByIdUint
80+
var sysOperationRecord model.SysOperationRecord
8281
_ = c.ShouldBindQuery(&sysOperationRecord)
8382
if err := utils.Verify(sysOperationRecord, utils.IdVerify); err != nil {
8483
response.FailWithMessage(err.Error(), c)
8584
return
8685
}
87-
if err, resysOperationRecord := service.GetSysOperationRecord(sysOperationRecord.Id); err != nil {
86+
if err, resysOperationRecord := service.GetSysOperationRecord(sysOperationRecord.ID); err != nil {
8887
global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
8988
response.FailWithMessage("查询失败", c)
9089
} else {
@@ -97,7 +96,7 @@ func FindSysOperationRecord(c *gin.Context) {
9796
// @Security ApiKeyAuth
9897
// @accept application/json
9998
// @Produce application/json
100-
// @Param data query request.SysOperationRecordSearch true "页码, 每页大小, 搜索条件"
99+
// @Param data body request.SysOperationRecordSearch true "页码, 每页大小, 搜索条件"
101100
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
102101
// @Router /sysOperationRecord/getSysOperationRecordList [get]
103102
func GetSysOperationRecordList(c *gin.Context) {

server/model/request/common.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ type GetById struct {
1111
Id float64 `json:"id" form:"id"`
1212
}
1313

14-
// Find by id structure
15-
type GetByIdUint struct {
16-
Id uint `json:"id" form:"id"`
17-
}
18-
1914
type IdsReq struct {
2015
Ids []int `json:"ids" form:"ids"`
2116
}
@@ -25,4 +20,4 @@ type GetAuthorityId struct {
2520
AuthorityId string
2621
}
2722

28-
type Empty struct{}
23+
type Empty struct {}
Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
11
package request
22

3-
import "gin-vue-admin/global"
4-
5-
type SysOperationRecordCreate struct {
6-
global.GVA_MODEL
7-
Ip string `json:"ip" form:"ip" gorm:"column:ip;comment:请求ip"`
8-
Method string `json:"method" form:"method" gorm:"column:method;comment:请求方法"`
9-
Path string `json:"path" form:"path" gorm:"column:path;comment:请求路径"`
10-
Status int `json:"status" form:"status" gorm:"column:status;comment:请求状态"`
11-
Latency int `json:"latency" form:"latency" gorm:"column:latency;comment:延迟"`
12-
Agent string `json:"agent" form:"agent" gorm:"column:agent;comment:代理"`
13-
ErrorMessage string `json:"error_message" form:"error_message" gorm:"column:error_message;comment:错误信息"`
14-
Body string `json:"body" form:"body" gorm:"type:longtext;column:body;comment:请求Body"`
15-
Resp string `json:"resp" form:"resp" gorm:"type:longtext;column:resp;comment:响应Body"`
16-
UserID int `json:"user_id" form:"user_id" gorm:"column:user_id;comment:用户id"`
17-
}
3+
import "gin-vue-admin/model"
184

195
type SysOperationRecordSearch struct {
20-
SysOperationRecordCreate
6+
model.SysOperationRecord
217
PageInfo
228
}

server/resource/template/server/api.go.tpl

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
// @Security ApiKeyAuth
1616
// @accept application/json
1717
// @Produce application/json
18-
// @Param data body model.{{.StructName}}Base true "创建{{.StructName}}"
18+
// @Param data body model.{{.StructName}} true "创建{{.StructName}}"
1919
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
2020
// @Router /{{.Abbreviation}}/create{{.StructName}} [post]
2121
func Create{{.StructName}}(c *gin.Context) {
@@ -34,7 +34,7 @@ func Create{{.StructName}}(c *gin.Context) {
3434
// @Security ApiKeyAuth
3535
// @accept application/json
3636
// @Produce application/json
37-
// @Param data body request.GetByIdUint true "删除{{.StructName}}"
37+
// @Param data body model.{{.StructName}} true "删除{{.StructName}}"
3838
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
3939
// @Router /{{.Abbreviation}}/delete{{.StructName}} [delete]
4040
func Delete{{.StructName}}(c *gin.Context) {
@@ -72,20 +72,12 @@ func Delete{{.StructName}}ByIds(c *gin.Context) {
7272
// @Security ApiKeyAuth
7373
// @accept application/json
7474
// @Produce application/json
75-
// @Param data body request.{{.StructName}}Update true "更新{{.StructName}}"
75+
// @Param data body model.{{.StructName}} true "更新{{.StructName}}"
7676
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
7777
// @Router /{{.Abbreviation}}/update{{.StructName}} [put]
7878
func Update{{.StructName}}(c *gin.Context) {
7979
var {{.Abbreviation}} model.{{.StructName}}
8080
_ = c.ShouldBindJSON(&{{.Abbreviation}})
81-
82-
err, {{.Abbreviation}}Original := service.Get{{.StructName}}({{.Abbreviation}}.ID)
83-
if err != nil {
84-
global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
85-
response.FailWithMessage("查询失败", c)
86-
}
87-
{{.Abbreviation}}.CreatedAt = {{.Abbreviation}}Original.CreatedAt
88-
8981
if err := service.Update{{.StructName}}({{.Abbreviation}}); err != nil {
9082
global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
9183
response.FailWithMessage("更新失败", c)
@@ -99,13 +91,13 @@ func Update{{.StructName}}(c *gin.Context) {
9991
// @Security ApiKeyAuth
10092
// @accept application/json
10193
// @Produce application/json
102-
// @Param data query request.GetByIdUint true "用id查询{{.StructName}}"
94+
// @Param data body model.{{.StructName}} true "用id查询{{.StructName}}"
10395
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
10496
// @Router /{{.Abbreviation}}/find{{.StructName}} [get]
10597
func Find{{.StructName}}(c *gin.Context) {
106-
var {{.Abbreviation}} request.GetByIdUint
98+
var {{.Abbreviation}} model.{{.StructName}}
10799
_ = c.ShouldBindQuery(&{{.Abbreviation}})
108-
if err, re{{.Abbreviation}} := service.Get{{.StructName}}({{.Abbreviation}}.Id); err != nil {
100+
if err, re{{.Abbreviation}} := service.Get{{.StructName}}({{.Abbreviation}}.ID); err != nil {
109101
global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
110102
response.FailWithMessage("查询失败", c)
111103
} else {
@@ -118,7 +110,7 @@ func Find{{.StructName}}(c *gin.Context) {
118110
// @Security ApiKeyAuth
119111
// @accept application/json
120112
// @Produce application/json
121-
// @Param data query request.{{.StructName}}Search true "分页获取{{.StructName}}列表"
113+
// @Param data body request.{{.StructName}}Search true "分页获取{{.StructName}}列表"
122114
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
123115
// @Router /{{.Abbreviation}}/get{{.StructName}}List [get]
124116
func Get{{.StructName}}List(c *gin.Context) {

server/resource/template/server/model.go.tpl

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,18 @@ import (
66
)
77

88
// 如果含有time.Time 请自行import time包
9-
type {{.StructName}}Base struct {
10-
{{- range .Fields}}
9+
type {{.StructName}} struct {
10+
global.GVA_MODEL {{- range .Fields}}
1111
{{- if eq .FieldType "bool" }}
1212
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- if eq .FieldType "string" -}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}}{{- end -}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}"`
1313
{{- else }}
1414
{{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- if eq .FieldType "string" -}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}}{{- end -}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}"`
1515
{{- end }} {{- end }}
1616
}
1717

18-
type {{.StructName}} struct {
19-
global.GVA_MODEL
20-
{{.StructName}}Base
21-
}
22-
2318
{{ if .TableName }}
2419
func ({{.StructName}}) TableName() string {
25-
return "{{.TableName}}"
20+
return "{{.TableName}}"
2621
}
2722
{{ end }}
2823

server/resource/template/server/request.go.tpl

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@ package request
22

33
import "gin-vue-admin/model"
44

5-
type {{.StructName}}Search struct {
6-
model.{{.StructName}}Base
5+
type {{.StructName}}Search struct{
6+
model.{{.StructName}}
77
PageInfo
8-
}
9-
10-
type {{.StructName}}Update struct {
11-
model.{{.StructName}}Base
12-
ID uint `gorm:"primarykey"`
13-
}
14-
8+
}

server/resource/template/server/service.go.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func Delete{{.StructName}}({{.Abbreviation}} model.{{.StructName}}) (err error)
3535
//@return: err error
3636

3737
func Delete{{.StructName}}ByIds(ids request.IdsReq) (err error) {
38-
err = global.GVA_DB.Delete(&[]model.{{.StructName}}{}, "id in ?", ids.Ids).Error
38+
err = global.GVA_DB.Delete(&[]model.{{.StructName}}{},"id in ?",ids.Ids).Error
3939
return err
4040
}
4141

server/resource/template/web/workflowForm.vue.tpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ export default {
117117
return false
118118
}
119119
}
120-
return true
121120
},
122121
...mapGetters("user", ["userInfo"])
123122
},

0 commit comments

Comments
 (0)