做完了一部分,备份一下,防止以外删除

This commit is contained in:
2025-11-11 15:16:38 +08:00
parent 9600e5b6e0
commit e98dd4d725
39 changed files with 2423 additions and 183 deletions

33
internal/handler/user.go Normal file
View File

@@ -0,0 +1,33 @@
package handler
import (
"github.com/gofiber/fiber/v2"
"github.com/break/junhong_cmp_fiber/pkg/constants"
"github.com/break/junhong_cmp_fiber/pkg/response"
)
// GetUsers 获取用户列表(示例受保护端点)
func GetUsers(c *fiber.Ctx) error {
// 从上下文获取用户 ID由 auth 中间件设置)
userID := c.Locals(constants.ContextKeyUserID)
// 示例数据
users := []fiber.Map{
{
"id": "user-123",
"name": "张三",
"email": "zhangsan@example.com",
},
{
"id": "user-456",
"name": "李四",
"email": "lisi@example.com",
},
}
return response.SuccessWithMessage(c, fiber.Map{
"users": users,
"authenticated_as": userID,
}, "success")
}