feat(app): update
This commit is contained in:
@ -35,24 +35,24 @@ func WrapApi(f Fn) gin.HandlerFunc {
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg,omitempty"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
Cause error `json:"-"`
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg,omitempty"`
|
||||
Data any `json:"data,omitempty"`
|
||||
Cause error `json:"-"`
|
||||
}
|
||||
|
||||
type PageData struct {
|
||||
Total int64 `json:"total"`
|
||||
CountPage int64 `json:"count_page"`
|
||||
HasNext bool `json:"has_next"`
|
||||
List interface{} `json:"list"`
|
||||
Total int64 `json:"total"`
|
||||
CountPage int64 `json:"count_page"`
|
||||
HasNext bool `json:"has_next"`
|
||||
List any `json:"list"`
|
||||
}
|
||||
|
||||
func (t Response) Success() bool {
|
||||
return t.Code == CodeSuccess
|
||||
}
|
||||
|
||||
func Success(data interface{}) Response {
|
||||
func Success(data any) Response {
|
||||
return Response{
|
||||
Code: CodeSuccess,
|
||||
Msg: "",
|
||||
@ -67,7 +67,7 @@ func Empty() Response {
|
||||
}
|
||||
}
|
||||
|
||||
func Page(pageable req.Page, count int64, data interface{}) Response {
|
||||
func Page(pageable req.Page, count int64, data any) Response {
|
||||
cnt := (count + pageable.Size - 1) / pageable.Size
|
||||
return Success(PageData{
|
||||
Total: count,
|
||||
@ -128,7 +128,7 @@ func AuthFailed(msg string) Response {
|
||||
}
|
||||
}
|
||||
|
||||
func FailedF(msg string, args ...interface{}) Response {
|
||||
func FailedF(msg string, args ...any) Response {
|
||||
return Response{
|
||||
Code: CodeFailed,
|
||||
Msg: fmt.Sprintf(msg, args...),
|
||||
|
||||
Reference in New Issue
Block a user