{"id":14987660,"url":"https://github.com/phyuany/gin-demo","last_synced_at":"2025-04-07T12:08:15.549Z","repository":{"id":53730313,"uuid":"256093185","full_name":"phyuany/gin-demo","owner":"phyuany","description":"基于Gin+GORM框架的Restful API接口开发","archived":false,"fork":false,"pushed_at":"2022-12-21T07:02:50.000Z","size":222,"stargazers_count":256,"open_issues_count":0,"forks_count":91,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T10:10:01.643Z","etag":null,"topics":["api","gin","go","golang","gorm","jwt","restful","vue"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phyuany.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2020-04-16T02:52:01.000Z","updated_at":"2025-03-24T15:45:10.000Z","dependencies_parsed_at":"2023-01-30T03:01:00.486Z","dependency_job_id":null,"html_url":"https://github.com/phyuany/gin-demo","commit_stats":null,"previous_names":["zigfan/gin-demo","ucodingfan/gin-demo","phyxyz/gin-demo","phyuany/gin-demo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phyuany%2Fgin-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phyuany%2Fgin-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phyuany%2Fgin-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phyuany%2Fgin-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phyuany","download_url":"https://codeload.github.com/phyuany/gin-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648977,"owners_count":20972945,"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":["api","gin","go","golang","gorm","jwt","restful","vue"],"created_at":"2024-09-24T14:15:07.889Z","updated_at":"2025-04-07T12:08:15.522Z","avatar_url":"https://github.com/phyuany.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gin-demo\n\n## 一、项目内容\n\n基于gin框架的demo项目,本项目基于B站视频Go语言 Gin+Vue 前后端分离实战 - OceanLearn\n[https://www.bilibili.com/video/BV1CE411H7bQ?t=7](https://www.bilibili.com/video/BV1CE411H7bQ?t=7)\n\n**master**分支为后端go代码,**vue**分支为前端vue代码\n\n## 二、怎样运行该项目\n\n### 2.1 运行后端程序\n\n\u003e 先确保你电脑上正确安装了 golang 环境\n\n从master分支拉取后端golang代码\n\n```bash\n# 拉取代码\ngit clone -b main https://github.com/kotlindev/gin-demo.git backend\n# 进入项目目录\ncd  backend\n# 安装项目依赖\ngo get\n```\n\n如果没有mysql数据库，可以使用docker启动一个mysql数据库，项目中提供脚本快速启动，脚本在`db`目录下，相关操作如下\n\n```bash\n# 进入db目录\ncd db\n# 启动mysql数据库\n./startup.sh\n# 销毁数据库\n./shutdown.sh\n```\n\n启动数据库后，在浏览器中访问`http://localhost:8080`，进入数据库管理页面。默认两个账号如下\n\n| 账号       | 密码       | 级别    |\n|----------|----------|-------|\n| root     | root     | 超级管理员 |\n| gin_demo | gin_demo | 普通用户  |\n\n打开 `config/application.yaml` 文件，修改数据库链接配置，修改项目运行端口，确保端口不被占用，参考如下\n\n```yaml\nserver:\n  port: 8081\ndatasource:\n  driverName: mysql\n  host: 127.0.0.1\n  port: 3306\n  database: gin_demo\n  username: gin_demo\n  password: gin_demo\n  charset: utf8mb4\n  loc: Asia/Shanghai\n```\n\n启动项目\n\n```bash\ngo run routes.go main.go\n```\n\n如果看到命令行终端输出以下路由信息，代表项目运行正常。如果不正常，检查一下数据库地址还有账号密码是否正确，同时确保运行的端口没有被占用\n\n```bash\n[GIN-debug] POST   /api/auth/register        --\u003e jkdev.cn/api/controller.Register (5 handlers)\n[GIN-debug] POST   /api/auth/login           --\u003e jkdev.cn/api/controller.Login (5 handlers)\n[GIN-debug] GET    /api/auth/info            --\u003e jkdev.cn/api/controller.Info (6 handlers)\n[GIN-debug] POST   /categories               --\u003e jkdev.cn/api/controller.ICategoryController.Create-fm (5 handlers)\n[GIN-debug] PUT    /categories/:id           --\u003e jkdev.cn/api/controller.ICategoryController.Update-fm (5 handlers)\n[GIN-debug] GET    /categories/:id           --\u003e jkdev.cn/api/controller.ICategoryController.Show-fm (5 handlers)\n[GIN-debug] DELETE /categories/:id           --\u003e jkdev.cn/api/controller.ICategoryController.Delete-fm (5 handlers)\n[GIN-debug] POST   /posts                    --\u003e jkdev.cn/api/controller.IPostController.Create-fm (6 handlers)\n[GIN-debug] PUT    /posts/:id                --\u003e jkdev.cn/api/controller.IPostController.Update-fm (6 handlers)\n[GIN-debug] GET    /posts/:id                --\u003e jkdev.cn/api/controller.IPostController.Show-fm (6 handlers)\n[GIN-debug] DELETE /posts/:id                --\u003e jkdev.cn/api/controller.IPostController.Delete-fm (6 handlers)\n[GIN-debug] POST   /posts/page/list          --\u003e jkdev.cn/api/controller.IPostController.PageList-fm (6 handlers)\n[GIN-debug] Listening and serving HTTP on :8081\n```\n\n### 2.2 运行前端程序\n\n\u003e 先确保你电脑上正确安装了 npm 环境，并安装了 vue、yarn\n\n从vue分支拉取前端vue代码\n\n```bash\n# 拉取代码\ngit clone -b vue https://github.com/kotlindev/gin-demo.git vue\n# 进入项目目录\ncd  vue\n# 安装项目依赖\nyarn install\n```\n\n根据1中的 后端代码的运行端口，修改 `.env.development.local` 和 `.env.development` 两个配置文件，修改配置如下为\n\n```bash\nVUE_APP_BASE_URL = http://localhost:8081/api/\n```\n\n在运行项目\n\n```bash\nyarn serve\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphyuany%2Fgin-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphyuany%2Fgin-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphyuany%2Fgin-demo/lists"}