diff --git a/http_result.go b/http_result.go index f72bb00..ed233ce 100644 --- a/http_result.go +++ b/http_result.go @@ -42,16 +42,9 @@ func (h *HttpResult) Success(message string, data interface{}) http.Response { if message == "" { message = facades.Config().GetString("http_result.Message") } - - res := []string{} - //如果data就是一个interface{}类型,则直接返回 - if _, ok := data.(interface{}); ok { - return h.Context.Response().Success().Json(http.Json{ - "message": message, - "data": res, - }) - } //查询的结果有可能存在data为nil的情况,判断如果是nil则,给定一个[]string{}类型的数据,避免前端页面报错 + //或者判断data的slice类型的长度为0 + res := []string{} if data == nil { return h.Context.Response().Success().Json(http.Json{ "message": message, diff --git a/paginator.go b/paginator.go index 05f86fd..59e9a5e 100644 --- a/paginator.go +++ b/paginator.go @@ -55,6 +55,7 @@ func (h *HttpResult) SearchByIncludes(column string, values []any) *HttpResult { } // SearchByParams +// example SearchByParams(map[string]{}{"name":"user"}, map[string]interface{}{"state",1}, []string{"age"}...) // ?name=xxx&pageSize=1¤tPage=1&sort=xxx&order=xxx func (h *HttpResult) SearchByParams(params map[string]string, conditionMap map[string]interface{}, excepts ...string) *HttpResult { for _, except := range excepts {