debug
This commit is contained in:
@@ -1,11 +1,9 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -460,7 +458,7 @@ func NewSchema(config Config) (graphql.Schema, error) {
|
|||||||
// 筛选条件
|
// 筛选条件
|
||||||
for _, format := range argFormat {
|
for _, format := range argFormat {
|
||||||
if p.Args[format] != nil {
|
if p.Args[format] != nil {
|
||||||
query = query.Where(fmt.Sprintf("%s = ?", format), p.Args[format])
|
query = query.Where(fmt.Sprintf("web_images.%s = ?", format), p.Args[format])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,28 +524,26 @@ func NewSchema(config Config) (graphql.Schema, error) {
|
|||||||
fmt.Println("Interest:", args.Interest)
|
fmt.Println("Interest:", args.Interest)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 数据库中筛选: 关注列表
|
//// 数据库中筛选: 关注列表
|
||||||
if args.Follower != 0 {
|
//if args.Follower != 0 {
|
||||||
// 返回JSON数组(2.5秒)
|
// // 返回JSON数组(2.5秒)
|
||||||
var item string
|
// var item string
|
||||||
if err := db.Raw(`
|
// if err := db.Raw(`
|
||||||
SELECT JSON_ARRAYAGG(web_images.id) AS json_result
|
// SELECT JSON_ARRAYAGG(web_images.id) AS json_result
|
||||||
FROM web_fans
|
// FROM web_fans
|
||||||
INNER JOIN web_images ON web_images.user_id = web_fans.blogger_id
|
// INNER JOIN web_images ON web_images.user_id = web_fans.blogger_id
|
||||||
WHERE web_fans.follower_id = ? AND web_images.article_category_top_id = 22
|
// WHERE web_fans.follower_id = ? AND web_images.article_category_top_id = 22
|
||||||
`, args.Follower).Scan(&item).Error; err != nil {
|
// `, args.Follower).Scan(&item).Error; err != nil {
|
||||||
fmt.Println("获取关注列表失败", err)
|
// fmt.Println("获取关注列表失败", err)
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
|
// var ids []int
|
||||||
var ids []int
|
// json.Unmarshal([]byte(item), &ids)
|
||||||
json.Unmarshal([]byte(item), &ids)
|
// sort.Slice(ids, func(i, j int) bool {
|
||||||
|
// return ids[i] > ids[j] // 按照降序排列
|
||||||
sort.Slice(ids, func(i, j int) bool {
|
// })
|
||||||
return ids[i] > ids[j] // 按照降序排列
|
// id_list = append(id_list, ids)
|
||||||
})
|
//}
|
||||||
id_list = append(id_list, ids)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 筛选:时间段
|
// 筛选:时间段
|
||||||
applyTimeCondition := func(name string, str string) {
|
applyTimeCondition := func(name string, str string) {
|
||||||
@@ -561,15 +557,19 @@ func NewSchema(config Config) (graphql.Schema, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if createTime, ok := p.Args["create_time"].(string); ok && createTime != "" {
|
// 数据库中筛选:创建时间段
|
||||||
applyTimeCondition("create_time", createTime)
|
if p.Args["create_time"] != nil {
|
||||||
} else if updateTime, ok := p.Args["update_time"].(string); ok && updateTime != "" {
|
applyTimeCondition("create_time", p.Args["create_time"].(string))
|
||||||
applyTimeCondition("update_time", updateTime)
|
}
|
||||||
|
|
||||||
|
// 数据库中筛选:更新时间段
|
||||||
|
if p.Args["update_time"] != nil {
|
||||||
|
applyTimeCondition("update_time", p.Args["update_time"].(string))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 数据库中筛选:横屏纵屏
|
// 数据库中筛选:横屏纵屏
|
||||||
if args.Orientation != "" {
|
if p.Args["orientation"] != nil {
|
||||||
query.Where("article_orientation = ?", args.Orientation)
|
query.Where("article_orientation = ?", p.Args["orientation"])
|
||||||
}
|
}
|
||||||
|
|
||||||
// 数据库中筛选:游戏设备
|
// 数据库中筛选:游戏设备
|
||||||
@@ -582,6 +582,11 @@ func NewSchema(config Config) (graphql.Schema, error) {
|
|||||||
query = query.Joins("JOIN web_article ON web_images.article_id = web_article.id AND web_article.era = ?", p.Args["era"])
|
query = query.Joins("JOIN web_article ON web_images.article_id = web_article.id AND web_article.era = ?", p.Args["era"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 数据库中筛选:按关注列表
|
||||||
|
if p.Args["follower"] != nil {
|
||||||
|
query = query.Joins("JOIN web_fans ON web_images.user_id = web_fans.blogger_id AND web_fans.follower_id = ?", p.Args["follower"])
|
||||||
|
}
|
||||||
|
|
||||||
// 排序
|
// 排序
|
||||||
|
|
||||||
// 截取:取交集
|
// 截取:取交集
|
||||||
|
Reference in New Issue
Block a user