Files
lunar-mini/server
gouki 48255faa5b feat: 实现后端业务逻辑和Inertia.js管理后台
- 实现数据库连接和自动迁移
- 实现用户服务(登录、资料、JWT认证)
- 实现许愿服务(创建、列表、机器人许愿)
- 实现订单服务(创建、支付、状态管理)
- 实现JWT认证中间件
- 实现管理后台API(仪表盘、用户、订单、许愿、设置)
- 创建Inertia.js前端页面(Vue3 + Tailwind CSS)
- 修复Go模块依赖问题
2026-08-06 13:11:59 +00:00
..

祈福小助手后端服务

基于 Go + Gin + Inertia.js 的后端服务。

功能模块

  • 用户模块 — 微信登录、资料修改、授权管理
  • 支付模块 — 微信支付集成、订单管理
  • 许愿树 — 许愿发布、付费许愿、机器人自动许愿
  • 管理后台 — 基于 Inertia.js 的前后端分离管理界面

技术栈

  • 后端: Go 1.22 + Gin + GORM
  • 前端: Inertia.js + React/Vue(待选择)
  • 数据库: MySQL
  • 缓存: Redis

快速开始

开发环境

# 安装依赖
go mod download

# 启动开发服务器
./scripts/dev.sh

生产构建

# 构建
./scripts/build.sh

# 运行
./bin/lunar-server

项目结构

server/
├── cmd/              # 入口文件
│   └── main.go
├── internal/         # 内部包
│   ├── config/       # 配置
│   ├── handler/      # 处理器
│   ├── middleware/   # 中间件
│   ├── model/        # 数据模型
│   └── service/      # 业务逻辑
├── web/              # Inertia.js 前端
│   ├── src/
│   └── public/
├── migrations/       # 数据库迁移
├── scripts/          # 脚本
└── go.mod

API 接口

用户接口

  • POST /api/user/login — 用户登录
  • POST /api/user/logout — 用户登出
  • GET /api/user/profile — 获取用户资料
  • PUT /api/user/profile — 更新用户资料
  • POST /api/user/auth — 微信授权

支付接口

  • POST /api/pay/create — 创建订单
  • POST /api/pay/notify — 支付回调
  • GET /api/pay/status/:orderId — 查询支付状态

订单接口

  • GET /api/order/list — 订单列表
  • GET /api/order/detail/:id — 订单详情
  • POST /api/order/cancel/:id — 取消订单

许愿接口

  • GET /api/wish/tree — 获取许愿树
  • POST /api/wish/create — 创建许愿
  • GET /api/wish/list — 许愿列表
  • DELETE /api/wish/:id — 删除许愿

环境变量

参考 .env.local 文件配置。

数据库

执行 migrations/001_init.sql 初始化数据库。