需求:前台壁纸站支持切换到开源壁纸平台,并能展示后台上传的自家图库, 保留原有「浏览器实时生成」能力(扩展而非替换),PC / 移动双端一致。 设计要点(受服务器 5M 出口带宽约束): - 开源平台图片一律走官方 CDN 直链,后端只代理元数据,零带宽消耗。 - 自建图库落盘到 /data/www/wallpaper,由 nginx 的 /wallpaper/ 直出, Go 服务不参与传图;三档尺寸(480 缩略 / 1920 预览 / 原图仅供下载)。 - 内存缓存平台响应(Bing 1h、搜索类 10min),避免撞第三方配额。 内容: - 平台插件:Bing 每日一图、Picsum、Unsplash、Pexels、Wallhaven。 新增平台 = 写一个 provider_xxx.go 并在 allProviders() 加一行, 刻意不用 init() 自注册,避免隐式副作用。所有适配器支持 config.baseUrl 覆盖,用于绕开 DNS 污染(实测 wallhaven.cc 解析到境外无关 IP)。 - 自建图库:上传(MD5 秒传去重 / 尺寸前置校验 / 失败清理孤儿文件)、 元信息编辑、删除、统计;随机取图用「数总数 → 随机偏移」而非 ORDER BY RAND()。 - 接口:open 组 4 个(sources / list / random / download-track), admin 组 8 个(list / upload / save / delete / stats / source.list|save|test)。 全部 POST 且 URL 无参数,符合工作空间接口规范;上传走 multipart 例外。 - 安全:purity 默认锁死 SFW;apiKey 只回传布尔不回传明文; 保存时留空表示保留旧值;open 组错误信息对外脱敏。 - 配置:clientMaxBodySize 提到 64M(gf 默认 8M 会截断 20MB 原图); wallpaper.root / baseUrl 支持环境变量注入并在占位符未替换时兜底。 依赖:golang.org/x/image@v0.23.0(仅用于缩略图缩放,保持 go 1.23.0 不变)。
31 lines
3.1 KiB
Go
31 lines
3.1 KiB
Go
// =================================================================================
|
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|
// =================================================================================
|
|
|
|
package entity
|
|
|
|
// Wallpaper is the golang structure for table wallpaper.
|
|
type Wallpaper struct {
|
|
Id uint64 `json:"id" orm:"id" description:""` //
|
|
Title string `json:"title" orm:"title" description:"标题"` // 标题
|
|
Tags string `json:"tags" orm:"tags" description:"标签(英文逗号分隔)"` // 标签(英文逗号分隔)
|
|
Category string `json:"category" orm:"category" description:"分类(自由文本)"` // 分类(自由文本)
|
|
Orientation int `json:"orientation" orm:"orientation" description:"朝向 0未知 1横版 2竖版 3方形"` // 朝向 0未知 1横版 2竖版 3方形
|
|
Width int `json:"width" orm:"width" description:"原图宽度(px)"` // 原图宽度(px)
|
|
Height int `json:"height" orm:"height" description:"原图高度(px)"` // 原图高度(px)
|
|
Filesize int64 `json:"filesize" orm:"filesize" description:"原图字节数"` // 原图字节数
|
|
Mime string `json:"mime" orm:"mime" description:"原图MIME(image/jpeg等)"` // 原图MIME(image/jpeg等)
|
|
Path string `json:"path" orm:"path" description:"原图相对路径(相对存储根)"` // 原图相对路径(相对存储根)
|
|
ThumbPath string `json:"thumbPath" orm:"thumb_path" description:"缩略图相对路径(480px)"` // 缩略图相对路径(480px)
|
|
PreviewPath string `json:"previewPath" orm:"preview_path" description:"预览图相对路径(长边1920)"` // 预览图相对路径(长边1920)
|
|
Hash string `json:"hash" orm:"hash" description:"原图MD5(秒传去重)"` // 原图MD5(秒传去重)
|
|
Enabled int `json:"enabled" orm:"enabled" description:"是否启用 0否 1是"` // 是否启用 0否 1是
|
|
Sort int `json:"sort" orm:"sort" description:"排序,小的在前"` // 排序,小的在前
|
|
ViewCount int `json:"viewCount" orm:"view_count" description:"浏览次数"` // 浏览次数
|
|
DownloadCount int `json:"downloadCount" orm:"download_count" description:"下载次数"` // 下载次数
|
|
Remark string `json:"remark" orm:"remark" description:"备注"` // 备注
|
|
CreatedAt string `json:"createdAt" orm:"created_at" description:""` //
|
|
UpdatedAt string `json:"updatedAt" orm:"updated_at" description:""` //
|
|
DeletedAt string `json:"deletedAt" orm:"deleted_at" description:""` //
|
|
}
|