开发环境搭建
开发环境搭建
环境准备
- Go 1.25+
- Node.js 22+、pnpm(前端开发)
- MySQL / PostgreSQL / SQLite
- Redis(可选,开发可用内存缓存)
配置
git clone <repository-url>
cd mliev-iam
go mod download
cp config.yaml.example config.yaml开发推荐使用 SQLite + 内存缓存:
server:
mode: debug
database:
driver: sqlite
filepath: "./config/mliev_iam.db"
cache:
driver: memory启动开发模式
make dev # 前端 watch + 后端 debug
make dev-go # 仅后端 debug
go run . # 直接运行项目结构
app/
├── controller/ # HTTP 请求处理
├── service/ # 业务逻辑
├── dao/ # 数据库查询(GORM)
├── model/ # 数据模型
├── dto/ # 请求/响应结构体
└── middleware/ # 认证、权限、CORS
config/autoload/ # 配置源、路由、中间件
internal/ # 接口定义、Helper 单例、基础设施
admin-web/apps/ # 前端应用(web-antd, web-oidc, web-install)开发约定
- Handler 签名:
func(c *gin.Context, helper interfaces.HelperInterface) - 路由注册在
config/autoload/router.go,使用deps.WrapHandler()包装 - 所有模型使用 GORM 软删除
- 数据库迁移启动时自动执行
配置热重载
kill -HUP $(pgrep mliev-iam)
# 或
curl -X GET http://localhost:8080/api/system/reload