15
GitHub - snowlyg/IrisAdminApi: iris 框架的后台api项目
source link: https://github.com/snowlyg/IrisAdminApi
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
IrisAdminApi
项目介绍
iris-go
框架后台接口项目gorm
数据库模块jwt
的单点登陆认证方式cors
跨域认证- 数据支持
mysql
,sqlite3
配置;sqlite3
需要下载gcc
, 并且在/temp
目录下新建文件gorm.db
,tgorm.db
。 gcc 下载地址 - 使用了 https://github.com/snowlyg/gotransformer 转换数据,返回数据格式化,excel 导入数据转换,xml 文件生产数据转换等
- 增加了
excel
文件接口导入实例 - 前端采用了
element-ui
框架,如果需要修改前端代码请移步 https://github.com/snowlyg/IrisApiVueAdmin - 使用
casbin
做权限控制,config/rbac_model.conf
为相关配置。系统会根据路由名称生成对应路由权限,并配置到管理员角色。 - 增加系统日志记录
/logs
文件夹下,自定义记录,控制器内ctx.Application().Logger().Infof("%s 登录系统",aul.Username)
注意:
- 更新代码后,如果启动报错,请尝试手动删所有数据表后重启。
- 默认数据库设置为
DirverType = "Sqlite"
,使用 mysql 需要修改为DirverType = "Mysql"
,在config/conf.tml
文件中 permissions.xlsx
权限导入测试模板文件,仅供测试使用; 权限会自动生成,无需另外导入。
更新日志
更新日志
问题总结
所用依赖包
项目初始化
拉取项目
git clone https://github.com/snowlyg/IrisAdminApi.git
// github 克隆太慢可以用 gitee 地址:
git clone https://gitee.com/dtouyu/IrisAdminApi.git
加载依赖管理包 (解决国内下载依赖太慢问题) 使用国内七牛云的 go module 镜像。
参考 https://github.com/goproxy/goproxy.cn。
阿里: https://mirrors.aliyun.com/goproxy/
golang 1.13 可以直接执行:
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
项目配置文件 /config/config.toml
cp config.toml.example config.toml
运行项目
go get github.com/silenceper/gowatch
gowatch //安装 gowatch 后才可以使用
go run main.go // go 命令
单元测试
http test
go test -v //所有测试
go test -run TestUserCreate -v //单个方法
// go get github.com/rakyll/gotest@latest 增加测试输出数据颜色
gotest
接口文档
自动生成文档 (访问过接口就会自动成功) 因为原生的 jquery.min.js 里面的 cdn 是使用国外的,访问很慢。 有条件的可以开个 vpn ,如果没有可以根据下面的方法修改一下,访问就很快了
打开 /resource/apiDoc/index.html 修改里面的
https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
国内的 cdn
https://cdn.bootcss.com/jquery/2.1.3/jquery.min.js
访问文档,从浏览器直接打开 http://localhost:8081/apiDoc
登录项目
//在 config/conf.tml
内配置
项目管理员账号 : username 项目管理员密码 : password
演示地址
Iris-go 学习交流QQ群 :676717248Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK