Skip to content

Commit 39badd5

Browse files
author
奇淼(piexlmax
authored
Merge pull request #560 from iiiusky/fix/commentStyle
修改模板中的注释格式为官方推荐的格式
2 parents e8beb15 + 4260a2e commit 39badd5

File tree

4 files changed

+22
-37
lines changed

4 files changed

+22
-37
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"go.uber.org/zap"
1111
)
1212

13+
// Create{{.StructName}} 创建{{.StructName}}
1314
// @Tags {{.StructName}}
1415
// @Summary 创建{{.StructName}}
1516
// @Security ApiKeyAuth
@@ -29,6 +30,7 @@ func Create{{.StructName}}(c *gin.Context) {
2930
}
3031
}
3132

33+
// Delete{{.StructName}} 删除{{.StructName}}
3234
// @Tags {{.StructName}}
3335
// @Summary 删除{{.StructName}}
3436
// @Security ApiKeyAuth
@@ -48,6 +50,7 @@ func Delete{{.StructName}}(c *gin.Context) {
4850
}
4951
}
5052

53+
// Delete{{.StructName}}ByIds 批量删除{{.StructName}}
5154
// @Tags {{.StructName}}
5255
// @Summary 批量删除{{.StructName}}
5356
// @Security ApiKeyAuth
@@ -67,6 +70,7 @@ func Delete{{.StructName}}ByIds(c *gin.Context) {
6770
}
6871
}
6972

73+
// Update{{.StructName}} 更新{{.StructName}}
7074
// @Tags {{.StructName}}
7175
// @Summary 更新{{.StructName}}
7276
// @Security ApiKeyAuth
@@ -86,6 +90,7 @@ func Update{{.StructName}}(c *gin.Context) {
8690
}
8791
}
8892

93+
// Find{{.StructName}} 用id查询{{.StructName}}
8994
// @Tags {{.StructName}}
9095
// @Summary 用id查询{{.StructName}}
9196
// @Security ApiKeyAuth
@@ -105,6 +110,7 @@ func Find{{.StructName}}(c *gin.Context) {
105110
}
106111
}
107112

113+
// Get{{.StructName}}List 分页获取{{.StructName}}列表
108114
// @Tags {{.StructName}}
109115
// @Summary 分页获取{{.StructName}}列表
110116
// @Security ApiKeyAuth

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"gin-vue-admin/global"
66
)
77

8+
// {{.StructName}} 结构体
89
// 如果含有time.Time 请自行import time包
910
type {{.StructName}} struct {
1011
global.GVA_MODEL {{- range .Fields}}
@@ -16,6 +17,7 @@ type {{.StructName}} struct {
1617
}
1718

1819
{{ if .TableName }}
20+
// TableName {{.StructName}} 表名
1921
func ({{.StructName}}) TableName() string {
2022
return "{{.TableName}}"
2123
}

server/resource/template/server/router.go.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/gin-gonic/gin"
77
)
88

9+
// Init{{.StructName}}Router 初始化 {{.StructName}} 路由信息
910
func Init{{.StructName}}Router(Router *gin.RouterGroup) {
1011
{{.StructName}}Router := Router.Group("{{.Abbreviation}}").Use(middleware.OperationRecord())
1112
{

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

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,67 +6,43 @@ import (
66
"gin-vue-admin/model/request"
77
)
88

9-
//@author: [piexlmax](https://github.com/piexlmax)
10-
//@function: Create{{.StructName}}
11-
//@description: 创建{{.StructName}}记录
12-
//@param: {{.Abbreviation}} model.{{.StructName}}
13-
//@return: err error
14-
9+
// Create{{.StructName}} 创建{{.StructName}}记录
10+
// Author [piexlmax](https://github.com/piexlmax)
1511
func Create{{.StructName}}({{.Abbreviation}} model.{{.StructName}}) (err error) {
1612
err = global.GVA_DB.Create(&{{.Abbreviation}}).Error
1713
return err
1814
}
1915

20-
//@author: [piexlmax](https://github.com/piexlmax)
21-
//@function: Delete{{.StructName}}
22-
//@description: 删除{{.StructName}}记录
23-
//@param: {{.Abbreviation}} model.{{.StructName}}
24-
//@return: err error
25-
16+
// Delete{{.StructName}} 删除{{.StructName}}记录
17+
// Author [piexlmax](https://github.com/piexlmax)
2618
func Delete{{.StructName}}({{.Abbreviation}} model.{{.StructName}}) (err error) {
2719
err = global.GVA_DB.Delete(&{{.Abbreviation}}).Error
2820
return err
2921
}
3022

31-
//@author: [piexlmax](https://github.com/piexlmax)
32-
//@function: Delete{{.StructName}}ByIds
33-
//@description: 批量删除{{.StructName}}记录
34-
//@param: ids request.IdsReq
35-
//@return: err error
36-
23+
// Delete{{.StructName}}ByIds 批量删除{{.StructName}}记录
24+
// Author [piexlmax](https://github.com/piexlmax)
3725
func Delete{{.StructName}}ByIds(ids request.IdsReq) (err error) {
3826
err = global.GVA_DB.Delete(&[]model.{{.StructName}}{},"id in ?",ids.Ids).Error
3927
return err
4028
}
4129

42-
//@author: [piexlmax](https://github.com/piexlmax)
43-
//@function: Update{{.StructName}}
44-
//@description: 更新{{.StructName}}记录
45-
//@param: {{.Abbreviation}} *model.{{.StructName}}
46-
//@return: err error
47-
30+
// Update{{.StructName}} 更新{{.StructName}}记录
31+
// Author [piexlmax](https://github.com/piexlmax)
4832
func Update{{.StructName}}({{.Abbreviation}} model.{{.StructName}}) (err error) {
4933
err = global.GVA_DB.Save(&{{.Abbreviation}}).Error
5034
return err
5135
}
5236

53-
//@author: [piexlmax](https://github.com/piexlmax)
54-
//@function: Get{{.StructName}}
55-
//@description: 根据id获取{{.StructName}}记录
56-
//@param: id uint
57-
//@return: err error, {{.Abbreviation}} model.{{.StructName}}
58-
37+
// Get{{.StructName}} 根据id获取{{.StructName}}记录
38+
// Author [piexlmax](https://github.com/piexlmax)
5939
func Get{{.StructName}}(id uint) (err error, {{.Abbreviation}} model.{{.StructName}}) {
6040
err = global.GVA_DB.Where("id = ?", id).First(&{{.Abbreviation}}).Error
6141
return
6242
}
6343

64-
//@author: [piexlmax](https://github.com/piexlmax)
65-
//@function: Get{{.StructName}}InfoList
66-
//@description: 分页获取{{.StructName}}记录
67-
//@param: info request.{{.StructName}}Search
68-
//@return: err error, list interface{}, total int64
69-
44+
// Get{{.StructName}}InfoList 分页获取{{.StructName}}记录
45+
// Author [piexlmax](https://github.com/piexlmax)
7046
func Get{{.StructName}}InfoList(info request.{{.StructName}}Search) (err error, list interface{}, total int64) {
7147
limit := info.PageSize
7248
offset := info.PageSize * (info.Page - 1)
@@ -102,4 +78,4 @@ func Get{{.StructName}}InfoList(info request.{{.StructName}}Search) (err error,
10278
err = db.Count(&total).Error
10379
err = db.Limit(limit).Offset(offset).Find(&{{.Abbreviation}}s).Error
10480
return err, {{.Abbreviation}}s, total
105-
}
81+
}

0 commit comments

Comments
 (0)