跳过无数据
This commit is contained in:
@@ -508,6 +508,10 @@ func NewSchema(config Config) (graphql.Schema, error) {
|
|||||||
item = append(item, int(id))
|
item = append(item, int(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(item) == 0 {
|
||||||
|
return map[string]interface{}{"list": []Image{}, "total": 0}, nil
|
||||||
|
}
|
||||||
|
|
||||||
query = query.Where(goqu.Ex{"web_images.id": goqu.Op{"in": item}}).Select("web_images.id", goqu.L(
|
query = query.Where(goqu.Ex{"web_images.id": goqu.Op{"in": item}}).Select("web_images.id", goqu.L(
|
||||||
fmt.Sprintf("ROW_NUMBER() OVER(ORDER BY FIELD(%s, %s))", "web_images.id", regexp.MustCompile(`[\[\]]`).ReplaceAllString(strings.Join(strings.Fields(fmt.Sprint(item)), ", "), "")),
|
fmt.Sprintf("ROW_NUMBER() OVER(ORDER BY FIELD(%s, %s))", "web_images.id", regexp.MustCompile(`[\[\]]`).ReplaceAllString(strings.Join(strings.Fields(fmt.Sprint(item)), ", "), "")),
|
||||||
).As("row_num"))
|
).As("row_num"))
|
||||||
|
Reference in New Issue
Block a user