Files
hr_data_analyzer/controllers/response.go
T
2026-04-28 19:38:02 +08:00

18 lines
474 B
Go

package controllers
import "github.com/gin-gonic/gin"
type APIResponse struct {
Data interface{} `json:"data"`
Msg string `json:"msg"`
Code int `json:"code"`
}
func writeSuccess(c *gin.Context, httpStatus int, msg string, data interface{}) {
c.JSON(httpStatus, APIResponse{Data: data, Msg: msg, Code: httpStatus})
}
func writeError(c *gin.Context, httpStatus int, msg string) {
c.JSON(httpStatus, APIResponse{Data: nil, Msg: msg, Code: httpStatus})
}