diff --git a/README.md b/README.md index 3f1b9b5..a18d075 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,82 @@ -# ai +# ai 繪圖 -ai 繪圖服務端(快速重構) \ No newline at end of file +ai 繪圖服務端(快速重構) + + +接口列表: +- [ ] /api/user +- [ ] /api/tags +- [ ] /api/tasks +- [ ] /api/models +- [ ] /api/images + + +請求方式: +- [ ] GET +- [ ] POST +- [ ] PATCH +- [ ] DELETE + + + +### 获取图片列表(标准查询) + +GET /api/images +```javascript +{ + page: 1, // 当前页码 + pageSize: 20, // 分页数 + next: true, // 是否存在下一页 + list: [{ + id: 1234, // 原图ID + width: 512, // 原图宽度 + height: 512, // 原图高度 + user: { // 来源用户 + id: 1234, + user_name: 'LAST', + }, + article: { // 来源文章 + id: 1234, + title: 'GAMEX', + } + }] +} +``` + + +列表视图:(输出控制) +------------------------------------------------------------------------------------- +Method | URL | Info | Status +-------|--------------------------------|-----------------------------------|-------- +GET | /api/images | 标准顺序查询 | ok +GET | /api/images?page=1&pageSize=20 | 指定页码和指定分页大小 | ok + + +筛选规则:(数据过滤) +------------------------------------------------------------------------------------- +Method | URL | Info | Statu +-------|--------------------------------|-----------------------------------|-------- +GET | /api/images?user=1234 | 筛选指定某用户发表的图片 | +GET | /api/images?choice=1234 | 筛选指定精选集下的图片 | +GET | /api/images?like=1234 | 筛选指定用户点赞的图片 | +GET | /api/images?tag=1234 | 筛选含有指定标签的图片 | +GET | /api/images?tag=1234,1235 | 筛选含有多个标签之一的图片(并集) | +GET | /api/images?tag=1234&tag=1235 | 筛选含有指定多个标签的图片(交集) | +GET | /api/images?user=1234&tag=123 | 筛选指定用户的指定标签图片(交集) | +GET | /api/images?date=20220214+ | 时间范围(之后) | +GET | /api/images?date=20220214- | 时间范围(之前) | +GET | /api/images?date=2022~2023 | 时间范围(之间) | + + +排序规则:(权重强化) +------------------------------------------------------------------------------------- +Method | URL | Info | Status +-------|--------------------------------|-----------------------------------|-------- +GET | /api/images?similar=1234 | 根据指定图片的相似图片(指定图片ID) | ok +GET | /api/images?sort=date+ | 排序规则(相似图片查询时此项无效) | +GET | /api/images?sort=like | 根据用户偏好推荐(指定用户的偏好) | +GET | /api/images?sort=history | 根据浏览记录推荐(指定用户的记录) | +GET | /api/images?sort=choice | 根据精选集推荐(指定精选集ID,取一组权重) | + +* 注意, 筛选规则为多条件取交集, 单条件的复数取并集 +* 权重强化属于排序规则而非过滤规则 diff --git a/main.go b/main.go new file mode 100644 index 0000000..8b20215 --- /dev/null +++ b/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "net/http" +) + +func main() { + fmt.Println("Hello, World!") + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "Hello, World!") + }) + http.HandleFunc("/images", func(w http.ResponseWriter, r *http.Request) {}) + http.HandleFunc("/models", func(w http.ResponseWriter, r *http.Request) {}) + http.HandleFunc("/tasks", func(w http.ResponseWriter, r *http.Request) {}) + http.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) {}) + http.HandleFunc("/tags", func(w http.ResponseWriter, r *http.Request) {}) + http.ListenAndServe(":8080", nil) +} diff --git a/models/ListView.go b/models/ListView.go new file mode 100644 index 0000000..5c3f211 --- /dev/null +++ b/models/ListView.go @@ -0,0 +1,10 @@ +package models + +type ListView struct { + Code int `json:"code"` + Page int `json:"page"` + PageSize int `json:"page_size"` + Total int `json:"total"` + Next bool `json:"next"` + List []interface{} `json:"list"` +}