init history
This commit is contained in:
58
bin/main.go
58
bin/main.go
@@ -70,6 +70,12 @@ type Tag struct {
|
||||
UpdateTime time.Time `json:"update_time"`
|
||||
}
|
||||
|
||||
type History struct {
|
||||
Type string `json:"type"`
|
||||
CreateTime time.Time `json:"create_time"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
type ListView struct {
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
@@ -130,6 +136,58 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
// 获取浏览记录
|
||||
http.HandleFunc("/history", func(w http.ResponseWriter, r *http.Request) {
|
||||
defer LogComponent(time.Now().UnixNano(), r) // 最后打印日志
|
||||
|
||||
// 按会话过滤
|
||||
// 按用户过滤
|
||||
// 按时间过滤
|
||||
// 按类型过滤
|
||||
// 按数据过滤
|
||||
|
||||
// 日志记录器:
|
||||
// 会话记录, 调取也从SDK本地取数据
|
||||
// URL变化或新开 [URL, 来源, 时间]
|
||||
// 针对某些组件挂载的事件 [组件, 事件, 时间]
|
||||
// 记录用户行为 [用户, 行为, 时间]
|
||||
// 查看过的[图片, 文章, 精选集, 用户]
|
||||
// 请求过的API连接
|
||||
|
||||
// 展示了的数据
|
||||
// 展示后被点击的数据(+正反馈)
|
||||
// 展示后被收藏的数据
|
||||
// 展示后被分享的数据
|
||||
// 展示后被评论的数据
|
||||
// 展示后被点赞的数据
|
||||
// 展示后被下载的数据
|
||||
// 展示后被忽略的数据(+负反馈)
|
||||
// 展示后被屏蔽的数据(+屏蔽功能)
|
||||
|
||||
// 获取用户id
|
||||
userId := stringToInt(r.URL.Query().Get("user_id"), 0)
|
||||
if userId == 0 {
|
||||
w.Write([]byte("user_id is required"))
|
||||
return
|
||||
}
|
||||
|
||||
// 获取图片id列表
|
||||
var ids []int64
|
||||
err := json.Unmarshal([]byte(r.URL.Query().Get("ids")), &ids)
|
||||
if err != nil {
|
||||
w.Write([]byte("ids is required"))
|
||||
return
|
||||
}
|
||||
|
||||
// 获取图片信息列表
|
||||
var images []Image
|
||||
//mysqlConnection.DB.Where("id in (?)", ids).Find(&images)
|
||||
|
||||
// 返回结果
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(images)
|
||||
})
|
||||
|
||||
// 获取图片信息列表(分页)
|
||||
http.HandleFunc("/images", func(w http.ResponseWriter, r *http.Request) {
|
||||
defer LogComponent(time.Now().UnixNano(), r) // 最后打印日志
|
||||
|
Reference in New Issue
Block a user