electricity_bill_calc_service/response/user_response.go

32 lines
703 B
Go

package response
import (
"electricity_bill_calc/model"
"net/http"
"github.com/gofiber/fiber/v2"
)
type LoginResponse struct {
BaseResponse
NeedReset bool `json:"needReset"`
Session *model.Session `json:"session"`
}
func (r Result) LoginSuccess(session *model.Session) error {
res := &LoginResponse{}
res.Code = http.StatusOK
res.Message = "用户已成功登录。"
res.NeedReset = false
res.Session = session
return r.Ctx.Status(fiber.StatusOK).JSON(res)
}
func (r Result) LoginNeedReset() error {
res := &LoginResponse{}
res.Code = http.StatusUnauthorized
res.Message = "用户凭据已失效。"
res.NeedReset = true
return r.Ctx.Status(fiber.StatusOK).JSON(res)
}