livebud/bud

How to change default id:int to name:string in generated url path?

开放

#363 创建于 2023年1月22日

 (1 条评论) (0 个反应) (0 位负责人)JavaScript (211 个派生)batch import
bughelp wantedimprovement

仓库指标

星标
 (5,391 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

First of all thank you very much for the tool, very useful.
I have some questions waiting for your help.

1. how to change id:int to name:string?

If I run the following commands to generate controller and view, I got a generated path like // GET /pscluster/:pscluster_id/psmeta/:id. Do we have some cli flags to change ":pscluter_id int" to ":pscluster_name string"?

bud new controller pscluster index new create show edit update delete
bud new controller pscluster/psmeta create show edit update delete


// GET /pscluster/:pscluster_id/psmeta/:id

2. why this strange name generated?

when I run bud new controller pscluster/psmeta create show edit update delete, I got a strange struct name, which change psmeta to psmetum

// Psmetum struct
type Psmetum struct {
	ID int `json:"id"`
}

// Create psmetum
// POST /pscluster/:pscluster_id/psmeta
func (c *Controller) Create(ctx context.Context) (psmetum *Psmetum, err error) {
	return &Psmetum{
		ID: 0,
	}, nil
}

3. Underscores become dashes in url

bud new controller ps_cluster index new create show edit update delete
// GET /ps-cluster

贡献者指南