# 基于 golang 的后台管理脚手架 go-admin 的使用步骤 {#基于-golang-的后台管理脚手架-go-admin-的使用步骤}
本文讲述基于 golang 的后台管理脚手架 go-admin 的使用步骤。
# 1. 后台 {#_1-后台}
# 1.1 下载工程代码 {#_1-1-下载工程代码}
git clone https://github.com/go-admin-team/go-admin.git
# 1.2 创建数据库 {#_1-2-创建数据库}
create database site_container default CHARSET utf8mb4 collate utf8mb4_general_ci;
# 1.3 创建配置文件 {#_1-3-创建配置文件}
基于模板配置文件创建开发环境的配置文件,执行如下命令
cp config/settings.yml config/settings.dev.yml
修改配置文件
database:
# 数据库类型 mysql,sqlite3, postgres
driver: mysql
# 数据库连接字符串 mysql 缺省信息 charset=utf8&parseTime=True&loc=Local&timeout=1000ms
source: root:123456@tcp(127.0.0.1:3306)/site_container?charset=utf8&parseTime=True&loc=Local&timeout=1000ms
gen:
# 代码生成读取的数据库名称
dbname: site_container
# 代码生成是使用前端代码存放位置,需要指定到src文件夹,相对路径
frontpath: ../go-admin-ui/src
# 1.4 运行 {#_1-4-运行}
# 1.4.1 编译 {#_1-4-1-编译}
执行命令go build -o ./go-admin
编译程序, 生成可执行文件./go-admin
go build -o ./go-admin
# 1.4.2 初始化数据库数据 {#_1-4-2-初始化数据库数据}
./go-admin migrate -c=config/settings.dev.yml
注意: 该初始化操作一共依赖2个文件: config/settings.dev.yml和config/db.sql。 所以,若是部署到生产环境,初始化时不要丢掉config/db.sql文件。
# 1.4.3 运行 {#_1-4-3-运行}
执行命令./go-admin server -c=config/settings.dev.yml
运行服务。
(py3.6) wangshibiao@wangshibiao:/data/workspace/wangshibiao/go-admin/go-admin$ ./go-admin server -c=config/settings.dev.yml
warning config not found settings.ssl in the configuration
2020-12-04 16:34:05.431 [INFO] Logger init success!
2020-12-04 16:34:05.432 [INFO] mysql_drive.go:25: root:123456@tcp(127.0.0.1:3306)/site_container?charset=utf8&parseTime=True&loc=Local&timeout=1000ms
2020-12-04 16:34:05.433 [INFO] mysql_drive.go:42: mysql connect success !
2020-12-04 16:34:05.435 [INFO] server.go:67: starting api server
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
- using code: gin.SetMode(gin.ReleaseMode)
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
- using code: gin.SetMode(gin.ReleaseMode)
[GIN-debug] GET / --> go-admin/app/admin/apis/system.HelloWorld (7 handlers)
[GIN-debug] GET /info --> go-admin/app/admin/middleware/handler.Ping (7 handlers)
[GIN-debug] GET /static/*filepath --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (7 handlers)
[GIN-debug] HEAD /static/*filepath --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (7 handlers)
[GIN-debug] GET /form-generator/*filepath --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (7 handlers)
[GIN-debug] HEAD /form-generator/*filepath --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (7 handlers)
[GIN-debug] GET /swagger/*any --> github.com/swaggo/gin-swagger.CustomWrapHandler.func1 (7 handlers)
[GIN-debug] GET /api/v1/monitor/server --> go-admin/app/admin/apis/monitor.ServerInfo (7 handlers)
[GIN-debug] GET /api/v1/getCaptcha --> go-admin/app/admin/apis/system.GenerateCaptchaHandler (7 handlers)
[GIN-debug] GET /api/v1/gen/preview/:tableId --> go-admin/app/admin/apis/tools.Preview (7 handlers)
[GIN-debug] GET /api/v1/gen/toproject/:tableId --> go-admin/app/admin/apis/tools.GenCodeV3 (7 handlers)
[GIN-debug] GET /api/v1/gen/todb/:tableId --> go-admin/app/admin/apis/tools.GenMenuAndApi (7 handlers)
[GIN-debug] GET /api/v1/gen/tabletree --> go-admin/app/admin/apis/tools.GetSysTablesTree (7 handlers)
[GIN-debug] GET /api/v1/menuTreeselect --> go-admin/app/admin/apis/system.GetMenuTreeelect (7 handlers)
[GIN-debug] GET /api/v1/dict/databytype/:dictType --> go-admin/app/admin/apis/system/dict.GetDictDataByDictType (7 handlers)
[GIN-debug] GET /api/v1/db/tables/page --> go-admin/app/admin/apis/tools.GetDBTableList (7 handlers)
[GIN-debug] GET /api/v1/db/columns/page --> go-admin/app/admin/apis/tools.GetDBColumnList (7 handlers)
[GIN-debug] GET /api/v1/sys/tables/page --> go-admin/app/admin/apis/tools.GetSysTableList (7 handlers)
[GIN-debug] POST /api/v1/sys/tables/info --> go-admin/app/admin/apis/tools.InsertSysTable (7 handlers)
[GIN-debug] PUT /api/v1/sys/tables/info --> go-admin/app/admin/apis/tools.UpdateSysTable (7 handlers)
[GIN-debug] DELETE /api/v1/sys/tables/info/:tableId --> go-admin/app/admin/apis/tools.DeleteSysTables (7 handlers)
[GIN-debug] GET /api/v1/sys/tables/info/:tableId --> go-admin/app/admin/apis/tools.GetSysTables (7 handlers)
[GIN-debug] GET /api/v1/sys/tables/info --> go-admin/app/admin/apis/tools.GetSysTablesInfo (7 handlers)
[GIN-debug] POST /api/v1/public/uploadFile --> go-admin/app/admin/apis/public.UploadFile (7 handlers)
[GIN-debug] GET /api/v1/setting --> go-admin/app/admin/apis/system.GetSetting (7 handlers)
[GIN-debug] POST /api/v1/setting --> go-admin/app/admin/apis/system.CreateSetting (7 handlers)
[GIN-debug] GET /api/v1/setting/serverInfo --> go-admin/app/admin/apis/monitor.ServerInfo (7 handlers)
[GIN-debug] POST /login --> go-admin/pkg/jwtauth.(*GinJWTMiddleware).LoginHandler-fm (7 handlers)
[GIN-debug] GET /refresh_token --> go-admin/pkg/jwtauth.(*GinJWTMiddleware).RefreshHandler-fm (7 handlers)
[GIN-debug] GET /ws/:id/:channel --> go-admin/pkg/ws.(*Manager).WsClient-fm (8 handlers)
[GIN-debug] GET /wslogout/:id/:channel --> go-admin/pkg/ws.(*Manager).UnWsClient-fm (8 handlers)
[GIN-debug] GET /api/v1/deptList --> go-admin/app/admin/apis/system.GetDeptList (9 handlers)
[GIN-debug] GET /api/v1/deptTree --> go-admin/app/admin/apis/system.GetDeptTree (9 handlers)
[GIN-debug] GET /api/v1/sysUserList --> go-admin/app/admin/apis/system.GetSysUserList (9 handlers)
[GIN-debug] GET /api/v1/rolelist --> go-admin/app/admin/apis/system.GetRoleList (9 handlers)
[GIN-debug] GET /api/v1/configList --> go-admin/app/admin/apis/system.GetConfigList (9 handlers)
[GIN-debug] GET /api/v1/postlist --> go-admin/app/admin/apis/system.GetPostList (9 handlers)
[GIN-debug] GET /api/v1/menulist --> go-admin/app/admin/apis/system.GetMenuList (9 handlers)
[GIN-debug] GET /api/v1/loginloglist --> go-admin/app/admin/apis/log.GetLoginLogList (9 handlers)
[GIN-debug] GET /api/v1/getinfo --> go-admin/app/admin/apis/system.GetInfo (9 handlers)
[GIN-debug] GET /api/v1/menurole --> go-admin/app/admin/apis/system.GetMenuRole (9 handlers)
[GIN-debug] PUT /api/v1/roledatascope --> go-admin/app/admin/apis/system.UpdateRoleDataScope (9 handlers)
[GIN-debug] GET /api/v1/roleMenuTreeselect/:roleId --> go-admin/app/admin/apis/system.GetMenuTreeRoleselect (9 handlers)
[GIN-debug] GET /api/v1/roleDeptTreeselect/:roleId --> go-admin/app/admin/apis/system.GetDeptTreeRoleselect (9 handlers)
[GIN-debug] POST /api/v1/logout --> go-admin/app/admin/middleware/handler.LogOut (9 handlers)
[GIN-debug] GET /api/v1/menuids --> go-admin/app/admin/apis/system.GetMenuIDS (9 handlers)
[GIN-debug] GET /api/v1/operloglist --> go-admin/app/admin/apis/log.GetOperLogList (9 handlers)
[GIN-debug] GET /api/v1/configKey/:configKey --> go-admin/app/admin/apis/system.GetConfigByConfigKey (9 handlers)
[GIN-debug] GET /api/v1/dept/:deptId --> go-admin/app/admin/apis/system.GetDept (9 handlers)
[GIN-debug] POST /api/v1/dept --> go-admin/app/admin/apis/system.InsertDept (9 handlers)
[GIN-debug] PUT /api/v1/dept --> go-admin/app/admin/apis/system.UpdateDept (9 handlers)
[GIN-debug] DELETE /api/v1/dept/:id --> go-admin/app/admin/apis/system.DeleteDept (9 handlers)
[GIN-debug] GET /api/v1/dict/datalist --> go-admin/app/admin/apis/system/dict.GetDictDataList (9 handlers)
[GIN-debug] GET /api/v1/dict/typelist --> go-admin/app/admin/apis/system/dict.GetDictTypeList (9 handlers)
[GIN-debug] GET /api/v1/dict/typeoptionselect --> go-admin/app/admin/apis/system/dict.GetDictTypeOptionSelect (9 handlers)
[GIN-debug] GET /api/v1/dict/data/:dictCode --> go-admin/app/admin/apis/system/dict.GetDictData (9 handlers)
[GIN-debug] POST /api/v1/dict/data --> go-admin/app/admin/apis/system/dict.InsertDictData (9 handlers)
[GIN-debug] PUT /api/v1/dict/data/ --> go-admin/app/admin/apis/system/dict.UpdateDictData (9 handlers)
[GIN-debug] DELETE /api/v1/dict/data/:dictCode --> go-admin/app/admin/apis/system/dict.DeleteDictData (9 handlers)
[GIN-debug] GET /api/v1/dict/type/:dictId --> go-admin/app/admin/apis/system/dict.GetDictType (9 handlers)
[GIN-debug] POST /api/v1/dict/type --> go-admin/app/admin/apis/system/dict.InsertDictType (9 handlers)
[GIN-debug] PUT /api/v1/dict/type --> go-admin/app/admin/apis/system/dict.UpdateDictType (9 handlers)
[GIN-debug] DELETE /api/v1/dict/type/:dictId --> go-admin/app/admin/apis/system/dict.DeleteDictType (9 handlers)
[GIN-debug] GET /api/v1/sysUser/:userId --> go-admin/app/admin/apis/system.GetSysUser (9 handlers)
[GIN-debug] GET /api/v1/sysUser/ --> go-admin/app/admin/apis/system.GetSysUserInit (9 handlers)
[GIN-debug] POST /api/v1/sysUser --> go-admin/app/admin/apis/system.InsertSysUser (9 handlers)
[GIN-debug] PUT /api/v1/sysUser --> go-admin/app/admin/apis/system.UpdateSysUser (9 handlers)
[GIN-debug] DELETE /api/v1/sysUser/:userId --> go-admin/app/admin/apis/system.DeleteSysUser (9 handlers)
[GIN-debug] GET /api/v1/role/:roleId --> go-admin/app/admin/apis/system.GetRole (9 handlers)
[GIN-debug] POST /api/v1/role --> go-admin/app/admin/apis/system.InsertRole (9 handlers)
[GIN-debug] PUT /api/v1/role --> go-admin/app/admin/apis/system.UpdateRole (9 handlers)
[GIN-debug] DELETE /api/v1/role/:roleId --> go-admin/app/admin/apis/system.DeleteRole (9 handlers)
[GIN-debug] GET /api/v1/config/:configId --> go-admin/app/admin/apis/system.GetConfig (9 handlers)
[GIN-debug] POST /api/v1/config --> go-admin/app/admin/apis/system.InsertConfig (9 handlers)
[GIN-debug] PUT /api/v1/config --> go-admin/app/admin/apis/system.UpdateConfig (9 handlers)
[GIN-debug] DELETE /api/v1/config/:configId --> go-admin/app/admin/apis/system.DeleteConfig (9 handlers)
[GIN-debug] GET /api/v1/user/profile --> go-admin/app/admin/apis/system.GetSysUserProfile (9 handlers)
[GIN-debug] POST /api/v1/user/avatar --> go-admin/app/admin/apis/system.InsetSysUserAvatar (9 handlers)
[GIN-debug] PUT /api/v1/user/pwd --> go-admin/app/admin/apis/system.SysUserUpdatePwd (9 handlers)
[GIN-debug] GET /api/v1/post/:postId --> go-admin/app/admin/apis/system.GetPost (9 handlers)
[GIN-debug] POST /api/v1/post --> go-admin/app/admin/apis/system.InsertPost (9 handlers)
[GIN-debug] PUT /api/v1/post --> go-admin/app/admin/apis/system.UpdatePost (9 handlers)
[GIN-debug] DELETE /api/v1/post/:postId --> go-admin/app/admin/apis/system.DeletePost (9 handlers)
[GIN-debug] GET /api/v1/menu/:id --> go-admin/app/admin/apis/system.GetMenu (9 handlers)
[GIN-debug] POST /api/v1/menu --> go-admin/app/admin/apis/system.InsertMenu (9 handlers)
[GIN-debug] PUT /api/v1/menu --> go-admin/app/admin/apis/system.UpdateMenu (9 handlers)
[GIN-debug] DELETE /api/v1/menu/:id --> go-admin/app/admin/apis/system.DeleteMenu (9 handlers)
[GIN-debug] GET /api/v1/loginlog/:infoId --> go-admin/app/admin/apis/log.GetLoginLog (9 handlers)
[GIN-debug] POST /api/v1/loginlog --> go-admin/app/admin/apis/log.InsertLoginLog (9 handlers)
[GIN-debug] PUT /api/v1/loginlog --> go-admin/app/admin/apis/log.UpdateLoginLog (9 handlers)
[GIN-debug] DELETE /api/v1/loginlog/:infoId --> go-admin/app/admin/apis/log.DeleteLoginLog (9 handlers)
[GIN-debug] GET /api/v1/operlog/:operId --> go-admin/app/admin/apis/log.GetOperLog (9 handlers)
[GIN-debug] DELETE /api/v1/operlog/:operId --> go-admin/app/admin/apis/log.DeleteOperLog (9 handlers)
[GIN-debug] GET /api/v1/nilcheckrole --> (7 handlers)
[GIN-debug] GET /api/v1/sysfileinfoList --> go-admin/app/admin/apis/sysfileinfo.GetSysFileInfoList (7 handlers)
[GIN-debug] GET /api/v1/sysfileinfo/:id --> go-admin/app/admin/apis/sysfileinfo.GetSysFileInfo (7 handlers)
[GIN-debug] POST /api/v1/sysfileinfo --> go-admin/app/admin/apis/sysfileinfo.InsertSysFileInfo (7 handlers)
[GIN-debug] PUT /api/v1/sysfileinfo --> go-admin/app/admin/apis/sysfileinfo.UpdateSysFileInfo (7 handlers)
[GIN-debug] DELETE /api/v1/sysfileinfo/:id --> go-admin/app/admin/apis/sysfileinfo.DeleteSysFileInfo (7 handlers)
[GIN-debug] GET /api/v1/sysfiledirList --> go-admin/app/admin/apis/sysfiledir.GetSysFileDirList (7 handlers)
[GIN-debug] GET /api/v1/sysfiledir/:id --> go-admin/app/admin/apis/sysfiledir.GetSysFileDir (7 handlers)
[GIN-debug] POST /api/v1/sysfiledir --> go-admin/app/admin/apis/sysfiledir.InsertSysFileDir (7 handlers)
[GIN-debug] PUT /api/v1/sysfiledir --> go-admin/app/admin/apis/sysfiledir.UpdateSysFileDir (7 handlers)
[GIN-debug] DELETE /api/v1/sysfiledir/:id --> go-admin/app/admin/apis/sysfiledir.DeleteSysFileDir (7 handlers)
[GIN-debug] GET /api/v1/checkrole --> (7 handlers)
[GIN-debug] GET /api/v1/sysjob --> go-admin/common/actions.IndexAction.func1 (10 handlers)
[GIN-debug] GET /api/v1/sysjob/:id --> go-admin/common/actions.ViewAction.func1 (10 handlers)
[GIN-debug] POST /api/v1/sysjob --> go-admin/common/actions.CreateAction.func1 (9 handlers)
[GIN-debug] PUT /api/v1/sysjob --> go-admin/common/actions.UpdateAction.func1 (10 handlers)
[GIN-debug] DELETE /api/v1/sysjob --> go-admin/common/actions.DeleteAction.func1 (10 handlers)
[GIN-debug] GET /api/v1/job/remove/:id --> go-admin/app/admin/apis/sysjob.(*SysJob).RemoveJobForService-fm (7 handlers)
[GIN-debug] GET /api/v1/job/start/:id --> go-admin/app/admin/apis/sysjob.(*SysJob).StartJobForService-fm (7 handlers)
[GIN-debug] GET /api/v1/syscontent/:id --> go-admin/app/admin/apis/syscontent.GetSysContent (9 handlers)
[GIN-debug] POST /api/v1/syscontent --> go-admin/app/admin/apis/syscontent.InsertSysContent (9 handlers)
[GIN-debug] PUT /api/v1/syscontent --> go-admin/app/admin/apis/syscontent.UpdateSysContent (9 handlers)
[GIN-debug] DELETE /api/v1/syscontent/:id --> go-admin/app/admin/apis/syscontent.DeleteSysContent (9 handlers)
[GIN-debug] GET /api/v1/syscontentList --> go-admin/app/admin/apis/syscontent.GetSysContentList (9 handlers)
[GIN-debug] GET /api/v1/syscategory/:id --> go-admin/app/admin/apis/syscategory.GetSysCategory (9 handlers)
[GIN-debug] POST /api/v1/syscategory --> go-admin/app/admin/apis/syscategory.InsertSysCategory (9 handlers)
[GIN-debug] PUT /api/v1/syscategory --> go-admin/app/admin/apis/syscategory.UpdateSysCategory (9 handlers)
[GIN-debug] DELETE /api/v1/syscategory/:id --> go-admin/app/admin/apis/syscategory.DeleteSysCategory (9 handlers)
[GIN-debug] GET /api/v1/syscategoryList --> go-admin/app/admin/apis/syscategory.GetSysCategoryList (9 handlers)
____
,---, ,' , `. ,--,
,---. ,---,. ,---.'| ,-+-,.' _ |,--.'| ,---,
,----._,. ' ,'\ ,' .' | | | : ,-+-. ; , ||| |, ,-+-. / |
/ / ' / / / |,---.' , ,--.--. | | | ,--.'|' | ||`--'_ ,--.'|' |
| : |. ; ,. :| | |/ \ ,--.__| || | ,', | |,,' ,'| | | ,"' |
| | .\ .' | |: :: : .'.--. .-. | / ,' || | / | |--' ' | | | | / | |
. ; '; |' | .; :: |.' \__\/: . .. ' / || : | | , | | : | | | | |
' . . || : |`---' ," .--.; |' ; |: || : | |/ ' : |__ | | | |/
`---`-'| | \ \ / / / ,. || | '/ '| | |`-' | | '.'|| | |--'
.'__/\_: | `----' ; : .' \ : :|| ;/ ; : ;| |/
| : : | , .-./\ \ / '---' | , / '---'
\ \ / `--`---' `----' ---`-'
`--`-'
欢迎使用 go-admin 1.2.0 可以使用 -h 查看命令
Server run at:
- Local: http://localhost:8000/
2020/12/04 16:34:05 websocket manage start
2020-12-04 16:34:05 [INFO] JobCore Starting...
- Network: http://172.16.10.199:8000/
Swagger run at:
- Local: http://localhost:8000/swagger/index.html
- Network: http://172.16.10.199:8000/swagger/index.html
2020-12-04 16:34:05 Enter Control + C Shutdown Server
2020-12-04 16:34:05 [INFO] JobCore total:0
2020-12-04 16:34:05 [INFO] JobCore start success.
# 1.4.4 debug调试 {#_1-4-4-debug调试}
若想借助vscode debug调试, 则参考如下运行配置:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "go-admin",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceRoot}/main.go",
"env": {},
"args": ["server", "-c", "config/settings.dev.yml"]
}
]
}
# 1.5 访问接口文档 {#_1-5-访问接口文档}
接口文档访问路径: http://localhost:8000/swagger/index.html
# 2. 前端页面 {#_2-前端页面}
# 2.1 下载工程代码 {#_2-1-下载工程代码}
git clone https://github.com/go-admin-team/go-admin-ui.git
# 2.2 安装依赖 {#_2-2-安装依赖}
进入工程根目录, 执行命令npm install
安装依赖包。
npm install
如果安装错误,请尝试切换到其它 node 版本或改用 yarn 重试。
我最终在node v15.0.1
下使用 yarn 命令安装依赖成功。
中间经历几次网络错误导致安装失败,则尝试如下2个方案:
- 反复重试可能会成功; 2. 若提示http://raw.githubusercontent.com/无法访问,则需要配置下本机hosts文件,访问ipaddress (opens new window)查询该域名的实际IP, 然后配置到hosts文件中(如199.232.96.133 raw.githubusercontent.com),然后再重试。
# 2.3 运行 {#_2-3-运行}
npm run dev
运行时报了如下错误, 则按提示执行命令npm install @vue/babel-preset-app --save-dev
安装对应依赖
ERROR Error: Cannot find module '@vue/babel-preset-app' from '/data/workspace/wangshibiao/go-admin/go-admin-ui'
然后重新重试,运行成功。
(py3.6) wangshibiao@wangshibiao:/data/workspace/wangshibiao/go-admin/go-admin-ui$ npm run dev
> go-admin@1.2.0 dev
> vue-cli-service serve
INFO Starting development server...
98% after emitting CopyPlugin
DONE Compiled successfully in 38597ms 下午5:33:56
App running at:
- Local: http://localhost:9527/
- Network: http://172.16.10.199:9527/
Note that the development build is not optimized.
To create a production build, run yarn build.
# 2.4 访问页面 {#_2-4-访问页面}
浏览器访问http://localhost:9527/, 界面如下:
主页面如下:
# 3. 自动生成代码 {#_3-自动生成代码}
# 3.1 创建数据库表 {#_3-1-创建数据库表}
使用sql语句手动创建数据库表。
# 3.2 导入数据库表 {#_3-2-导入数据库表}
通过后台的导入功能,导入创建的数据库表。
# 3.3 修改表的相关信息 {#_3-3-修改表的相关信息}
可以设置表单创建、修改、查询表单
要显示哪些字段。
表单的每一项都可以选择要渲染的样式,比如性别字段可以渲染为单选框,以性别单选框为例,讲解配置步骤:
- 创建性别字典
定义字典,名称为性别
, 并配置选项列表以及每个选项的取值。 - 设置字段信息 字段信息模块中,对指定的字段的
显示类型
配置为单选框
,同时字典类型
配置为性别
。
导入表之后,在编辑页面修改
字段信息
模块的字段描述
,该列的内容会渲染为表单的标题,所以尽量简短,否则页面会比较难看。
生成信息
模块的指定应用名
一项默认值为admin
,建议修改为对应表名,否则普通用户访问该表的列表页时,会隐藏掉增删改的按钮(因为默认情况下,自动生成页面中的增删改按钮的权限字符串是以admin
开头,如admin:distributor:add, 实际上该菜单的权限是distributor:distributor:add, 因为不匹配,导致普通用户没有看到对应按钮)。
可以设置表单的"选填"或"必填"项。但是注意的是,最终渲染的必填项并不是以"必填"列为准,而是以"查询"列为准,是系统bug。
# 3.4 生成代码 {#_3-4-生成代码}
使用后台的生成代码功能,生成前端和后台代码。前端和后台代码会自动生成到2个工程项目的对应目录中。
生成完代码后,需要重启后台服务。
# 3.5 生成菜单配置和权限配置节点 {#_3-5-生成菜单配置和权限配置节点}
点击代码生成功能的"配置生成"按钮即可。
刷新页面,发现左侧多了一个菜单。查看接口文档,发现多了对应了接口定义。(前提是以admin账号登录)
# 3.6 权限配置 {#_3-6-权限配置}
为角色配置如下几个权限: 名为"必开接口"的权限、 "要分配的菜单权限"、"要分配的api权限"。
为用户分配该角色
# 4. 总结 {#_4-总结}
- 目前发现go-admin脚手架存在的不足: 表单生成的"选填"功能不生效
- 自动生成的curd接口,update接口考虑不足,仅支持非空字段的修改,即不支持对某个字段置空。
- 可选的替换方案为gfast脚手架基于golang的后台管理脚手架gofast的使用步骤,是基于goframe和ruoyi框架开发。