123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- 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 []ListResult `json:"data"`
- }
- type ListResult struct {
- CountryCode string `json:"countryCode"`
- Nodes []Node `json:"nodes"`
- }
- type Node struct {
- Ip string `json:"ip"`
- }
- type DetailResponse struct {
- Response
- Data Node `json:"data"`
- }
|