beego 框架自动化生成api

第一步创建api项目   cmd命令创建

bee api ApiName

第二步 cd 到ApiName项目中  粗体是可更改的  member 创建的控制器 模型层 数据表的名字    ——字段   / 连接数据库

bee generate scaffold memeber -fields="name:string,email:text,mobile:string" -driver=mysql -conn="root:root@tcp(127.0.0.1:3306)/beegotest"

 

第三部 是否创建一些东西

2020/09/03 17:01:05 INFO     ▶ 0001 Do you want to create a 'sexc' model? [Yes|No]
y
2020/09/03 17:01:08 INFO     ▶ 0002 Using 'Sexc' as model name
2020/09/03 17:01:08 INFO     ▶ 0003 Using 'models' as package name
        create   E:\Gobee\src\ApiName/models/sexc.go
2020/09/03 17:01:08 INFO     ▶ 0004 Do you want to create a 'sexc' controller? [Yes|No]
y
2020/09/03 17:01:12 INFO     ▶ 0005 Using 'Sexc' as controller name
2020/09/03 17:01:12 INFO     ▶ 0006 Using 'controllers' as package name
2020/09/03 17:01:12 INFO     ▶ 0007 Using matching model 'Sexc'
        create   E:\Gobee\src\ApiName/controllers/sexc.go
2020/09/03 17:01:12 INFO     ▶ 0008 Do you want to create views for this 'sexc' resource? [Yes|No]
y
2020/09/03 17:01:16 INFO     ▶ 0009 Generating view...
        create   E:\Gobee\src\ApiName/views/sexc/logins.html
        create   E:\Gobee\src\ApiName/views/sexc/show.tpl
        create   E:\Gobee\src\ApiName/views/sexc/create.tpl
        create   E:\Gobee\src\ApiName/views/sexc/edit.tpl
2020/09/03 17:01:16 INFO     ▶ 0010 Do you want to create a 'sexc' migration and schema for this resource? [Yes|No]
y
        create   E:\Gobee\src\ApiName/database/migrations/20200903_170121_sexc.go
2020/09/03 17:01:21 INFO     ▶ 0011 Do you want to migrate the database? [Yes|No]
y
2020/09/03 17:01:23 INFO     ▶ 0012 Creating 'migrations' table...
2020/09/03 17:01:27 INFO     ▶ 0013 |> 2020/09/03 17:01:25.108 [I]  start upgrade Sexc_20200903_170121
2020/09/03 17:01:27 INFO     ▶ 0014 |> 2020/09/03 17:01:25.108 [I]  exec sql: CREATE TABLE sexc(`id` int(11) NOT NULL AUTO_INCREMENT,`name` va
rchar(128) NOT NULL,`email` longtext  NOT NULL,`mobile` varchar(128) NOT NULL,PRIMARY KEY (`id`))
2020/09/03 17:01:27 INFO     ▶ 0015 |> 2020/09/03 17:01:25.115 [I]  end upgrade: Sexc_20200903_170121
2020/09/03 17:01:27 INFO     ▶ 0016 |> 2020/09/03 17:01:25.115 [I]  total success upgrade: 1  migration
2020/09/03 17:01:27 SUCCESS  ▶ 0017 All done! Don't forget to add  beego.Router("/sexc" ,&controllers.SexcController{}) to routers/route.go

2020/09/03 17:01:27 SUCCESS  ▶ 0018 Scaffold successfully generated!

  就可以看到你一键生成的项目

posted @ 2020-09-03 17:11  拉斯维加斯  阅读(347)  评论(0)    收藏  举报