{"id":13575240,"url":"https://github.com/piupuer/gin-web","last_synced_at":"2025-04-04T13:07:30.886Z","repository":{"id":37351957,"uuid":"263559033","full_name":"piupuer/gin-web","owner":"piupuer","description":"由gin + gorm + jwt + casbin组合实现的RBAC权限管理脚手架Golang版, 搭建完成即可快速、高效投入业务开发","archived":false,"fork":false,"pushed_at":"2023-05-05T02:34:44.000Z","size":3439,"stargazers_count":728,"open_issues_count":4,"forks_count":153,"subscribers_count":17,"default_branch":"dev","last_synced_at":"2025-03-28T12:03:52.356Z","etag":null,"topics":["casbin","gin","gin-admin","go","go-admin","golang","idempotence","jwt","message-center","middleware","rbac","restful","transaction","validator","viper","vue","websocket","workflow"],"latest_commit_sha":null,"homepage":"https://piupuer.github.io/gin-web-slate","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/piupuer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-05-13T07:38:35.000Z","updated_at":"2025-03-26T14:45:06.000Z","dependencies_parsed_at":"2024-01-13T16:22:28.457Z","dependency_job_id":"ea4124a2-9ca1-42be-938d-f2786134081a","html_url":"https://github.com/piupuer/gin-web","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piupuer%2Fgin-web","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piupuer%2Fgin-web/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piupuer%2Fgin-web/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piupuer%2Fgin-web/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/piupuer","download_url":"https://codeload.github.com/piupuer/gin-web/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247176854,"owners_count":20896543,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["casbin","gin","gin-admin","go","go-admin","golang","idempotence","jwt","message-center","middleware","rbac","restful","transaction","validator","viper","vue","websocket","workflow"],"created_at":"2024-08-01T15:00:59.300Z","updated_at":"2025-04-04T13:07:30.860Z","avatar_url":"https://github.com/piupuer.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eGin Web\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n由gin + gorm + jwt + casbin组合实现的RBAC权限管理脚手架Golang版, 搭建完成即可快速、高效投入业务开发\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://img.shields.io/github/go-mod/go-version/piupuer/gin-web\" alt=\"Go version\"/\u003e\n\u003cimg src=\"https://img.shields.io/badge/Gin-1.6.2-brightgreen\" alt=\"Gin version\"/\u003e\n\u003cimg src=\"https://img.shields.io/badge/Gorm-1.9.12-brightgreen\" alt=\"Gorm version\"/\u003e\n\u003cimg src=\"https://img.shields.io/github/license/piupuer/gin-web\" alt=\"License\"/\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\n## 特性\n\n- `RESTful API` 设计规范\n- `Gin` 一款高效的golang web框架\n- `MySQL` 数据库存储\n- `Jwt` 用户认证, 登入登出一键搞定\n- `Casbin` 基于角色的访问控制模型(RBAC)\n- `Gorm` 数据库ORM管理框架, 可自行扩展多种数据库类型(主分支已支持gorm 2.0)\n- `Validator` 请求参数校验, 版本V9\n- `Log` v1.2.2升级后日志支持两种常见的高性能日志 logrus / zap (移除日志写入本地文件, 强烈建议使用docker日志或其他日志收集工具)\n- `Viper` 配置管理工具, 支持多种配置文件类型\n- `Embed` go 1.16文件嵌入属性, 轻松将静态文件打包到编译后的二进制应用中\n- `DCron` 分布式定时任务，同一task只在某台机器上执行一次(需要配置redis)\n- `GoFunk` 常用工具包, 某些方法无需重复造轮子\n- `FiniteStateMachine` 有限状态机, 常用于审批流程管理(没有使用工作流, 一是go的轮子太少, 二是有限状态机基本可以涵盖常用的审批流程)\n- `Uploader` 大文件分块上传/多文件、文件夹上传Vue组件[vue-uploader](https://github.com/simple-uploader/vue-uploader/)\n- `MessageCenter` 消息中心(websocket长连接保证实时性, 活跃用户上线时新增消息表, 不活跃用户不管, 有效降低数据量)\n- `testing` 测试标准包, 快速进行单元测试\n- `Grafana Loki` 轻量日志收集工具loki, 支持分布式日志收集(需要通过docker运行[gin-web-docker](https://github.com/piupuer/gin-web-docker))\n- `Minio` 轻量对象存储服务(需要通过docker运行[gin-web-docker](https://github.com/piupuer/gin-web-docker))\n- `Swagger` Swagger V2接口文档\n- `Captcha` 密码输错次数过多需输入验证码\n- `Sign` API接口签名(防重放攻击、防数据篡改)\n- `Opentelemetry` 链路追踪, 快速分析接口耗时\n\n## 中间件\n\n- `Rate` 访问速率限制中间件 -- 限制访问流量\n- `Exception` 全局异常处理中间件 -- 使用golang recover特性, 捕获所有异常, 保存到日志, 方便追溯\n- `Transaction` 全局事务处理中间件 -- 每次请求无异常自动提交, 有异常自动回滚事务, 无需每个service单独调用(GET/OPTIONS跳过)\n- `AccessLog` 请求日志中间件 -- 每次请求的路由、IP自动写入日志\n- `Cors 跨域中间件` -- 所有请求均可跨域访问\n- `Jwt` 权限认证中间件 -- 处理登录、登出、无状态token校验\n- `Casbin` 权限访问中间件 -- 基于Cabin RBAC, 对不同角色访问不同API进行校验\n- `Idempotence` 接口幂等性中间件 -- 保证接口不受网络波动影响而重复点击或提交(目前针对create接口加了处理，可根据实际情况更改)\n\n## 默认菜单\n\n- 首页\n- 系统管理\n    - 菜单管理\n    - 角色管理\n    - 用户管理\n    - 接口管理\n    - 数据字典\n    - 操作日志\n    - 消息推送\n    - 机器管理\n- 状态机\n    - 状态机配置\n    - 我的请假条\n    - 待审批列表\n- 上传组件\n    - 上传示例1\n    - 上传示例2(主要是针对ZIP压缩包上传及解压)\n- 测试页面\n    - 测试用例\n\n## 在线演示\n\n### 目前单体架构不满足业务需要, 已转至[Go Cinch](https://go-cinch.github.io/docs/#/README), 本项目不再提供在线演示.\n\n## 快速开始\n\n```\ngit clone https://github.com/piupuer/gin-web\ncd gin-web\n# 强烈建议使用golang官方包管理工具go mod, 无需将代码拷贝到$GOPATH/src目录下\n# 确保go环境变量都配置好, 运行main文件\ngo run main.go\n```\n\n\u003e 启动成功之后, 可在浏览器中输入: [http://127.0.0.1:10000/api/ping](http://127.0.0.1:10000/api/ping), 若不能访问请检查Go环境变量或数据库配置是否正确\n\n## [文档](https://piupuer.github.io/gin-web-slate)\n\n## 项目结构概览\n\n```\n├── api\n│   └── v1 # v1版本接口目录(类似于Java中的controller), 如果有新版本可以继续添加v2/v3\n├── conf # 配置文件目录(包含测试/预发布/生产环境配置参数及casbin模型配置)\n├── docker-conf # docker相关配置文件\n├── initialize # 数据初始化目录\n│   ├── db # 数据库初始化脚本目录, 遵循sql-migrate规范\n│   └── xxx.go # 包含各种需要初始化的全局变量, 如mysql/redis\n├── middleware # 中间件目录\n├── models # 存储层模型定义目录\n├── pkg # 公共模块目录\n│   ├── cache_service # redis缓存服务目录\n│   ├── global # 全局变量目录\n│   ├── redis # redis查询工具目录\n│   ├── request # 请求相关结构体目录\n│   ├── response # 响应相关结构体目录\n│   ├── service # 数据DAO服务目录\n│   ├── utils # 工具包目录\n│   └── wechat # 微信接口目录\n├── router # 路由目录\n├── tests # 本地单元测试配置目录\n├── upload # 上传文件默认目录\n├── Dockerfile # docker镜像构建文件(生产环境)\n├── Dockerfile.stage # docker镜像构建文件(预发布环境)\n├── go.mod # go依赖列表\n├── go.sum # go依赖下载历史\n├── main.go # 程序主入口\n├── README.md # 说明文档\n├── TIPS.md # 个人踩坑记录\n├── TODO.md # 已完成/待完成列表\n```\n\n## 前端\n\n- 项目地址: [gin-web-vue](https://github.com/piupuer/gin-web-vue)\n- 实现方式: Typescript(为什么使用它, JS的弱类型带来的问题实在不想再吐槽, TS提高效率, 反正笔者作为一枚后端用起来很舒服~)\n\n## [注意事项](https://github.com/piupuer/gin-web/blob/master/TIPS.md)\n\n## [TODO](https://github.com/piupuer/gin-web/blob/master/TODO.md)\n\n## 特别感谢\n\n前端:\n\u003cbr/\u003e\n[Element UI](https://github.com/ElemeFE/element): A Vue.js 2.0 UI Toolkit for Web.\n\u003cbr/\u003e\n[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin): a production-ready front-end solution for admin\ninterfaces.\n\u003cbr/\u003e\n[vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template): a production-ready front-end\nsolution for admin interfaces based on vue, typescript and UI Toolkit element-ui.\n\u003cbr/\u003e\n\n后端:\n\u003cbr/\u003e\n[Gin](https://github.com/gin-gonic/gin): a web framework written in Go (Golang).\n\u003cbr/\u003e\n[gin-jwt](https://github.com/appleboy/gin-jwt): a middleware for Gin framework.\n\u003cbr/\u003e\n[casbin](https://github.com/casbin/casbin): An authorization library that supports access control models like ACL, RBAC,\nABAC in Golang.\n\u003cbr/\u003e\n[Gorm](https://github.com/jinzhu/gorm): The fantastic ORM library for Golang.\n\u003cbr/\u003e\n[logrus](https://github.com/sirupsen/logrus): Logrus is a structured logger for Go (golang), completely API compatible with the standard library logger.\n\u003cbr/\u003e\n[zap](https://github.com/uber-go/zap): Blazing fast, structured, leveled logging in Go.\n\u003cbr/\u003e\n[lumberjack](https://github.com/natefinch/lumberjack): lumberjack is a log rolling package for Go.\n\u003cbr/\u003e\n[viper](https://github.com/spf13/viper): Go configuration with fangs.\n\u003cbr/\u003e\n[packr](https://github.com/gobuffalo/packr): The simple and easy way to embed static files into Go binaries.\n\u003cbr/\u003e\n[go-funk](https://github.com/thoas/go-funk): A modern Go utility library which provides helpers (map, find, contains,\nfilter, ...).\n\u003cbr/\u003e\n[limiter](https://github.com/ulule/limiter): Dead simple rate limit middleware for Go.\n\u003cbr/\u003e\n[validator](https://github.com/go-playground/validator): Go Struct and Field validation, including Cross Field, Cross\nStruct, Map, Slice and Array diving.\n\u003cbr/\u003e\n[dcron](https://github.com/libi/dcron): 分布式定时任务库.\n\u003cbr/\u003e\n[fsm](https://github.com/looplab/fsm): FSM is a finite state machine for Go.\n\u003cbr/\u003e\n[sql-migrate](https://github.com/rubenv/sql-migrate): SQL Schema migration tool for Go. Based on gorp and goose.\n\u003cbr/\u003e\n\n日志搜集:\n\u003cbr/\u003e\n[loki](https://github.com/grafana/loki): Loki: like Prometheus, but for logs.\n\n\u003cbr/\u003e\n\n下面几个类似本项目, 学习了大神的一些代码风格:\n\u003cbr/\u003e\n[gin-admin](https://github.com/LyricTian/gin-admin): RBAC scaffolding based on Gin + Gorm/Mongo + Casbin + Wire.\n\u003cbr/\u003e\n[gin-vue-admin](https://github.com/flipped-aurora/gin-vue-admin): Gin-vue-admin is a full-stack (frontend and backend\nseparation) framework designed for management system.\n\u003cbr/\u003e\n[go-admin](https://github.com/wenjianzhang/go-admin): Gin + Vue + Element UI based scaffolding for front and back\nseparation management system.\n\n## 互动交流\n\n### 与作者对话\n\n\u003e 该项目是利用业余时间进行开发的, 开发思路参考了很多优秀的前后端框架, 结合自己的理解和实际需求, 做了改进.\n\u003e 如果觉得项目有不懂的地方或需要改进的地方, 欢迎提issue或pr!\n\n### QQ群：943724601\n\n\u003cimg src=\"https://github.com/piupuer/gin-web-images/blob/master/contact/qq_group.jpeg?raw=true\" width=\"256\" alt=\"QQ群\" /\u003e\n\n\u003e 就不贴打赏二维码了, 不然显得项目很low, 如果您非要请我喝咖啡, 私信我, 哈哈哈~\n\n## MIT License\n\n    Copyright (c) 2021 piupuer\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiupuer%2Fgin-web","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiupuer%2Fgin-web","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiupuer%2Fgin-web/lists"}