package model

import "net/http"

type Response struct {
	StatusCode int         `json:"-"`
	Code       int         `json:"code"`
	Message    string      `json:"message"`
	Data       interface{} `json:"data"`
}

var CommonResp map[string]*Response

const (
	OK         = "ok"
	PARAMERROR = "paramerror"
	INNERERROR = "innnererror"
	TIMEOUT    = "timeout"
	AUTHERROR  = "autherror"
	NOTVALID   = "notvalid"
)

func init() {
	CommonResp = make(map[string]*Response)
	CommonResp[OK] = &Response{StatusCode: http.StatusOK, Code: 200, Message: "ok"}
	CommonResp[PARAMERROR] = &Response{StatusCode: http.StatusBadRequest, Code: 1001, Message: "参数错误"}
	CommonResp[AUTHERROR] = &Response{StatusCode: http.StatusUnauthorized, Code: 1002, Message: "认证失败"}
	CommonResp[INNERERROR] = &Response{StatusCode: http.StatusInternalServerError, Code: 2001, Message: "内部错误"}
	CommonResp[TIMEOUT] = &Response{StatusCode: http.StatusInternalServerError, Code: 2002, Message: "内部超时"}
	CommonResp[NOTVALID] = &Response{StatusCode: http.StatusForbidden, Code: 3001, Message: "禁用"}
}
