mirror of
https://gitee.com/dromara/electron-egg.git
synced 2026-05-21 07:48:08 +08:00
36 lines
480 B
Go
36 lines
480 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type Result struct {
|
|
Code int `json:"code"`
|
|
Msg string `json:"msg"`
|
|
Data interface{} `json:"data"`
|
|
}
|
|
|
|
func newResult() *Result {
|
|
return &Result{
|
|
Code: 0,
|
|
Msg: "",
|
|
Data: nil,
|
|
}
|
|
}
|
|
|
|
func GetName(c *gin.Context) {
|
|
ret := newResult()
|
|
defer c.JSON(http.StatusOK, ret)
|
|
|
|
ret.Data = "gsx"
|
|
}
|
|
|
|
func GetAge(c *gin.Context) {
|
|
ret := newResult()
|
|
defer c.JSON(http.StatusOK, ret)
|
|
|
|
ret.Data = 12
|
|
}
|