electricity_bill_calc_service/response/user_response.go
2022-08-13 05:53:09 +08:00

30 lines
631 B
Go

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