Skip to content

cmd/gf: gf gen ctrl add comment #4168

@ywanbing

Description

@ywanbing

Is your feature request related to a problem?

Option Yes

Describe the solution you'd like

可以通过在api的文件中增加req的注释,来生成到 controller 的函数注释。

比如

// GetUserInfoReq 获取用户信息
type GetUserInfoReq struct {
	g.Meta `path:"/consumer/userInfo" method:"get"`
}

生成后的是下面这样

// GetUserInfo 获取用户信息
func (c *ControllerV1) GetUserInfo(ctx context.Context, req *v1.GetUserInfoReq) (res *v1.GetUserInfoRes, err error) {
    return nil, gerror.NewCode(gcode.CodeNotImplemented)
}

Describe alternatives you've considered

  1. 在 genctrl_ast_parse.go 中增加注释的返回
  2. 在 genctrl_api_item.go 中增加注释的字段
  3. 在 genctrl_generate_ctrl.go 中使用注释生成到 controller 的函数上

Additional

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions