12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- package dto
- import (
- "github.com/gin-gonic/gin"
- "log"
- "net/http"
- "runtime/debug"
- )
- func BadRequest(c *gin.Context, err error) {
- log.Printf("err: %+v", err)
- debug.PrintStack()
- c.JSON(http.StatusBadRequest, Response{
- Status: 0,
- Message: err.Error(),
- })
- }
- func Error(c *gin.Context, err error) {
- log.Printf("err: %+v", err)
- debug.PrintStack()
- c.JSON(http.StatusInternalServerError, Response{
- Status: 0,
- Message: err.Error(),
- })
- }
- func NewOkResponse() Response {
- return Response{Status: 1, Message: "ok"}
- }
- type Response struct {
- Status int `json:"status"`
- Message string `json:"message"`
- }
- type RegisterResponse struct {
- Response
- Data RegisterResult `json:"data"`
- }
- type RegisterResult struct {
- Success bool `json:"success"`
- }
- type ListResponse struct {
- Response
- Data []*Node `json:"data"`
- }
- type DetailResponse struct {
- Response
- Data Node `json:"data"`
- }
- type Node struct {
- CountryCode string `json:"countryCode"`
- CountryName string `json:"countryName"`
- CountryLabel string `json:"countryLabel"`
- Ip string `json:"ip"`
- Icon string `json:"icon"`
- }
- type ConfigResponse struct {
- Response
- Data ConfigResult `json:"data"`
- }
- type ConfigResult struct {
- FreeTrialDuration uint64 `json:"freeTrialDuration"`
- Timestamp int64 `json:"timestamp"`
- Node *Node `json:"node"`
- }
|