|
|
### 使用
|
|
|
1. git clone http://gitlab.fjmaimaimai.com/mmm-go/gencode.git
|
|
|
|
|
|
2. go build
|
|
|
|
|
|
3. 查看帮助 ./gencode
|
|
|
|
|
|
4. 生成代码 ./gencode.exe new -c Auth -m Login
|
|
|
-c 控制器名
|
|
|
-m 方法名
|
|
|
|
|
|
5. 查看生成文件 cat gencode.out
|
|
|
|
|
|
```golang
|
|
|
|
|
|
//Login
|
|
|
func(this *AuthController)Login(){
|
|
|
var msg *mybeego.Message
|
|
|
defer func(){
|
|
|
this.Resp(msg)
|
|
|
}()
|
|
|
var request *protocol.LoginRequest
|
|
|
if err:=json.Unmarshal(this.ByteBody,&request);err!=nil{
|
|
|
log.Error(err)
|
|
|
msg = mybeego.NewMessage(1)
|
|
|
return
|
|
|
}
|
|
|
if b,m :=this.Valid(request);!b{
|
|
|
msg = m
|
|
|
return
|
|
|
}
|
|
|
msg = this.GenMessage(auth.Login(request))
|
|
|
}
|
|
|
|
|
|
/*Login */
|
|
|
type LoginRequest struct {
|
|
|
Xxx string`json:"xxx" valid:"Required"`
|
|
|
}
|
|
|
type LoginResponse struct {
|
|
|
}
|
|
|
|
|
|
func Login(request *protocol.LoginRequest)(rsp *protocol.LoginResponse,err error){
|
|
|
var (
|
|
|
|
|
|
)
|
|
|
rsp =&protocol.LoginResponse{}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
/*login controller*/
|
|
|
{
|
|
|
auth :=&v1.AuthController{}
|
|
|
nsV1.Router("/auth/login",auth,"post:Login")
|
|
|
}
|
|
|
``` |
|
|
\ No newline at end of file |
...
|
...
|
|