Files
xk-of-api/.cursor/rules/20-backend-goframe.mdc
2026-07-18 05:58:41 +08:00

18 lines
1.2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
description: 萧康云医后端 GoFrame GF 分层开发规则
globs: **/*.go,api/**/*,internal/**/*,manifest/**/*,resource/**/*
alwaysApply: false
---
# 后端规则
- 后端使用 GoFrame GF 框架必须遵循 GF 的项目结构路由注册控制器服务模型配置和错误处理规范
- 分层链路为路由 -> 控制器 -> service 服务层 -> 模型层
- 路由层只负责请求路径HTTP 方法中间件和控制器绑定不编写业务逻辑
- 控制器层负责获取请求信息参数验证用户信息解析调用 service并返回统一响应
- 控制器层不编写核心业务逻辑不直接操作数据库不绕过 service 调用模型
- service 层是业务逻辑层负责业务流程编排权限判断事务控制数据处理和外部服务调用
- 模型层只用于定义表结构表关系字段映射和数据承载不编写业务逻辑
- 数据库访问事务缓存队列第三方接口等能力应按 GF 推荐方式封装并放在合适的服务或基础设施模块中
- 参数校验错误码日志上下文传递和用户身份解析要保持统一规范