修复没有备注时生成文档报错

This commit is contained in:
xiangheng
2023-12-21 16:15:24 +08:00
parent bce060c758
commit cefdc294ef
4 changed files with 15 additions and 11 deletions

View File

@@ -46,7 +46,7 @@ func (hd FlowApplyHandler) List(c *gin.Context) {
// @Tags flow_apply-申请流程 // @Tags flow_apply-申请流程
// @Produce json // @Produce json
// @Param Token header string true "token" // @Param Token header string true "token"
// @Param id query int false "" // @Param id query int false "申请id"
// @Success 200 {object} FlowApplyResp "成功" // @Success 200 {object} FlowApplyResp "成功"
// @Router /api/flow_apply/detail [get] // @Router /api/flow_apply/detail [get]
func (hd FlowApplyHandler) Detail(c *gin.Context) { func (hd FlowApplyHandler) Detail(c *gin.Context) {
@@ -92,7 +92,7 @@ func (hd FlowApplyHandler) Add(c *gin.Context) {
// @Tags flow_apply-申请流程 // @Tags flow_apply-申请流程
// @Produce json // @Produce json
// @Param Token header string true "token" // @Param Token header string true "token"
// @Param id body int false "" // @Param id body int false "申请id"
// @Param templateId body int false "模板" // @Param templateId body int false "模板"
// @Param applyUserId body int false "申请人id" // @Param applyUserId body int false "申请人id"
// @Param applyUserNickname body string false "申请人昵称" // @Param applyUserNickname body string false "申请人昵称"
@@ -116,7 +116,7 @@ func (hd FlowApplyHandler) Edit(c *gin.Context) {
// @Tags flow_apply-申请流程 // @Tags flow_apply-申请流程
// @Produce json // @Produce json
// @Param Token header string true "token" // @Param Token header string true "token"
// @Param id body int false "" // @Param id body int false "申请id"
// @Success 200 {object} response.RespType "成功" // @Success 200 {object} response.RespType "成功"
// @Router /api/flow_apply/del [post] // @Router /api/flow_apply/del [post]
func (hd FlowApplyHandler) Del(c *gin.Context) { func (hd FlowApplyHandler) Del(c *gin.Context) {

View File

@@ -49,7 +49,7 @@ func (hd FlowTemplateHandler) ListAll(c *gin.Context) {
// @Tags flow_template-流程模板 // @Tags flow_template-流程模板
// @Produce json // @Produce json
// @Param Token header string true "token" // @Param Token header string true "token"
// @Param id query int false "" // @Param id query int false "历史id"
// @Success 200 {object} FlowTemplateResp "成功" // @Success 200 {object} FlowTemplateResp "成功"
// @Router /api/flow_template/detail [get] // @Router /api/flow_template/detail [get]
func (hd FlowTemplateHandler) Detail(c *gin.Context) { func (hd FlowTemplateHandler) Detail(c *gin.Context) {
@@ -84,7 +84,7 @@ func (hd FlowTemplateHandler) Add(c *gin.Context) {
// @Tags flow_template-流程模板 // @Tags flow_template-流程模板
// @Produce json // @Produce json
// @Param Token header string true "token" // @Param Token header string true "token"
// @Param id body int false "" // @Param id body int false "."
// @Param flowName body string false "流程名称" // @Param flowName body string false "流程名称"
// @Param flowGroup body int false "流程分类" // @Param flowGroup body int false "流程分类"
// @Param flowRemark body string false "流程描述" // @Param flowRemark body string false "流程描述"
@@ -104,7 +104,7 @@ func (hd FlowTemplateHandler) Edit(c *gin.Context) {
// @Tags flow_template-流程模板 // @Tags flow_template-流程模板
// @Produce json // @Produce json
// @Param Token header string true "token" // @Param Token header string true "token"
// @Param id body int false "" // @Param id body int false "历史id"
// @Success 200 {object} response.RespType "成功" // @Success 200 {object} response.RespType "成功"
// @Router /api/flow_template/del [post] // @Router /api/flow_template/del [post]
func (hd FlowTemplateHandler) Del(c *gin.Context) { func (hd FlowTemplateHandler) Del(c *gin.Context) {

View File

@@ -18,7 +18,7 @@ type {{{ title (toCamelCase .ModuleName) }}}Handler struct {}
// @Param PageSize query int true "每页数量" // @Param PageSize query int true "每页数量"
{{{- range .Columns }}} {{{- range .Columns }}}
{{{- if .IsQuery }}} {{{- if .IsQuery }}}
// @Param {{{ toCamelCase .GoField }}} query {{{ .GoType }}} false "{{{ .ColumnComment }}}" // @Param {{{ toCamelCase .GoField }}} query {{{ .GoType }}} false "{{{ .ColumnComment }}}."
{{{- end }}} {{{- end }}}
{{{- end }}} {{{- end }}}
// @Success 200 {object} []{{{ title (toCamelCase .EntityName) }}}Resp "成功" // @Success 200 {object} []{{{ title (toCamelCase .EntityName) }}}Resp "成功"
@@ -53,7 +53,7 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) ListAll(c *gin.Context
// @Param Token header string true "token" // @Param Token header string true "token"
{{{- range .Columns }}} {{{- range .Columns }}}
{{{- if .IsPk }}} {{{- if .IsPk }}}
// @Param {{{ toCamelCase .GoField }}} query {{{ .GoType }}} false "{{{ .ColumnComment }}}" // @Param {{{ toCamelCase .GoField }}} query {{{ .GoType }}} false "{{{ .ColumnComment }}}."
{{{- end }}} {{{- end }}}
{{{- end }}} {{{- end }}}
// @Success 200 {object} {{{ title (toCamelCase .EntityName) }}}Resp "成功" // @Success 200 {object} {{{ title (toCamelCase .EntityName) }}}Resp "成功"
@@ -74,7 +74,7 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Detail(c *gin.Context)
// @Param Token header string true "token" // @Param Token header string true "token"
{{{- range .Columns }}} {{{- range .Columns }}}
{{{- if .IsInsert }}} {{{- if .IsInsert }}}
// @Param {{{ toCamelCase .GoField }}} body {{{ .GoType }}} false "{{{ .ColumnComment }}}" // @Param {{{ toCamelCase .GoField }}} body {{{ .GoType }}} false "{{{ .ColumnComment }}}."
{{{- end }}} {{{- end }}}
{{{- end }}} {{{- end }}}
// @Success 200 {object} response.RespType "成功" // @Success 200 {object} response.RespType "成功"
@@ -92,7 +92,7 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Add(c *gin.Context) {
// @Param Token header string true "token" // @Param Token header string true "token"
{{{- range .Columns }}} {{{- range .Columns }}}
{{{- if .IsEdit }}} {{{- if .IsEdit }}}
// @Param {{{ toCamelCase .GoField }}} body {{{ .GoType }}} false "{{{ .ColumnComment }}}" // @Param {{{ toCamelCase .GoField }}} body {{{ .GoType }}} false "{{{ .ColumnComment }}}."
{{{- end }}} {{{- end }}}
{{{- end }}} {{{- end }}}
// @Success 200 {object} response.RespType "成功" // @Success 200 {object} response.RespType "成功"
@@ -110,7 +110,7 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Edit(c *gin.Context) {
// @Param Token header string true "token" // @Param Token header string true "token"
{{{- range .Columns }}} {{{- range .Columns }}}
{{{- if .IsPk }}} {{{- if .IsPk }}}
// @Param {{{ toCamelCase .GoField }}} body {{{ .GoType }}} false "{{{ .ColumnComment }}}" // @Param {{{ toCamelCase .GoField }}} body {{{ .GoType }}} false "{{{ .ColumnComment }}}."
{{{- end }}} {{{- end }}}
{{{- end }}} {{{- end }}}
// @Success 200 {object} response.RespType "成功" // @Success 200 {object} response.RespType "成功"

View File

@@ -99,6 +99,10 @@ func main() {
// 初始化router // 初始化router
router := initRouter() router := initRouter()
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler)) router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
fmt.Println("格式化文档注释:", "swag fmt")
fmt.Println("生成文档:", "swag init")
fmt.Println("文档:", "http://localhost:8001/swagger/index.html") fmt.Println("文档:", "http://localhost:8001/swagger/index.html")
// 初始化server // 初始化server
s := initServer(router) s := initServer(router)