基于 MySql + Gorm + Gin HTTP服务完成的第三届字节跳动青训营--极简抖音后端项目
-
基于《接口文档在线分享- Apifox》提供的接口进行开发,使用《极简抖音App使用说明 - 青训营版 》提供的APK进行Demo测试, 功能完整实现 ,前端接口匹配良好。
-
代码结构采用 (HTTP API 层 + RPC Service 层+Dao 层) 项目 结构清晰 ,代码 符合规范
-
使用 JWT 进行用户token的校验
-
使用 Gorm 对 MySQL 进行 ORM 操作;
-
数据库表建立了索引和外键约束,对于具有关联性的操作一旦出错立刻回滚,保证数据一致性和安全性
- 视频:视频推送、视频投稿、发布列表
- 用户:用户注册、用户登录、用户信息
- 点赞:点赞操作、点赞列表
- 评论:评论操作、评论列表
- 关注:关注操作、关注列表、粉丝列表
git clone https://github.com/haksuai22/douyin.git
go mod tidy
./main.go
eg:
filetree
├─douyin(公共基础库,封装一些通用的逻辑)
│ ├─redis_cache(缓存)
│ ├─config(配置文件)
│ ├─controller(于handlers层)
│ ├─middlewares(中间件)
│ ├─models(实体类)
│ └─router(接口path访问路口)
│ └─service(操作数据库)
│ └─static(存储视频图片静态目录)
│ └─util(工具类)
│ └─image(图床)
本项目采用 MVC 分层设计模型分离模型层、视图层和控制层,从而降低代码的耦合度,提高项目的可维护性。
使用 Gin 作为 Web 框架,Redis 作为缓存框架,MySQL 作为持久层框架。
┌─────────┐ ┌─────────┐ ┌─────────┐
──req──► ├──────► ├──────► │
│ Gin │ │ Redis │ │ MySQL │
◄─resp─┤ ◄──────┤ ◄──────┤ │
请阅读 CONTRIBUTING.md 查阅为该项目做出贡献的开发者。
贡献使开源社区成为一个学习、激励和创造的绝佳场所。你所作的任何贡献都是非常感谢的。
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
该项目使用Git进行版本管理。您可以在 repository 参看当前可用版本。
博客:Hakusai
该项目签署了MIT 授权许可,详情请参阅 LICENSE.txt