feature: 优化添加空方法的apiPath
This commit is contained in:
@@ -229,6 +229,7 @@ type AutoCodeField struct {
|
||||
type AutoFunc struct {
|
||||
Package string `json:"package"`
|
||||
FuncName string `json:"funcName"` // 方法名称
|
||||
Router string `json:"router"` // 路由名称
|
||||
BusinessDB string `json:"businessDB"` // 业务库
|
||||
StructName string `json:"structName"` // Struct名称
|
||||
PackageName string `json:"packageName"` // 文件名称
|
||||
|
@@ -7,7 +7,7 @@
|
||||
// @Param data query request.{{.StructName}}Search true "分页获取{{.Description}}列表"
|
||||
// @Success 200 {object} response.Response{data=object,msg=string} "获取成功"
|
||||
// @Router /{{.Abbreviation}}/{{.FuncName}} [{{.Method}}]
|
||||
func (a *{{.Abbreviation}}) {{.FuncName}}(c *gin.Context) {
|
||||
func (a *{{.Abbreviation}}) {{.Router}}(c *gin.Context) {
|
||||
// 请添加自己的业务逻辑
|
||||
err := service{{ .StructName }}.{{.FuncName}}()
|
||||
if err != nil {
|
||||
@@ -27,7 +27,7 @@ func (a *{{.Abbreviation}}) {{.FuncName}}(c *gin.Context) {
|
||||
// @Produce application/json
|
||||
// @Param data query {{.Package}}Req.{{.StructName}}Search true "成功"
|
||||
// @Success 200 {object} response.Response{data=object,msg=string} "成功"
|
||||
// @Router /{{.Abbreviation}}/{{.FuncName}} [{{.Method}}]
|
||||
// @Router /{{.Abbreviation}}/{{.Router}} [{{.Method}}]
|
||||
func ({{.Abbreviation}}Api *{{.StructName}}Api){{.FuncName}}(c *gin.Context) {
|
||||
// 请添加自己的业务逻辑
|
||||
if err := {{.Abbreviation}}Service.{{.FuncName}}(); err != nil {
|
||||
|
@@ -220,10 +220,10 @@ func (s *autoCodeTemplate) getTemplateStr(t string, info request.AutoFunc) (stri
|
||||
func (s *autoCodeTemplate) addTemplateToAst(t string, info request.AutoFunc) error {
|
||||
tPath := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, "router", info.Package, info.HumpPackageName+".go")
|
||||
funcName := fmt.Sprintf("Init%sRouter", info.StructName)
|
||||
stmtStr := fmt.Sprintf("%sRouterWithoutAuth.%s(\"%s\", %sApi.%s)", info.Abbreviation, info.Method, info.FuncName, info.Abbreviation, info.FuncName)
|
||||
stmtStr := fmt.Sprintf("%sRouterWithoutAuth.%s(\"%s\", %sApi.%s)", info.Abbreviation, info.Method, info.Router, info.Abbreviation, info.FuncName)
|
||||
if info.IsPlugin {
|
||||
tPath = filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, "plugin", info.Package, "router", info.HumpPackageName+".go")
|
||||
stmtStr = fmt.Sprintf("group.%s(\"%s\", api%s.%s)", info.Method, info.FuncName, info.StructName, info.FuncName)
|
||||
stmtStr = fmt.Sprintf("group.%s(\"%s\", api%s.%s)", info.Method, info.Router, info.StructName, info.FuncName)
|
||||
funcName = "Init"
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user