| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 | 
							- package app
 
- import (
 
- 	"tmr-watch/pkg/e"
 
- 	"github.com/gin-gonic/gin"
 
- )
 
- type Gin struct {
 
- 	C *gin.Context
 
- }
 
- func (g *Gin) Response(httpCode, errCode int, data interface{}) {
 
- 	g.C.JSON(httpCode, gin.H{
 
- 		"code": httpCode,
 
- 		"msg":  e.GetMsg(errCode),
 
- 		"data": data,
 
- 	})
 
- 	return
 
- }
 
- func (g *Gin) ResponseEq(httpCode, errCode int, errorNo int, data interface{}) {
 
- 	g.C.JSON(httpCode, gin.H{
 
- 		"code":    httpCode,
 
- 		"message": e.GetMsg(errCode),
 
- 		"results": data,
 
- 		"errorNo": errorNo,
 
- 		"success": 1,
 
- 	})
 
- 	return
 
- }
 
- func (g *Gin) Get(key string) string {
 
- 	if str, ok := g.C.Get(key); !ok {
 
- 		return ""
 
- 	} else {
 
- 		switch str.(type) {
 
- 		case string:
 
- 			return str.(string)
 
- 		}
 
- 	}
 
- 	return ""
 
- }
 
 
  |