11-22 gowebmini项目
# go_web_mini_ui
克隆到本地之后npm i下载依赖
npm run dev运行项目
然后去新建数据库,再运行后端项目,就会初始化数据库数据了
登录账号密码是admin 123456
# go_web_mini
go mod tidy自动下载项目依赖
然后添加启动配置类,就可以运行后端项目了
# 项目技术栈
- gin
- gorm
# 项目结构
├─common # casbin mysql zap validator 等公共资源
├─config # viper读取配置
├─controller # controller层,响应路由请求的方法
├─dto # 返回给前端的数据结构
├─middleware # 中间件
├─model # 结构体模型
├─repository # 数据库操作
├─response # 常用返回封装,如Success、Fail
├─routes # 所有路由
├─util # 工具方法
└─vo # 接收前端请求的数据结构
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
# 属性封装

# 校友会统计功能

# 会员数量统计
- model要获取会员的数量,其实就是统计表id总数
- gorm绑定数据表
- 因为没有service层,controller实现接口
- 返回数据
# 学历分布统计
- model根据学历进行分组来统计数量
- gorm绑定数据表
- 因为没有service层,controller实现接口
- 返回数据
# 地域分布统计
- model根据地域进行分组来统计数量
- gorm绑定数据表
- 因为没有service层,controller实现接口
- 返回数据
# 行业分布统计
- model根据行业进行分组来统计数量
- gorm绑定数据表
- 因为没有service层,controller实现接口
- 返回数据
# gorm
安装
go get -u gorm.io/gorm
go get -u gorm.io/driver/sqlite
1
2
2
# 原生写法
library
编辑 (opens new window)