Sem descrição

baishaojie a35c9baed2 提交 há 5 meses atrás
comm c2af6927ee project: 框架升级 há 1 ano atrás
conf e0ddbdc1f6 羊场栏舍同步调整 há 5 meses atrás
demo 1e42d30b28 first commit há 1 ano atrás
dist 6a33983a0d 羊场 há 5 meses atrás
dist-tmr-测试-20240613 6a33983a0d 羊场 há 5 meses atrás
docs 1e42d30b28 first commit há 1 ano atrás
html 1e42d30b28 first commit há 1 ano atrás
http a35c9baed2 提交 há 5 meses atrás
mdns 1e42d30b28 first commit há 1 ano atrás
middleware a5b7c8c9cf release: tmr集团1.0版本 há 1 ano atrás
migration f85bc1458a sheep: 去除栏舍关键字牛 há 7 meses atrás
models f85bc1458a sheep: 去除栏舍关键字牛 há 7 meses atrás
module f85bc1458a sheep: 去除栏舍关键字牛 há 7 meses atrás
pkg 6038dc1b52 代码合并 光明ud上传 há 1 ano atrás
scripts 5641426df2 cicd: 增加手动构建镜像流程 há 1 ano atrás
service f85bc1458a sheep: 去除栏舍关键字牛 há 7 meses atrás
test 1e42d30b28 first commit há 1 ano atrás
uploads f85bc1458a sheep: 去除栏舍关键字牛 há 7 meses atrás
.drone-bak.yml 9b6f017c9a drone: update há 7 meses atrás
.gitignore 628b1e1245 tmr: dashboard há 1 ano atrás
11111.sql 6a33983a0d 羊场 há 5 meses atrás
Dockerfile ff764d1307 drone: update há 7 meses atrás
LICENSE 1e42d30b28 first commit há 1 ano atrás
Makefile 5987e91d12 feature: init há 7 meses atrás
README.md b025f6679e group: 空版本 há 1 ano atrás
TMRWatchComm a35c9baed2 提交 há 5 meses atrás
TMRWatchComm.zip a35c9baed2 提交 há 5 meses atrás
dist-tmr-测试-20240613.zip 6a33983a0d 羊场 há 5 meses atrás
go.mod a08d4c2c3c 羊圈 há 7 meses atrás
go.sum a08d4c2c3c 羊圈 há 7 meses atrás
linux64.bat 1e42d30b28 first commit há 1 ano atrás
main.go 9f04883f95 project: cicd 6 há 1 ano atrás
win32.bat ffe724c489 圣牧优化更新 há 10 meses atrás
win64.bat ffe724c489 圣牧优化更新 há 10 meses atrás

README.md

KPTYUN

一个go api 后端例子,包含JWT,RBAC(Casbin),增删改查, 一键生成 Restful API接口(不依赖orm)。

主要说明

  • v1.1.2

  • user
    • username password
  • role
    • name
  • menu
    • name path method

目录结构

  • conf:用于存储配置文件
  • docs: 文档(SQL和API注释)
  • logs: 日志
  • middleware:应用中间件
  • models:应用数据库模型
  • pkg:第三方包
  • routers: 路由逻辑处理
  • service: 逻辑处理
  • test: 单元测试

权限验证说明

利用的casbin库, 将 user role menu 进行自动关联

项目启动时,会自动加载权限. 如有更改,会删除对应的权限,重新加载.

用户关联角色  
角色关联菜单  

权限关系为:
角色(role.name,menu.path,menu.method)  
用户(user.username,role.name)

例如:
test      /api/v1/users       GET
zhuhongbin     test

当zhuhongbin  GET  /api/v1/users 地址的时候,会去检查权限,因为他属于test组,同时组有对应权限,所以本次请求会通过。

用户 admin 有所有的权限,不进行权限匹配

登录接口 /auth  不进行验证

请求

请求和接收 都是 传递 json 格式 数据

例如:
访问 /auth    获取token
{
	"username": "admin",
	"password": "123456"
}

访问  /api/v1/users   
请求头设置  Authorization: Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

How to run

Required

  • Mysql

Ready

Create a go database and import SQL

创建一个库,然后导入sql,创建表!

Conf

You should modify conf/app.ini

[database]
Type = mysql
User = root
Password =
Host = 127.0.0.1:3306
Name = go
TablePrefix = go_

Installation


yum install go -y 


cd $GOPATH/src/github.com/kptyun/go-admin
go build main.go
go run  main.go 

## 热编译,开发时使用

go get github.com/silenceper/gowatch

gowatch   

Run

Project information and existing API

[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)

Listening port is 8000

默认 账户 密码 都为  123456

  • 不用orm依赖,直接输入表名字就可以 增删改查

    
    get   http://127.0.0.1:8000/api/restful/go_user
    get   http://127.0.0.1:8000/api/restful/go_user/1
    post   http://127.0.0.1:8000/api/restful/go_user
    数据格式  json  支持批量
    [{
    	"username":"hequan",
    	"password":"hequan1",
    	"created_on": "0",
    	"modified_on":"0",
    	"deleted_on":"0"
    }]
    put  http://127.0.0.1:8000/api/restful/go_user/2
    数据格式  json
    {
    	"password":"654321"
    }
    delete http://127.0.0.1:8000/api/restful/go_user/2
    

API 注释

http://127.0.0.1:8000/swagger/index.html

Features

- RESTful API
- Gorm
- logging
- Jwt-go
- Swagger
- Gin
- Graceful restart or stop (fvbock/endless)
- App configurable
- 一键生成 Restful API接口

其他

##更新注释
swag init

TODO 列表

  • 撒料时间统计分析接口,因数据量太多,目前limit 100条数据