You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.4 KiB
74 lines
1.4 KiB
2 months ago
|
package backend
|
||
|
|
||
|
import (
|
||
|
v1 "matchmaking-system/api/matchmaking/v1/backend"
|
||
|
"matchmaking-system/internal/pkg/flags"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
// VerificationRequest
|
||
|
//
|
||
|
// @Description:
|
||
|
// @param req
|
||
|
// @return bool
|
||
|
func VerificationRequest(req *v1.BotUsersNullRequest) bool {
|
||
|
|
||
|
return true
|
||
|
}
|
||
|
|
||
|
// BotUsersReply
|
||
|
//
|
||
|
// @Description:
|
||
|
// @param check
|
||
|
// @param err
|
||
|
// @return *v1.BotUsersReply
|
||
|
func BotUsersReply(check bool, err string) *v1.BotUsersReply {
|
||
|
code, replyStr := ResultCodeSrr(check, err)
|
||
|
|
||
|
return &v1.BotUsersReply{
|
||
|
Code: code,
|
||
|
Data: "",
|
||
|
Message: replyStr,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ResultCodeSrr
|
||
|
//
|
||
|
// @Description:
|
||
|
// @param check
|
||
|
// @param err
|
||
|
// @return int64
|
||
|
// @return string
|
||
|
func ResultCodeSrr(check bool, err string) (int64, string) {
|
||
|
var code int
|
||
|
var replyStr string
|
||
|
if !check {
|
||
|
code, replyStr = ResultTokenError(err)
|
||
|
} else {
|
||
|
code = http.StatusOK
|
||
|
replyStr = "successful"
|
||
|
}
|
||
|
return int64(code), replyStr
|
||
|
}
|
||
|
|
||
|
// ResultTokenError
|
||
|
//
|
||
|
// @Description:
|
||
|
// @param err
|
||
|
// @return int
|
||
|
// @return string
|
||
|
func ResultTokenError(err string) (int, string) {
|
||
|
switch err {
|
||
|
case flags.ErrTokenError.Error():
|
||
|
return http.StatusUnauthorized, flags.ErrTokenMessage.Error()
|
||
|
case flags.ErrTokenMessage.Error():
|
||
|
return http.StatusUnauthorized, err
|
||
|
case flags.ErrIsReal.Error():
|
||
|
return http.StatusMethodNotAllowed, err
|
||
|
case flags.ErrIsParameter.Error():
|
||
|
return http.StatusBadRequest, err
|
||
|
default:
|
||
|
return http.StatusBadRequest, err
|
||
|
}
|
||
|
}
|