package controller import ( "electricity_bill_calc/exceptions" "electricity_bill_calc/model" "github.com/gofiber/fiber/v2" ) func _retreiveSession(c *fiber.Ctx) (*model.Session, error) { session := c.Locals("session") if session == nil { return nil, exceptions.NewUnauthorizedError("用户会话不存在") } userSession, ok := session.(*model.Session) if !ok { return nil, exceptions.NewUnauthorizedError("用户会话格式不正确,需要重新登录") } return userSession, nil }