Categorygithub.com/haimait/go-mindoc
repositorypackage
0.0.0-20240804120327-b651be72993f
Repository: https://github.com/haimait/go-mindoc.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

iot-platform

基于 go-zero(微服务) 实现的物联网平台

B站视频地址:https://www.bilibili.com/video/BV13G4y1R71m

技术栈

  • 后端:go-zero、gorm
  • 前端:vue
  • 硬件:arduino、esp8266

go-zero官网

https://go-zero.dev/cn/docs/introduction/

安装

  1. 搭建 Golang 环境
  2. 安装 goctl
go get -u github.com/zeromicro/go-zero/tools/goctl@latest 
  1. 下载安装 arduino
  2. 搭建 ETCD 环境
# 参考如下,使用Docker安装ETCD
docker run -d --name Etcd-server \
    --network app-tier \
    --publish 2379:2379 \
    --publish 2380:2380 \
    --env ALLOW_NONE_AUTHENTICATION=yes \
    --env ETCD_ADVERTISE_CLIENT_URLS=http://etcd-server:2379 \
    bitnami/etcd:latest
  1. 搭建 EMQX 环境,参考地址:https://www.emqx.io/downloads
docker run -d --name emqx -p 1883:1883 -p 8083:8083 -p 8084:8084 -p 8883:8883 -p 18083:18083 emqx/emqx:5.0.12 

命令

  • 创建API服务
goctl api new 服务名称
# 1. 创建 user 服务
goctl api new user
# 2. 创建 admin 服务
goctl api new admin
  • 生成服务代码
goctl api go -api 服务名称.api -dir ../ -style go_zero
# 1. 生成 core api 服务代码
goctl api go -api core.api -dir ../ -style go_zero

# 2. 生成 user rpc 服务代码

## 多服务 如果需要 单服务,删除 --multiple
goctl rpc protoc core.proto --go_out=./types --go-grpc_out=./types --zrpc_out=../ --style go_zero --multiple

  • 启动服务
go run 服务名称.go -f 配置文件地址
# 1. 启动 user api 服务
go run user.go -f etc/user-api.yaml
# 2. 启动 admin api 服务
go run admin.go -f etc/admin-api.yaml
# 3. 启动 user rpc 服务
go run user.go -f etc/user.yaml
# 4. 启动 device rpc 服务
go run device.go -f etc/device.yaml

#grpc调适

#grpc调适
grpcui -bind localhost -plaintext 127.0.0.1:8080

适用场景

共享单车、共享充电宝、外卖柜

功能模块

  • 用户模块
    • 登录
  • 后台管理模块
    • 设备管理
      • 设备列表
      • 创建、修改、删除设备
    • 产品管理
      • 产品列表
      • 创建、修改、删除产品
  • 开放平台模块
  • 设备服务模块
    • 设备状态管理
    • 发送消息