cockpit-source/backend/internal/domain/response.go
2026-04-02 14:12:43 +08:00

17 lines
334 B
Go

package domain
type Response[T any] struct {
Code int `json:"code"`
Message string `json:"message"`
Data T `json:"data,omitempty"`
}
func OK[T any](data T) Response[T] {
return Response[T]{Code: 0, Message: "ok", Data: data}
}
func Fail(msg string) Response[any] {
return Response[any]{Code: 1, Message: msg}
}