Compare commits
427
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df2da25833 | ||
|
|
1ea4cfeba3 | ||
|
|
ce6e3ef70a | ||
|
|
87e20c31a9 | ||
|
|
22edf34ff1 | ||
|
|
16ba79a336 | ||
|
|
9c25b1b397 | ||
|
|
5a80e6693f | ||
|
|
ab58641bbe | ||
|
|
45e3d84f59 | ||
|
|
a3ff636e45 | ||
|
|
7b360ddccd | ||
|
|
758c7521bb | ||
|
|
e730cfaa7d | ||
|
|
60a87a8d15 | ||
|
|
0b519b8ca1 | ||
|
|
e6b4a747ce | ||
|
|
f009f75c03 | ||
|
|
91b621fe75 | ||
|
|
5d1a157085 | ||
|
|
5552caa6c1 | ||
|
|
ad84704d28 | ||
|
|
08eddc9ed2 | ||
|
|
660afaf66d | ||
|
|
f9bc6eee6d | ||
|
|
5ef5dd8eaf | ||
|
|
a35b02dd18 | ||
|
|
04d25cd23d | ||
|
|
217ff24f1c | ||
|
|
40a884cc85 | ||
|
|
345408d5e7 | ||
|
|
090f149b31 | ||
|
|
f66eae5baf | ||
|
|
4219186ab0 | ||
|
|
7e6075a2e9 | ||
|
|
cd51aabe7e | ||
|
|
c5468a669b | ||
|
|
7b694938c6 | ||
|
|
71b0c7315a | ||
|
|
ec15950851 | ||
|
|
7d563f2cd6 | ||
|
|
6bdd245a83 | ||
|
|
316baf28d6 | ||
|
|
70da939a58 | ||
|
|
07754ff4e4 | ||
|
|
4159af1732 | ||
|
|
0143fa036c | ||
|
|
5227762aeb | ||
|
|
a4317bb6f1 | ||
|
|
9adf8c5630 | ||
|
|
8bb7f63c62 | ||
|
|
b8b3fd867b | ||
|
|
e92ec118fe | ||
|
|
4c4b53cd69 | ||
|
|
d7f226659c | ||
|
|
979e6ebea3 | ||
|
|
3a581163aa | ||
|
|
97c2153c2e | ||
|
|
27a15dd1b4 | ||
|
|
cf37d6c408 | ||
|
|
c9b8ec6805 | ||
|
|
31d88b634a | ||
|
|
5704f80929 | ||
|
|
652ef050ee | ||
|
|
8f35160b56 | ||
|
|
0e8fb1582d | ||
|
|
aa74770256 | ||
|
|
01ae6d44f0 | ||
|
|
ff14762426 | ||
|
|
419119725e | ||
|
|
b31784010c | ||
|
|
4049cfd2d0 | ||
|
|
c70054e83d | ||
|
|
9baab3777a | ||
|
|
3036b782f9 | ||
|
|
1fa3631e53 | ||
|
|
2df4e5cc9f | ||
|
|
8f1103dfa7 | ||
|
|
aa532eb568 | ||
|
|
33c1172da5 | ||
|
|
4c614a5ece | ||
|
|
030df5c5dc | ||
|
|
b82a05f82e | ||
|
|
ae053b0268 | ||
|
|
9a74876b3f | ||
|
|
6ddddef5ec | ||
|
|
0a2ca5d379 | ||
|
|
fe18a2c9ea | ||
|
|
1d316791b1 | ||
|
|
d52b805adf | ||
|
|
7a16feb548 | ||
|
|
08380a52c8 | ||
|
|
96d58c53f7 | ||
|
|
6252a07b5d | ||
|
|
3303a91e3c | ||
|
|
7ae05698fa | ||
|
|
c511d04415 | ||
|
|
dfc978c620 | ||
|
|
c6f729fb27 | ||
|
|
c7ff729f84 | ||
|
|
e0ae38ce08 | ||
|
|
e2e2a21d2f | ||
|
|
a3b6bf3a55 | ||
|
|
fd402d9efe | ||
|
|
1052b97306 | ||
|
|
d9cdbc8e15 | ||
|
|
edd279372d | ||
|
|
7ab6dc62dd | ||
|
|
22fc173305 | ||
|
|
0b914dd274 | ||
|
|
c7e5de5f99 | ||
|
|
e6b5b904fc | ||
|
|
ba628e3a4a | ||
|
|
ad4be92189 | ||
|
|
5d018657d5 | ||
|
|
24bd00b537 | ||
|
|
250a6142f3 | ||
|
|
e90debe810 | ||
|
|
2d8e5cf53e | ||
|
|
7ab22d26b1 | ||
|
|
5c7973471d | ||
|
|
c81e3643d5 | ||
|
|
4297e02a67 | ||
|
|
844b6abb25 | ||
|
|
e6e8a347fc | ||
|
|
fc8f507864 | ||
|
|
f016df0bf1 | ||
|
|
141874a0bc | ||
|
|
d788d70752 | ||
|
|
cb45bafad6 | ||
|
|
56532c2c03 | ||
|
|
12502a2e69 | ||
|
|
e46a9fd347 | ||
|
|
908023ddc4 | ||
|
|
d9db07573e | ||
|
|
b2621d67ca | ||
|
|
aaa6f06477 | ||
|
|
562d8941b9 | ||
|
|
b286137cb0 | ||
|
|
99e9b4f7bf | ||
|
|
12a011fdce | ||
|
|
fa95bf05d5 | ||
|
|
5c631c6f23 | ||
|
|
19fd56d477 | ||
|
|
35c8cf0b9c | ||
|
|
4b6c4ba928 | ||
|
|
4e93f7bdd4 | ||
|
|
81b5c99b6a | ||
|
|
f496c9fa16 | ||
|
|
1de35bfa30 | ||
|
|
48fdee2c4b | ||
|
|
3d15807919 | ||
|
|
3c64525a3e | ||
|
|
5103527635 | ||
|
|
52bc80a402 | ||
|
|
87c7f786d2 | ||
|
|
16e1657063 | ||
|
|
f54f21be37 | ||
|
|
f357347d28 | ||
|
|
afe45fe8c5 | ||
|
|
c415177287 | ||
|
|
76d6cc9703 | ||
|
|
a674865538 | ||
|
|
708b39ffcc | ||
|
|
7579d3163a | ||
|
|
8e6213aed8 | ||
|
|
b169173901 | ||
|
|
c08fb7b3aa | ||
|
|
65e8fbfc70 | ||
|
|
88794b816e | ||
|
|
256821b824 | ||
|
|
f90336963b | ||
|
|
4c20c82f96 | ||
|
|
530da2b1b4 | ||
|
|
b391ad31af | ||
|
|
368cd04742 | ||
|
|
f1c11df5d5 | ||
|
|
64ddfe8cae | ||
|
|
82dd899ad0 | ||
|
|
3a25534bc1 | ||
|
|
da60bd8b0f | ||
|
|
60fa96b789 | ||
|
|
ad5b104e0d | ||
|
|
e1580c70ed | ||
|
|
4f3bb0090c | ||
|
|
32710c2e06 | ||
|
|
42dd68f266 | ||
|
|
6d3997cbae | ||
|
|
fa4977a71d | ||
|
|
d1aaf2e5c0 | ||
|
|
0b2709339e | ||
|
|
b5f1699240 | ||
|
|
c2974957ba | ||
|
|
bce8d37d88 | ||
|
|
fdc7314087 | ||
|
|
c5def287b8 | ||
|
|
5e509b20ed | ||
|
|
f6ce79c65a | ||
|
|
0f477c6b15 | ||
|
|
0de7436baf | ||
|
|
a755a5f657 | ||
|
|
0a48d2739a | ||
|
|
36cd6a0fcd | ||
|
|
de8f02a542 | ||
|
|
374b0bd89c | ||
|
|
efd1c0d38c | ||
|
|
d214a9791c | ||
|
|
aadb02a9c4 | ||
|
|
3afb182361 | ||
|
|
e50e6c7170 | ||
|
|
a38809cc5d | ||
|
|
7fc5eb9067 | ||
|
|
ce221c99c8 | ||
|
|
d34410971a | ||
|
|
1de202ad4a | ||
|
|
38aac37a4e | ||
|
|
c6192fdbd0 | ||
|
|
f2a3d79f53 | ||
|
|
f51adf5a98 | ||
|
|
1aa003a5af | ||
|
|
68c00db549 | ||
|
|
8113a4efd3 | ||
|
|
fd59d1a19d | ||
|
|
df5cfb8c83 | ||
|
|
e08c73efe8 | ||
|
|
7a6ecc295f | ||
|
|
bc37f647ad | ||
|
|
06757e9ab4 | ||
|
|
2ed8f339db | ||
|
|
a92f903738 | ||
|
|
90b4f9d73a | ||
|
|
cd108ba6c5 | ||
|
|
63e20c2968 | ||
|
|
70949b8f4b | ||
|
|
f54c009acd | ||
|
|
a67bba1178 | ||
|
|
af2f2c9411 | ||
|
|
7c5800bef1 | ||
|
|
ee43b4e186 | ||
|
|
bf9d611fcc | ||
|
|
2bf9e8500c | ||
|
|
9ffbdc0926 | ||
|
|
2a2e301e57 | ||
|
|
e14d266dfd | ||
|
|
f73efc8653 | ||
|
|
041d97a0a3 | ||
|
|
a80a0ed4ca | ||
|
|
4a6a31d3cd | ||
|
|
8e1c8b7408 | ||
|
|
800537076d | ||
|
|
fbb1b6c30a | ||
|
|
75352e9817 | ||
|
|
748dea3424 | ||
|
|
d82d5c76be | ||
|
|
452fe74b3d | ||
|
|
053993dd5f | ||
|
|
43d04519c2 | ||
|
|
cc187a53c0 | ||
|
|
ef526c6360 | ||
|
|
e66e1ed922 | ||
|
|
c43321e19f | ||
|
|
aa69d4b0c6 | ||
|
|
3755b766af | ||
|
|
83f7890851 | ||
|
|
dfa24c0f43 | ||
|
|
6435238ad7 | ||
|
|
4aa80d0fc7 | ||
|
|
02a675a07c | ||
|
|
c9561edb63 | ||
|
|
ccf12cac8c | ||
|
|
7d3d131f28 | ||
|
|
fa6f443a98 | ||
|
|
729b369408 | ||
|
|
065318accd | ||
|
|
2cf9009a8c | ||
|
|
447a767617 | ||
|
|
8b176a6880 | ||
|
|
fdf3f04b23 | ||
|
|
97b55185e6 | ||
|
|
811b78375e | ||
|
|
97b5c4ac37 | ||
|
|
0877b1bb0f | ||
|
|
f19d21ef96 | ||
|
|
671953bff3 | ||
|
|
678652cb20 | ||
|
|
de584257e5 | ||
|
|
a4ea054df7 | ||
|
|
d91d1d59b9 | ||
|
|
16316e2f0a | ||
|
|
caab79d4c2 | ||
|
|
939d985f67 | ||
|
|
c93ba886b4 | ||
|
|
674b3d4ac8 | ||
|
|
4b0ca0e9e7 | ||
|
|
3073852153 | ||
|
|
ac0639e157 | ||
|
|
e95bc0b513 | ||
|
|
b9d8a0aa9a | ||
|
|
edc0e24021 | ||
|
|
5b5c590cad | ||
|
|
2a1e3ac8b7 | ||
|
|
9cbfa874c9 | ||
|
|
bd804ff05e | ||
|
|
5c7128136d | ||
|
|
cd2ab673a4 | ||
|
|
dc124b17a9 | ||
|
|
691ef33e5b | ||
|
|
c9b70e4e9b | ||
|
|
6e0757a246 | ||
|
|
5c8088a29c | ||
|
|
4541ca6bce | ||
|
|
fe84d8b7b5 | ||
|
|
8d9e3afc9a | ||
|
|
988362db00 | ||
|
|
1816142929 | ||
|
|
44d319a911 | ||
|
|
4ae07c7734 | ||
|
|
0cc5d4f0ee | ||
|
|
10bb3dbe6e | ||
|
|
3334b45334 | ||
|
|
c1d29baa87 | ||
|
|
4e2f80fefa | ||
|
|
df2023a523 | ||
|
|
62a0d3636d | ||
|
|
73404d68ed | ||
|
|
2715f4babe | ||
|
|
e15926a15e | ||
|
|
bc426f73a3 | ||
|
|
f58814eaea | ||
|
|
c35507681e | ||
|
|
c40bd52a8e | ||
|
|
691ec2e134 | ||
|
|
4a2e066608 | ||
|
|
2ccfc14473 | ||
|
|
6f18a8892b | ||
|
|
b70e5a90fd | ||
|
|
ae3c62b60f | ||
|
|
bb0b7377fe | ||
|
|
0ded8ddf19 | ||
|
|
b30123b727 | ||
|
|
3d560b8caf | ||
|
|
923fab80e8 | ||
|
|
63b086998e | ||
|
|
eeb5e0eaf8 | ||
|
|
e26e57ac18 | ||
|
|
83f13e9a6e | ||
|
|
212834d59d | ||
|
|
793d6e542a | ||
|
|
8b64060388 | ||
|
|
7aebcba35c | ||
|
|
2441234dba | ||
|
|
1abc190f95 | ||
|
|
ab891a0840 | ||
|
|
76e6c3546f | ||
|
|
01911016d2 | ||
|
|
244a6ce79e | ||
|
|
f51f07d77e | ||
|
|
bd53efc4c4 | ||
|
|
317daf4c2b | ||
|
|
01990259af | ||
|
|
d7e69fac80 | ||
|
|
0d2e6ba87f | ||
|
|
8767200235 | ||
|
|
d977f1472b | ||
|
|
f6d6887b84 | ||
|
|
218bd880e1 | ||
|
|
4081b9c893 | ||
|
|
19c608fb31 | ||
|
|
980ce77192 | ||
|
|
4070c4e39e | ||
|
|
c21f0309ba | ||
|
|
8a37996617 | ||
|
|
5c2c273798 | ||
|
|
e22e942c27 | ||
|
|
03e17166ab | ||
|
|
e03215f445 | ||
|
|
80a3b27353 | ||
|
|
7801fad1b5 | ||
|
|
98b3d30ca0 | ||
|
|
d9088be2a6 | ||
|
|
8e70dd220a | ||
|
|
7b1030c1ba | ||
|
|
258be6e4e7 | ||
|
|
696e36a991 | ||
|
|
71e2f266ff | ||
|
|
6fd532beae | ||
|
|
5cc6ce9d32 | ||
|
|
7613726b1a | ||
|
|
c69327062b | ||
|
|
f21a334ca8 | ||
|
|
cd711c5d5c | ||
|
|
0f8652c083 | ||
|
|
93b2299630 | ||
|
|
d88a7de2eb | ||
|
|
68d101cc8d | ||
|
|
6127fef897 | ||
|
|
3cbdca6861 | ||
|
|
c491c329af | ||
|
|
801e904552 | ||
|
|
38c8f51315 | ||
|
|
b8676d0731 | ||
|
|
477014f64b | ||
|
|
0ee3e4759e | ||
|
|
b400e36d8f | ||
|
|
91bbfd5622 | ||
|
|
5356f24632 | ||
|
|
9c96e18672 | ||
|
|
ce655ce5db | ||
|
|
c0fea67442 | ||
|
|
8aa84a39bc | ||
|
|
2807ae6a47 | ||
|
|
c4281b08b7 | ||
|
|
919e749554 | ||
|
|
be9e381612 | ||
|
|
c14b4cb9ad | ||
|
|
5e5517135a | ||
|
|
b025bfda36 | ||
|
|
81c1bbb1e5 | ||
|
|
0e3ddfc1b1 | ||
|
|
af28161e2f | ||
|
|
f6187df51a | ||
|
|
34357846f4 | ||
|
|
810d9fc2dc | ||
|
|
131f0c4e06 | ||
|
|
1bf74bdd4c | ||
|
|
9267a9026f | ||
|
|
20f19b13f2 |
No files matched your search
@@ -30,6 +30,11 @@ MEDIA_ROOT_DIR=/data/uploads
|
||||
# false = 两个都关闭(生产若不希望暴露 UI 就设 false,机器可读契约也一并关闭)
|
||||
SWAGGER_ENABLED=true
|
||||
|
||||
# ── 监控 ───────────────────────────────────────────────
|
||||
# Grafana 管理员密码(必填):3000 端口对外开放,不允许用默认 admin/admin
|
||||
GRAFANA_ADMIN_USER=admin
|
||||
GRAFANA_ADMIN_PASSWORD=
|
||||
|
||||
# ── 可选:Google Play 商店票据校验(不配则保持 disabled)──
|
||||
STORE_VERIFIER=disabled
|
||||
GOOGLE_PLAY_PACKAGE_NAME=
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# Author: fruit.com.cn
|
||||
# blackbox-exporter 探针模块:只探测 HTTP 2xx,跟随重定向
|
||||
modules:
|
||||
http_2xx:
|
||||
prober: http
|
||||
timeout: 5s
|
||||
http:
|
||||
preferred_ip_protocol: ip4
|
||||
valid_http_versions: ["HTTP/1.1", "HTTP/2.0"]
|
||||
valid_status_codes: [200]
|
||||
follow_redirects: true
|
||||
+72
-2
@@ -99,10 +99,16 @@ services:
|
||||
env_file: .env
|
||||
environment:
|
||||
SERVER_PORT: "8080"
|
||||
SPRING_SERVLET_MULTIPART_MAX_FILE_SIZE: "2GB"
|
||||
SPRING_SERVLET_MULTIPART_MAX_REQUEST_SIZE: "2GB"
|
||||
CORS_ALLOWED_ORIGINS: "http://localhost:3005,http://127.0.0.1:3005,http://39.162.50.99:3005,http://192.168.31.250:3005"
|
||||
DB_URL: ${DB_URL:-jdbc:postgresql://db:5432/${DB_NAME:-fruitshorts}}
|
||||
# 管理端仅内网,页面上直接播放/下载裸媒资地址(不签播放签名),
|
||||
# 因此这里不启用 /files/episode/** 的签名校验;公开的 app-api 仍保持开启。
|
||||
FRUITSHORTS_MEDIA_PROTECTED_PREFIXES: ""
|
||||
ports:
|
||||
# docs/12-上线检查清单「管理端仅内网」:只绑本机,公网不直接暴露
|
||||
- "127.0.0.1:8080:8080"
|
||||
# docs/12-上线检查清单「管理端仅内网」:只对局域网开放;不在路由器做端口转发,公网访问不到
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ./data/uploads:/data/uploads
|
||||
depends_on:
|
||||
@@ -142,7 +148,71 @@ services:
|
||||
start_period: 40s
|
||||
retries: 3
|
||||
|
||||
# ─────────── 监控 ───────────
|
||||
# 编排统一在这里:prometheus(应用指标 + 容器指标 + 黑盒探活)+ grafana(自动加载看板)
|
||||
prometheus:
|
||||
image: prom/prometheus:latest
|
||||
container_name: fruitshorts-prometheus
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "9090:9090"
|
||||
volumes:
|
||||
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
||||
- prometheus-data:/prometheus
|
||||
command:
|
||||
- "--config.file=/etc/prometheus/prometheus.yml"
|
||||
# 15 天保留期,避免磁盘无限增长
|
||||
- "--storage.tsdb.retention.time=15d"
|
||||
- "--web.enable-lifecycle"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:9090/-/healthy >/dev/null || exit 1"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
start_period: 20s
|
||||
retries: 3
|
||||
|
||||
grafana:
|
||||
image: grafana/grafana:latest
|
||||
container_name: fruitshorts-grafana
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- grafana-data:/var/lib/grafana
|
||||
# 数据源与看板全部来自仓库,换机器不需要手工配
|
||||
- ./grafana/provisioning:/etc/grafana/provisioning:ro
|
||||
- ./grafana/dashboards:/var/lib/grafana/dashboards:ro
|
||||
environment:
|
||||
GF_SECURITY_ADMIN_USER: ${GRAFANA_ADMIN_USER:-admin}
|
||||
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD:?Grafana 管理员密码必填,见 .env.example}
|
||||
GF_USERS_ALLOW_SIGN_UP: "false"
|
||||
TZ: Asia/Shanghai
|
||||
depends_on:
|
||||
- prometheus
|
||||
|
||||
# 黑盒探活:从外部探测接口可用性与耗时
|
||||
blackbox:
|
||||
image: prom/blackbox-exporter:latest
|
||||
container_name: fruitshorts-blackbox
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./blackbox/blackbox.yml:/etc/blackbox_exporter/config.yml:ro
|
||||
|
||||
# 容器资源指标(CPU / 内存 / 网络 / 重启),供 Prometheus 抓取
|
||||
cadvisor:
|
||||
image: gcr.io/cadvisor/cadvisor:latest
|
||||
container_name: fruitshorts-cadvisor
|
||||
restart: unless-stopped
|
||||
privileged: true
|
||||
volumes:
|
||||
- /:/rootfs:ro
|
||||
- /var/run:/var/run:ro
|
||||
- /sys:/sys:ro
|
||||
- /var/lib/docker/:/var/lib/docker:ro
|
||||
|
||||
volumes:
|
||||
# 命名卷:跟着 compose 项目走,`docker compose down -v` 才会删
|
||||
db-data:
|
||||
redis-data:
|
||||
prometheus-data:
|
||||
grafana-data:
|
||||
+440
-11
@@ -165,10 +165,90 @@ app.register.max-per-device-per-day
|
||||
|
||||
| 方法 | 路径 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| GET | `/app/home/feed` | 首页:轮播 + 分区,卡片带 `preview` 可播预览集 |
|
||||
| GET | `/app/home/feed` | 首页:轮播 + 分区,卡片带 `preview` 可播预览集与 `language` 语种 |
|
||||
| GET | `/app/discover/feed` | 发现页分区 |
|
||||
| GET | `/app/feed?types=ANIME,LIVE&categoryId=7&cursor=&size=20` | 推荐流;支持内容类型与分类叠加过滤,游标翻页 |
|
||||
| GET | `/app/categories` | 分类列表 |
|
||||
| GET | `/app/dramas/{id}` | 详情(含剧集列表,免费集带**已签名**播放地址) |
|
||||
| GET | `/app/search?keyword=&pageIndex=&pageSize=` | **匿名**。搜索已上线短剧:按标题/简介模糊匹配,分页返回卡片列表 |
|
||||
|
||||
> 卡片(`AppDramaCardVO`)统一新增 `language` 字段(取值如 `zh-CN` / `id`),
|
||||
> 首页、发现页、分类、收藏、搜索等所有下发卡片的场景都带该字段,客户端可据此做语言筛选。
|
||||
>
|
||||
> 卡片同时下发 `likeCount` / `favoriteCount` / `commentCount`(均为 JSON 字符串)。
|
||||
> `favoriteCount` 取整部剧;`likeCount` / `commentCount` 取卡片 `preview` 当前集的
|
||||
> `drama_episode.like_count` 与 `content_comment.episode_id` 统计(排除逻辑删除与 `status = 'deleted'`);
|
||||
> `viewCount` 热度仍取整部剧。首页、发现、分类、收藏、搜索等列表卡片结构一致。
|
||||
>
|
||||
> 卡片新增 `dramaType`:`ANIME` 表示漫剧,`LIVE` 表示真人剧。
|
||||
> 客户端字段仍返回主内容类型;后台多选值保存在 `drama.drama_types`,
|
||||
> App 类型筛选按逗号列整词匹配,因此 `ANIME,LIVE` 多标签剧可被任一类型命中。
|
||||
|
||||
#### 推荐类型流(`GET /app/feed`)
|
||||
|
||||
- `types` 可选,逗号分隔,支持 `ANIME`、`LIVE` 或多选 `ANIME,LIVE`;不传或空值返回全部已上线内容。
|
||||
过滤按 `drama_types` 整词匹配,多标签剧可被多个类型同时命中。
|
||||
- `categoryId` 可选;不传返回全部分类。传入后按 `category_ids` 整词匹配,
|
||||
可与 `types` 叠加,只返回同时命中内容类型和分类的已上线短剧。
|
||||
- `cursor` 可选,上一页返回的 `nextCursor`;`size` 默认 20,最大 50。
|
||||
游标短剧必须同时满足已上线、内容类型命中和分类命中,否则返回空列表。
|
||||
- 排序:`recommend_weight DESC NULLS LAST, view_count DESC, id DESC`。
|
||||
- 返回 `Result<CursorResult<AppDramaCardVO>>`,卡片字段与首页一致,包含互动计数、`preview`、`language`、`dramaType`。
|
||||
|
||||
#### 短剧详情响应(`GET /app/dramas/{id}`)
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0, "message": "ok",
|
||||
"data": {
|
||||
"id": "5",
|
||||
"title": "命运的相遇",
|
||||
"synopsis": "一次意外的相遇,让两个世界的人走到一起。",
|
||||
"cover": "/files/drama/202610/cover.jpg",
|
||||
"genre": "都市 · 情感",
|
||||
"category": "都市",
|
||||
"totalEpisodes": 80,
|
||||
"freeEpisodes": 10,
|
||||
"unlockCoin": 30,
|
||||
"isHot": true,
|
||||
"viewCount": "12400",
|
||||
"likeCount": "3200",
|
||||
"favoriteCount": "1800",
|
||||
"commentCount": "96",
|
||||
"episodes": [
|
||||
{
|
||||
"id": "2111012753262120962",
|
||||
"number": 1,
|
||||
"title": "第 1 集",
|
||||
"duration": "03:00",
|
||||
"durationSec": 180,
|
||||
"isFree": true,
|
||||
"locked": false,
|
||||
"unlockCoin": 0,
|
||||
"likeCount": "45",
|
||||
"commentCount": "8",
|
||||
"playUrl": "/files/episode/202610/xxx.mp4?e=1760000000&s=9f2c...",
|
||||
"thumbnailsUrl": "/files/transcoded/88/thumbnails/thumbnails.vtt?e=1760000000&s=8a1d..."
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
详情里的互动数量:
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `likeCount` | Long(JSON 字符串) | 剧级历史汇总,保留兼容;新客户端按集使用 `episodes[].likeCount` |
|
||||
| `favoriteCount` | Long(JSON 字符串) | 取 `drama.favorite_count`,短剧累计收藏数 |
|
||||
| `commentCount` | Long(JSON 字符串) | `content_comment` 中该剧未删除评论数:按 `drama_id` 统计,排除 `status = 'deleted'` 与逻辑删除记录 |
|
||||
| `viewCount` | Long(JSON 字符串) | 取 `drama.view_count`,累计播放量,既有字段语义不变 |
|
||||
| `episodes[].likeCount` | Long(JSON 字符串) | 本集点赞数,取 `drama_episode.like_count` |
|
||||
| `episodes[].commentCount` | Long(JSON 字符串) | 本集未删除评论数,按 `episode_id` 统计 |
|
||||
| `episodes[].thumbnailsUrl` | String / null | 本集雪碧图 WebVTT 时间轴签名地址;没有 READY 产物时为 `null` |
|
||||
|
||||
计数是只读快照:互动操作完成后客户端重新拉取详情即可刷新;`Long` 字段一律按字符串下发,
|
||||
客户端需要转成数字再展示(与 `viewCount` 相同)。
|
||||
|
||||
### 1.4 播放(已实现,链路已重做)
|
||||
|
||||
@@ -184,9 +264,16 @@ app.register.max-per-device-per-day
|
||||
"accessible": true,
|
||||
"accessType": "FREE",
|
||||
"playUrl": "/files/episode/202610/xxx.mp4?e=1760000000&s=9f2c...",
|
||||
"qualities": ["AUTO"],
|
||||
"qualities": ["AUTO", "720p", "1080p"],
|
||||
"tracks": [
|
||||
{"quality": "AUTO", "playUrl": "/files/transcoded/88/master.m3u8?e=1760000000&s=9f2c..."},
|
||||
{"quality": "720p", "playUrl": "/files/transcoded/88/720p/index.m3u8?e=1760000000&s=a1b2..."}
|
||||
],
|
||||
"thumbnailsUrl": "/files/transcoded/88/thumbnails/thumbnails.vtt?e=1760000000&s=8a1d...",
|
||||
"unlockCoin": 0,
|
||||
"previewSeconds": 0
|
||||
"previewSeconds": 0,
|
||||
"likeCount": "45",
|
||||
"commentCount": "8"
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -197,22 +284,105 @@ app.register.max-per-device-per-day
|
||||
**判定顺序由服务端决定,客户端不得自行推断可否播放。** 签名默认 15 分钟有效;
|
||||
开启 `fruitshorts.media.signature-required` 后,`/files/episode/**` 没带有效签名会返回 403。
|
||||
|
||||
`thumbnailsUrl` 指向 WebVTT:cue 链接为同目录相对雪碧图
|
||||
`sprite_XXX.jpg#xywh=x,y,w,h`。有 READY `media_thumbnail` 时返回签名地址,
|
||||
无产物时为 `null`;该字段不影响 `playUrl`、`qualities` 和 HLS/原文件回落。
|
||||
|
||||
### 1.5 观看记录与收藏(已实现)
|
||||
|
||||
| 方法 | 路径 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| POST | `/app/watch/progress` | 上报进度(建议每 10s 一次,切集时补一次) |
|
||||
| GET | `/app/watch/progress?dramaId=` | 某剧续看位置 |
|
||||
| GET | `/app/watch/recent?limit=20` | 最近观看 |
|
||||
| GET | `/app/watch/recent` | 最近观看分页;`pageIndex` 默认 1,`pageSize` 默认 20、上限 100 |
|
||||
| DELETE | `/app/watch/progress/{dramaId}` | 删除某剧记录 |
|
||||
| DELETE | `/app/watch/progress` | 清空记录 |
|
||||
| POST | `/app/favorites/toggle` | 收藏/取消收藏,返回切换后状态 |
|
||||
| GET | `/app/favorites` | 收藏列表(卡片结构与首页一致) |
|
||||
| GET | `/app/favorites` | 收藏分页;`pageIndex` 默认 1,`pageSize` 默认 20、上限 100 |
|
||||
| DELETE | `/app/favorites/{dramaId}` | 取消收藏 |
|
||||
| POST | `/app/favorites/remove` | 批量取消收藏,请求体 `{ "dramaIds": ["12", "15"] }` |
|
||||
|
||||
进度合并规则:同一集内只前进不后退;换集直接采纳新集;`finished` 只在接近片尾或客户端显式上报时置位。
|
||||
这样用户换设备不会看到进度倒退。
|
||||
|
||||
#### 收藏分页
|
||||
|
||||
`GET /app/favorites?pageIndex=1&pageSize=20`
|
||||
|
||||
请求参数:
|
||||
|
||||
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| `pageIndex` | int | 否 | 1 | 页码,小于 1 按 1 处理 |
|
||||
| `pageSize` | int | 否 | 20 | 每页数量,上限 100,小于 1 按 1 处理 |
|
||||
|
||||
响应 `data` 为 `PageResult<AppDramaCardVO>`:
|
||||
|
||||
```json
|
||||
{
|
||||
"total": "23",
|
||||
"list": [
|
||||
{
|
||||
"id": "12",
|
||||
"title": "替嫁新娘:总裁的掌心宠",
|
||||
"cover": "/files/drama_cover/12.jpg",
|
||||
"preview": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
排序固定为收藏时间倒序 `created_at DESC`,收藏时间相同时按 `drama_id DESC`。
|
||||
仅统计和返回仍处于已上线状态的短剧。
|
||||
|
||||
#### 最近观看分页
|
||||
|
||||
`GET /app/watch/recent?pageIndex=1&pageSize=20`
|
||||
|
||||
请求参数:
|
||||
|
||||
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| `pageIndex` | int | 否 | 1 | 页码,小于 1 按 1 处理 |
|
||||
| `pageSize` | int | 否 | 20 | 每页数量,上限 100,小于 1 按 1 处理 |
|
||||
|
||||
分页响应 `data` 为 `PageResult<ProgressRespVO>`:
|
||||
|
||||
```json
|
||||
{
|
||||
"total": "18",
|
||||
"list": [
|
||||
{
|
||||
"dramaId": "12",
|
||||
"episodeId": "88",
|
||||
"dramaTitle": "替嫁新娘:总裁的掌心宠",
|
||||
"dramaCover": "/files/drama_cover/12.jpg",
|
||||
"episodeNumber": 6,
|
||||
"totalEpisodes": 68,
|
||||
"viewCount": "1800",
|
||||
"positionMs": "80000",
|
||||
"durationMs": "120000",
|
||||
"finished": false,
|
||||
"playCount": 3,
|
||||
"updatedAt": "2026-10-22 10:00:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
排序固定为 `updated_at DESC, id DESC`。每页记录通过批量 IN 查询装配短剧和分集,
|
||||
不逐条访问数据库。越界页返回空 `list` 且 `total` 保持正确。
|
||||
|
||||
`ProgressRespVO` 展示字段:
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `dramaTitle` | string / null | 短剧标题 |
|
||||
| `dramaCover` | string / null | 短剧封面 |
|
||||
| `episodeNumber` | int / null | 当前续看集号 `ep_no` |
|
||||
| `totalEpisodes` | int / null | 短剧总集数 |
|
||||
| `viewCount` | Long(JSON 字符串)/ null | 短剧热度,取 `drama.view_count`。`playCount` 是用户自己的播放次数 |
|
||||
|
||||
### 1.6 离线下载(已实现)
|
||||
|
||||
服务端只发**授权**与**短时效地址**,分片由客户端直接向 CDN 拉取 ——
|
||||
@@ -240,8 +410,9 @@ app.register.max-per-device-per-day
|
||||
| --- | --- | --- | --- |
|
||||
| POST | `/app/comments` | 登录 | 发表评论/回复:过敏感词后按策略发布或转待审 |
|
||||
| GET | `/app/comments?dramaId=&cursor=&size=` | 匿名 | 游标翻页;不传 `rootId` 返回顶层评论,传了返回该楼层回复 |
|
||||
| GET | `/app/comments/count?dramaId=&episodeId=` | 匿名 | 传 `episodeId` 返回该集评论数;仅传 `dramaId` 返回全剧兼容汇总 |
|
||||
| DELETE | `/app/comments/{id}` | 登录 | 删除自己的评论(逻辑置为 `deleted`) |
|
||||
| POST | `/app/likes/toggle` | 登录 | 点赞/取消点赞,`targetType` 支持 `DRAMA` / `COMMENT` |
|
||||
| POST | `/app/likes/toggle` | 登录 | 点赞/取消点赞,`targetType` 支持 `DRAMA` / `EPISODE` / `COMMENT`;新客户端点赞按集 |
|
||||
| POST | `/app/reports` | 登录 | 举报评论/用户/短剧;同一目标只保留一条待处理工单 |
|
||||
|
||||
**敏感词三档处置**:`BLOCK` 直接拒绝并返回原因、`REPLACE` 替换后放行、`REVIEW` 转人工待审。
|
||||
@@ -257,9 +428,17 @@ app.register.max-per-device-per-day
|
||||
| --- | --- | --- |
|
||||
| GET | `/app/wallet` | 金币余额 + 最近流水 |
|
||||
| POST | `/app/episodes/{id}/unlock` | 金币解锁分集;幂等键 `unlock:{userId}:{episodeId}`,重复调用不重复扣币 |
|
||||
| GET | `/app/products` | 充值商品列表(只返回上架商品,`type` 可选 `COIN_PACK`/`VIP`) |
|
||||
| POST | `/app/orders` | 创建充值订单(`body` 传 `productId`,返回 `CREATED` 订单,等待支付) |
|
||||
| GET | `/app/orders` | 我的订单 |
|
||||
| POST | `/app/orders/verify` | 提交 Google Play 票据:服务端校验 → 建单 → 发权益(详见下方说明) |
|
||||
|
||||
> `GET /app/products` 只返回 `status=1`(上架)的商品,按 `sort` 升序、`id` 降序。
|
||||
> `POST /app/orders` 请求体 `{ "productId": 123 }`,商品下架时返回 `400 商品已下架`;
|
||||
> 订单 `coinAmount = coinAmount + bonusCoin`(与商店票据口径一致),状态为 `CREATED`。
|
||||
> VIP 商品下单后交付时发放 `TYPE_VIP` 权益(`dramaId=0`、`episodeId=0`,永久有效),
|
||||
> 播放/下载的权益判定在 `EntitlementPort` 中增加「存在有效 VIP 权益即放行」的判定。
|
||||
|
||||
解锁后播放入口与下载入口会同时放行 —— 权益判定由交易模块的 `EntitlementPort` 实现提供,
|
||||
播放域与下载域都不需要改代码。金币变动一律带幂等键并写 `coin_ledger`,钱包余额与流水同事务。
|
||||
|
||||
@@ -371,6 +550,17 @@ GET /app/notices?pageIndex=1&pageSize=20
|
||||
`expire_at` 为空或未过期的公告;按 `publish_at desc, id desc` 排序。
|
||||
**表里没有数据时返回 `total=0, list=[]`(HTTP 与 code 都是成功),不是 404。**
|
||||
|
||||
#### 1.9.2a 协议公开页(匿名 HTML)
|
||||
|
||||
客户端按当前界面语言打开,不走 `{code,message,data}` 包装。正文在后台「协议设置」用 Markdown 维护,页面不另加标题。
|
||||
|
||||
| 方法 | 路径 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| GET | `/privacy/{lang}` | 隐私协议。`lang` 为 `zh` / `en` / `id` |
|
||||
| GET | `/terms/{lang}` | 服务条款。语言同上 |
|
||||
|
||||
响应 `Content-Type: text/html;charset=UTF-8`。语言或路径不在上表时 HTTP 404。库里还没有该语言时返回内置缺省文案,不返回空页。
|
||||
|
||||
#### 1.9.3 `POST /app/creator/apply`(登录)
|
||||
|
||||
```json
|
||||
@@ -432,6 +622,8 @@ GET /app/notices?pageIndex=1&pageSize=20
|
||||
| 角色分类 | PUT · DELETE | `/admin/role-categories/{id}` | `system:role-category` |
|
||||
| 系统配置 | GET | `/admin/configs` | `system:role` / `system:menu` |
|
||||
| 系统配置 | PUT | `/admin/configs` | `system:role` |
|
||||
| 协议 | GET | `/admin/legal-documents` | `system:role` / `system:menu` |
|
||||
| 协议 | PUT | `/admin/legal-documents` | `system:role` |
|
||||
| 操作日志 | GET | `/admin/operation-logs/page` · `/{id}` | `log:list` |
|
||||
| 字典 | GET | `/admin/dicts/drama-category` · `/content-status` | `drama:list` |
|
||||
|
||||
@@ -444,10 +636,10 @@ GET /app/notices?pageIndex=1&pageSize=20
|
||||
|
||||
| 方法 | 路径 | 权限点 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| GET | `/admin/dramas/page` | `drama:list` | 检索(含热门、状态筛选) |
|
||||
| GET | `/admin/dramas/page` | `drama:list` | 检索(含热门、状态、`dramaTypes[]`、`categoryIds[]` 多选筛选) |
|
||||
| GET | `/admin/dramas/{id}` | `drama:list` | 详情 |
|
||||
| POST | `/admin/dramas` | `drama:create` | 新建短剧 |
|
||||
| PUT | `/admin/dramas/{id}` | `drama:update` | 编辑短剧 |
|
||||
| POST | `/admin/dramas` | `drama:create` | 新建短剧;优先接收 `dramaTypes[]` / `categoryIds[]` |
|
||||
| PUT | `/admin/dramas/{id}` | `drama:update` | 编辑短剧;优先接收 `dramaTypes[]` / `categoryIds[]` |
|
||||
| DELETE | `/admin/dramas/{id}` | `drama:delete` | 删除短剧 |
|
||||
| POST | `/admin/dramas/{id}/submit` | `drama:review` / `drama:update` | 提交审核 |
|
||||
| POST | `/admin/dramas/{id}/approve` | `drama:review` | 审核通过 |
|
||||
@@ -456,6 +648,15 @@ GET /app/notices?pageIndex=1&pageSize=20
|
||||
| POST | `/admin/dramas/{id}/offline` | `drama:review` | 下线 |
|
||||
| GET | `/admin/dramas/{id}/review-records` | `drama:list` | 审核记录 |
|
||||
|
||||
多选字段说明:
|
||||
|
||||
- 保存优先使用 `dramaTypes[]` / `categoryIds[]`,去重并保持提交顺序;
|
||||
`drama_type` / `category_id` 写第一个值,供旧客户端与旧接口兼容。
|
||||
- 仅传 `dramaType` / `categoryId` 时保持原单值行为。
|
||||
- 列表响应返回 `dramaTypes[]`、`categoryIds[]` 与按选中顺序映射的 `categoryNames[]`;
|
||||
分类名缺失时回退 `genre`。
|
||||
- 后台与 App 过滤均使用 `(',' || column || ',') LIKE '%,value,%'` 整词匹配。
|
||||
|
||||
**剧集**
|
||||
|
||||
| 方法 | 路径 | 权限点 | 说明 |
|
||||
@@ -499,6 +700,42 @@ GET /app/notices?pageIndex=1&pageSize=20
|
||||
**上传会话归属**:`uploadId` 相当于上传凭证,`chunk` / `complete` / 进度查询都校验会话发起人,
|
||||
别人拿到 `uploadId` 也塞不进分片(`{"code":403,"message":"无权操作该上传会话"}`)。
|
||||
|
||||
**转码档位配置**
|
||||
|
||||
| 方法 | 路径 | 权限点 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| GET | `/admin/media/transcode-profile` | `episode:upload` | 读取当前配置;缺省返回四档默认值 |
|
||||
| PUT | `/admin/media/transcode-profile` | `episode:upload` | 保存配置并记录操作日志 |
|
||||
|
||||
配置保存在 `sys_config` 的 `media.transcode.profile`,JSON 结构:
|
||||
|
||||
```json
|
||||
{
|
||||
"enabled": true,
|
||||
"segmentSeconds": 6,
|
||||
"ladder": [
|
||||
{
|
||||
"quality": "360p",
|
||||
"width": 640,
|
||||
"height": 360,
|
||||
"videoBitrateKbps": 400,
|
||||
"audioBitrateKbps": 64,
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"sprite": {
|
||||
"enabled": true,
|
||||
"intervalSeconds": 1,
|
||||
"columns": 10,
|
||||
"thumbWidth": 160
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`quality` 必须唯一且非空,宽高必须为大于 0 的偶数,音视频码率必须大于 0,
|
||||
至少启用一档;`segmentSeconds` 2–10、`intervalSeconds` 1–10、`columns` 5–20、
|
||||
`thumbWidth` 120–240。非法请求返回统一错误码 `400` 且不写库。
|
||||
|
||||
### 2.3 App 用户管理(已实现)
|
||||
|
||||
| 方法 | 路径 | 权限点 | 说明 |
|
||||
@@ -507,6 +744,7 @@ GET /app/notices?pageIndex=1&pageSize=20
|
||||
| GET | `/admin/app-users/{id}` | `app-user:list` | 详情 |
|
||||
| GET | `/admin/app-users/{id}/ban-records` | `app-user:list` | 封禁与申诉记录 |
|
||||
| GET | `/admin/app-users/{id}/watch-history` | `app-user:list` | 观看流水明细(带剧名/集号,客服核对用) |
|
||||
| GET | `/admin/watch-history/page` | `watch-history:list` | 跨用户观看记录分页:keyword、userId、dramaTitle、dramaId、episodeId、source、finished、startTime、endTime |
|
||||
| PUT | `/admin/app-users/{id}/status` | `app-user:update` | 改状态:normal/limited/banned |
|
||||
|
||||
状态处置会**立即吊销该用户全部会话**并写入封禁记录,避免"封了还能用"。
|
||||
@@ -524,15 +762,18 @@ GET /app/notices?pageIndex=1&pageSize=20
|
||||
|
||||
| 方法 | 路径 | 权限点 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| GET | `/admin/comments/page` | `comment:list` | 检索评论,`status=pending` 即审核队列 |
|
||||
| GET | `/admin/comments/page` | `comment:list` | 检索评论;`status` 为空返回全部,`pending` 即审核队列 |
|
||||
| GET | `/admin/comments/{id}/audit-records` | `comment:list` | 审核留证:机审与人审的完整链路 |
|
||||
| PUT | `/admin/comments/{id}/audit` | `comment:audit` | 通过 / 驳回(带原因码与说明) |
|
||||
| DELETE | `/admin/comments/{id}` | `comment:audit` | 删除评论 |
|
||||
| GET | `/admin/reports/page` | `report:list` | 举报工单检索(状态 / 类型 / 原因) |
|
||||
| GET | `/admin/reports/page` | `report:list` | 举报工单检索(状态 / 类型 / 原因),返回举报人、剧名、集号、集标题与目标摘要 |
|
||||
| PUT | `/admin/reports/{id}/handle` | `report:handle` | 处理工单;结论成立会联动驳回被举报评论,可选择同时封禁被举报用户 |
|
||||
| GET | `/admin/sensitive-words/page` | `sensitive-word:list` | 敏感词检索 |
|
||||
| POST/PUT/DELETE | `/admin/sensitive-words[/{id}]` | `sensitive-word:update` | 维护词库,改动即时生效(服务端缓存失效重建) |
|
||||
|
||||
后台评论行除 `dramaId/episodeId` 外,还返回 `dramaTitle/episodeNo/episodeTitle`;
|
||||
剧或集已删除时对应展示字段留空。后台评论与举报的 `status` 空值均表示全部状态。
|
||||
|
||||
### 2.6 订单与权益(已实现)
|
||||
|
||||
| 方法 | 路径 | 权限点 | 说明 |
|
||||
@@ -853,6 +1094,194 @@ GET /app/notices?pageIndex=1&pageSize=20
|
||||
**筛选与错误码**:`title` 必填(1–128);`content` 最长 2000;公告不存在 → `200002 公告不存在`;
|
||||
`status` 只接受 0/1,其他值 → `400`。
|
||||
|
||||
### 2.13 运营分类管理(已实现)
|
||||
|
||||
> 「分类」是运营自定义的分组,与短剧**类型**(`/admin/drama-categories`,写 `drama_category`)是两套独立概念。
|
||||
> 分类存在 `drama_classification`,通过 `drama_classification_drama` 关联任意多部短剧。
|
||||
> 后台页面:菜单 **分类管理**(`/content/category-dramas` → `CategoryDramaView.vue`)。
|
||||
|
||||
**接口清单**(前缀 `/admin/drama-classifications`)
|
||||
|
||||
| 方法 | 路径 | 权限点 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| GET | `/admin/drama-classifications` | `drama:list` | 分类列表(带关联短剧数量) |
|
||||
| POST | `/admin/drama-classifications` | `drama:create` | 新建分类,返回新分类 id |
|
||||
| PUT | `/admin/drama-classifications/{id}` | `drama:update` | 编辑分类 |
|
||||
| DELETE | `/admin/drama-classifications/{id}` | `drama:delete` | 删除分类(级联删关联,短剧本身保留) |
|
||||
| GET | `/admin/drama-classifications/{id}/dramas` | `drama:list` | 分类下已关联的短剧(分页) |
|
||||
| GET | `/admin/drama-classifications/{id}/dramas/candidates` | `drama:list` | 尚未关联到该分类的短剧(分页,供多选) |
|
||||
| POST | `/admin/drama-classifications/{id}/dramas` | `drama:update` | 批量关联短剧,返回实际新增数量 |
|
||||
| DELETE | `/admin/drama-classifications/{id}/dramas/{dramaId}` | `drama:update` | 从分类移出短剧(幂等) |
|
||||
|
||||
**列表响应**
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"message": "ok",
|
||||
"data": [
|
||||
{
|
||||
"id": "2112807182243336193",
|
||||
"name": "本周必看",
|
||||
"sort": 1,
|
||||
"status": 1,
|
||||
"dramaCount": 12,
|
||||
"updatedAt": "2026-10-22T19:41:02"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
排序规则固定为 `sort asc, id desc`;`dramaCount` 是关联表按分类聚合的实时数量。
|
||||
时间字段为 `LocalDateTime` 的 ISO 字符串(`yyyy-MM-ddTHH:mm:ss`,秒级),前端按需替换 `T` 为空格。
|
||||
|
||||
**新建 / 编辑请求体**
|
||||
|
||||
```json
|
||||
{ "name": "本周必看", "sort": 1, "status": 1 }
|
||||
```
|
||||
|
||||
| 字段 | 必填 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `name` | 是 | 去首尾空格后保存,全局唯一;`@NotBlank` 提示「请填写分类名称」 |
|
||||
| `sort` | 否 | 新建不传时取 `现有条数 + 1`;编辑不传(null)时保持原值 |
|
||||
| `status` | 否 | `1` 启用 / `0` 停用;新建默认 `1`,编辑不传保持原值 |
|
||||
|
||||
**关联短剧**
|
||||
|
||||
```json
|
||||
POST /admin/drama-classifications/2112807182243336193/dramas
|
||||
{ "dramaIds": ["2112807182243336194", "2112807182243336195"] }
|
||||
```
|
||||
|
||||
返回 `data` 为实际新增条数(整数)。已关联的、以及不存在的 `dramaId` 会被静默跳过,不报错;
|
||||
全部跳过时返回 `0`。`dramaIds` 为空数组 → `400 请选择短剧`。
|
||||
|
||||
**短剧列表项(`GET /{id}/dramas` 与 `/dramas/candidates` 共用)**
|
||||
|
||||
```json
|
||||
{
|
||||
"total": 12,
|
||||
"list": [
|
||||
{
|
||||
"id": "2112807182243336194",
|
||||
"title": "闪婚后首富老公竟是我老板",
|
||||
"cover": "https://.../cover.jpg",
|
||||
"status": "published",
|
||||
"totalEpisodes": 80,
|
||||
"sort": 100,
|
||||
"updatedAt": "2026-10-22T18:00:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
- 查询参数:`keyword`(按 `title` 模糊匹配,可空)、`pageIndex`(默认 1)、`pageSize`(默认 10,上限 100)
|
||||
- 排序:`sort desc, id desc`
|
||||
- `status` 取值:`draft` 草稿 / `reviewing` 审核中 / `approved` 待发布 / `published` 已上线 / `offline` 已下线
|
||||
- `cover` 取自短剧 `cover_url`
|
||||
|
||||
**错误码**
|
||||
|
||||
| 场景 | 返回 |
|
||||
| --- | --- |
|
||||
| 分类名称重复(新建或改名撞已有) | `200001 分类名称已存在` |
|
||||
| 分类 id 不存在(编辑/删除/查询/关联/移出) | `200002 分类不存在` |
|
||||
| `name` 为空 | `400 请填写分类名称` |
|
||||
| `dramaIds` 为空 | `400 请选择短剧` |
|
||||
|
||||
> 所有写操作带 `@OperationLog(module = "内容管理")` 操作日志。ID 下发口径见 **§0**。
|
||||
|
||||
### 2.14 剧单管理(已实现)
|
||||
|
||||
> 剧单使用**自己的一套分类**(`drama_playlist_category`),与「分类管理」和「类型」都没有关系。
|
||||
> **没有「剧单」这一层实体**:分类直接挂短剧,关联表 `drama_playlist_category_drama(category_id, drama_id)`。
|
||||
> 后台页面:菜单 **剧单管理**(`/content/drama-playlists` → `DramaPlaylistView.vue`)。
|
||||
|
||||
**接口清单**(前缀 `/admin/drama-playlist-categories`)
|
||||
|
||||
| 方法 | 路径 | 权限点 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| GET | `/admin/drama-playlist-categories` | `drama:list` | 剧单分类列表(带短剧数量) |
|
||||
| POST | `/admin/drama-playlist-categories` | `drama:create` | 新建剧单分类,返回新分类 id |
|
||||
| PUT | `/admin/drama-playlist-categories/{id}` | `drama:update` | 编辑剧单分类 |
|
||||
| DELETE | `/admin/drama-playlist-categories/{id}` | `drama:delete` | 删除剧单分类(级联删关联,短剧本身保留) |
|
||||
| GET | `/admin/drama-playlist-categories/{id}/dramas` | `drama:list` | 分类下已关联的短剧(分页) |
|
||||
| GET | `/admin/drama-playlist-categories/{id}/dramas/candidates` | `drama:list` | 尚未关联到该分类的短剧(分页,供多选) |
|
||||
| POST | `/admin/drama-playlist-categories/{id}/dramas` | `drama:update` | 批量把短剧加入分类,返回实际新增数量 |
|
||||
| DELETE | `/admin/drama-playlist-categories/{id}/dramas/{dramaId}` | `drama:update` | 从分类移出短剧(幂等) |
|
||||
|
||||
**列表响应**
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"message": "ok",
|
||||
"data": [
|
||||
{
|
||||
"id": "2112807182243336196",
|
||||
"name": "高甜先婚后爱",
|
||||
"description": "站内投放位使用,按周更新",
|
||||
"sort": 1,
|
||||
"status": 1,
|
||||
"dramaCount": 8
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
排序规则 `sort asc, id desc`;`dramaCount` 为该分类下已关联短剧数量。
|
||||
|
||||
**新建 / 编辑请求体**
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "高甜先婚后爱",
|
||||
"description": "站内投放位使用,按周更新",
|
||||
"sort": 1,
|
||||
"status": 1
|
||||
}
|
||||
```
|
||||
|
||||
| 字段 | 必填 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `name` | 是 | 去首尾空格后保存,全局唯一;`@NotBlank` 提示「请填写剧单分类名称」 |
|
||||
| `description` | 否 | 最长 255 字符(超长 → `400 描述最多 255 个字符`);新建不传存空串,编辑不传保持原值 |
|
||||
| `sort` | 否 | 新建不传取 `现有条数 + 1`;编辑不传保持原值 |
|
||||
| `status` | 否 | `1` 启用 / `0` 停用;新建默认 `1` |
|
||||
|
||||
**关联短剧**
|
||||
|
||||
```json
|
||||
POST /admin/drama-playlist-categories/2112807182243336196/dramas
|
||||
{ "dramaIds": ["2112807182243336194"] }
|
||||
```
|
||||
|
||||
返回实际新增条数;已关联或不存在的短剧自动跳过;`dramaIds` 为空 → `400 请选择短剧`。
|
||||
`GET /{id}/dramas` 与 `GET /{id}/dramas/candidates` 的查询参数和响应结构与 **§2.13** 完全一致
|
||||
(`keyword` / `pageIndex` / `pageSize`,响应 `{ total, list }`,列表项含
|
||||
`id` / `title` / `cover` / `status` / `totalEpisodes` / `sort` / `updatedAt`)。
|
||||
|
||||
**错误码**
|
||||
|
||||
| 场景 | 返回 |
|
||||
| --- | --- |
|
||||
| 剧单分类名称重复 | `200001 剧单分类名称已存在` |
|
||||
| 剧单分类 id 不存在 | `200002 剧单分类不存在` |
|
||||
| `name` 为空 | `400 请填写剧单分类名称` |
|
||||
| `description` 超过 255 | `400 描述最多 255 个字符` |
|
||||
| `dramaIds` 为空 | `400 请选择短剧` |
|
||||
|
||||
**与「分类管理」的差异**
|
||||
|
||||
| 项 | 运营分类(2.13) | 剧单分类(2.14) |
|
||||
| --- | --- | --- |
|
||||
| 数据表 | `drama_classification` + `drama_classification_drama` | `drama_playlist_category` + `drama_playlist_category_drama` |
|
||||
| 描述字段 | 无 | 有(`description`,≤255) |
|
||||
| 列表返回 | 含 `updatedAt` | 含 `description`,不含 `updatedAt` |
|
||||
| 菜单 | 分类管理(`/content/category-dramas`) | 剧单管理(`/content/drama-playlists`) |
|
||||
| 用途 | 内容侧分组 | 运营侧投放/剧单位分组 |
|
||||
|
||||
## 3. 契约与实现状态对照
|
||||
|
||||
> 最后更新:2026-10-16(`develop` 分支)。未完成项汇总见仓库根 `README.md`「尚未完成」。
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
# 2026-10-19 K20 客户端视觉统一
|
||||
|
||||
## 基线
|
||||
|
||||
- ReelShort `develop`: `42ce1d1`
|
||||
- FruitServer `develop`: `810d9fc`
|
||||
- 只改 ReelShort 视觉与布局;不改业务逻辑、接口、后端、Web、specs、main。
|
||||
- 保留辣椒红 `AppColors.blue = #C4322A`。
|
||||
|
||||
## 统一 Token
|
||||
|
||||
新增 `lib/core/theme/app_dimens.dart`:
|
||||
|
||||
| Token | 值 |
|
||||
| --- | --- |
|
||||
| 页面左右边距 | 16 |
|
||||
| 卡片圆角 / 内边距 | 16 / 16 |
|
||||
| 内嵌块圆角 / 内边距 | 12 / 12 |
|
||||
| 胶囊圆角 | 20 |
|
||||
| caption / body / list / section / page | 12 / 14 / 15 / 16 / 20 |
|
||||
| 导航标签 | 11 |
|
||||
| 详情主标题 | 24 |
|
||||
| 主按钮高度 | 48;整页主操作 52 |
|
||||
| 点击区 | 44 × 44 |
|
||||
| 导航高度 / 图标 | 64 / 22 |
|
||||
| 进度条高度 / 圆角 | 4 / 4 |
|
||||
| 账号卡高度 / 图标 / 标签 | 64 / 18 / 11 |
|
||||
| 观看占位高度 | 114 |
|
||||
|
||||
## 改造顺序
|
||||
|
||||
1. 加 token 与主题:`AppDimens`、`AppColors.favorite`、深色唯一口径、
|
||||
按钮最小高度、OutlinedButton 主题、AppBar/状态栏样式。
|
||||
2. 新增 `AppBottomNav` / `AppBottomNavItem`,替换 home/discover/mine/player fallback。
|
||||
3. 调整账号入口卡为 64 高、18 图标、11 标签、44 点击区,并回归 K19 首屏测试。
|
||||
4. 收敛字号下限:业务文案 ≥12,导航 11;清理 9.5/10。
|
||||
5. 收敛卡片圆角与间距:页面 16、卡片 16/12、区块 16/12。
|
||||
6. 替换任务书列出的硬编码颜色;收藏红心使用 `AppColors.favorite`。
|
||||
7. 统一详情、记录、下载进度条为 4 高、4 圆角、blueSoft/white24;播放器拖动条保持金色。
|
||||
8. 统一页面/区块/列表标题层级与按钮高度,移除 mine 按钮 VisualDensity.compact。
|
||||
9. 详情加载/失败分支补返回 AppBar,封面顶部加黑色渐变,详情边距 24→16。
|
||||
10. 点赞/收藏选中态改实心图标;分类和 my tabs 补 selected 语义。
|
||||
11. HeaderPill / LoginButton / 分类 Chip 点击区补到 44。
|
||||
12. 列表页底部安全区补齐;观看记录占位高度 114,与真实卡片 padding 一致。
|
||||
|
||||
## 测试与门禁
|
||||
|
||||
- 新增 `AppDimens` token 测试与 `AppBottomNav` 组件测试。
|
||||
- 不修改既有测试断言;视觉布局变化导致测试失败时改实现。
|
||||
- `dart analyze lib test`
|
||||
- `flutter test`
|
||||
- `flutter build apk --debug`
|
||||
|
||||
## 风险与边界
|
||||
|
||||
- 账号卡升高到 64 可能重新挤压“我的”页首屏;必须保持 K19 语言设置和观看历史入口测试通过。
|
||||
- 保留页面级深色 Theme 包装以降低大范围回归风险,但根 `themeMode` 必须固定 `dark`。
|
||||
- 不碰 K21 范围:搜索、Android 返回键、播放器切票黑屏、登录后续操作、下拉刷新、
|
||||
注销状态闭环、日期/时长格式、语言上送。
|
||||
- 真机验收由用户执行,本批不提供设备侧截图或日志。
|
||||
@@ -0,0 +1,70 @@
|
||||
# 2026-10-19 K21 登录页 UI 优化
|
||||
|
||||
## 基线
|
||||
|
||||
- ReelShort `develop`: `e44fbdf`
|
||||
- FruitServer `develop`: `af28161`
|
||||
- 只改 `ReelShort/lib/pages/auth/**`、l10n 与必要的新增测试。
|
||||
|
||||
## 布局方案
|
||||
|
||||
- 用 `LayoutBuilder + SingleChildScrollView + ConstrainedBox + Center`,
|
||||
让品牌与卡片在可视区域垂直居中,键盘弹起时仍可滚动。
|
||||
- 保留 `auth-scroll`,底部 padding 继续使用 `28 + viewInsets.bottom`。
|
||||
- 返回按钮移到顶部 `Positioned + SafeArea` 浮层,不再占据内容流。
|
||||
- 内容最大宽度继续为 440,页面左右边距 16。
|
||||
- 保留主 background glow(alpha ≤0.18),新增独立 Key 的 warm glow(alpha ≤0.06)。
|
||||
|
||||
## 品牌与卡片
|
||||
|
||||
- 品牌区居中竖排:48×48 splash mark、App 名 26/w800、tagline 14/blueSoft。
|
||||
- `auth-brand`、`auth-brand-mark` 保留,mark 尺寸严格 48×48。
|
||||
- 卡片结构保持:模式切换 → 标题 25/w800 → 副标题 → 字段 → 错误胶囊 → 提交。
|
||||
- 登录继续使用 `authSubtitle`;注册使用新增 `authSignUpSubtitle`。
|
||||
- 注册态密码框下显示 12px 的 `authPasswordHint`,登录态隐藏。
|
||||
|
||||
## 字段错误与交互
|
||||
|
||||
- `AuthLogic` 增加 `fieldError`;`validate()` 记录具体错误,输入变化或切换模式时清除。
|
||||
- 邮箱/密码字段按 `fieldError` 使用 1.5px semantic error `errorBorder` /
|
||||
`focusedErrorBorder`。
|
||||
- 保留 `auth-error-capsule`、`auth-error` 的文案、圆角 12 和 alpha 0.1。
|
||||
- `_submit()` 首行 busy 短路;异步 catch 中的 `setState` 前检查 mounted。
|
||||
- 密码框 done 提交仍走同一 `_submit()`,busy 时自然忽略。
|
||||
- 提交按钮增加极淡辣椒红阴影,背景和按下色保持不变。
|
||||
|
||||
## 不可变清单
|
||||
|
||||
```text
|
||||
auth-brand-mark 48x48
|
||||
auth-card radius 20 / border outlineVariantDark / width 1
|
||||
input height 52 / radius 14 / fill bar / focus blue 1.5
|
||||
submit height 52 / radius 26 / blue / bluePressed
|
||||
auth-enter-animation <=220ms / tween 0 -> 1
|
||||
mode switch keys, hidden compatibility copy
|
||||
error capsule radius 12 / alpha 0.1 / semantic color
|
||||
small screen 320x568 + keyboard 260 scroll reachability
|
||||
```
|
||||
|
||||
## TDD
|
||||
|
||||
1. 新增测试:注册副标题、注册态密码提示、登录态不显示提示、字段错误红框。
|
||||
2. 先确认红灯。
|
||||
3. 补 `authSignUpSubtitle` 三语并生成 l10n。
|
||||
4. 调整 AuthLogic、表单字段、品牌和页面布局。
|
||||
5. 跑两份既有 Auth 测试与新增测试,再跑全量门禁。
|
||||
|
||||
## 门禁
|
||||
|
||||
```text
|
||||
dart analyze lib test
|
||||
flutter test
|
||||
flutter build apk --debug
|
||||
```
|
||||
|
||||
## 风险
|
||||
|
||||
- 居中布局与小屏滚动会互相影响,必须保持 `auth-submit` 可滚动到。
|
||||
- 字段红框不能通过 errorText 增加字段高度,否则会破坏 52 高度断言。
|
||||
- 品牌改为图片资源后仍必须保持 `auth-brand-mark` 为 48×48。
|
||||
- 不改接口、后端、Web、specs、main;真机由用户验收。
|
||||
@@ -0,0 +1,56 @@
|
||||
# 2026-10-19 K22.1 后台收尾
|
||||
|
||||
## 基线
|
||||
|
||||
- ReelShortWeb `develop`: `5494190`
|
||||
- FruitServer `develop`: `2807ae6`
|
||||
- 只改 ReelShortWeb 的后台视觉与资源引用、构建配置及无引用文件。
|
||||
- 不改接口契约、后端业务、客户端与 main。
|
||||
|
||||
## 登录页
|
||||
|
||||
1. 保留 hero 品牌 mark、kicker 与标题。
|
||||
2. 删除标题下方说明段落及 `pointDrama/pointPublish/pointAccess` 三个标签。
|
||||
3. 删除不再使用的三语 key 与 hero 列表样式。
|
||||
4. 删除注册切换、注册表单、入口事件及相关导出和文案。
|
||||
|
||||
## 品牌与图标
|
||||
|
||||
1. `brand-mark.png` 复制到 `public`,作为浏览器 favicon 与首屏 loading。
|
||||
2. 首屏背景改为 `#100C0A`,loading mark 增加圆角。
|
||||
3. 删除 `public/logo.png`、`public/favicon.ico`。
|
||||
4. 四个 env 均关闭在线图标,由 `PurgeIcons` 本地打包 Material Symbols。
|
||||
5. 构建后扫描旧前缀、`<el-icon>`、Element Plus 图标引用,并检查浏览器实际图标。
|
||||
|
||||
## Mock 清理
|
||||
|
||||
1. dev/pro/test 环境关闭 `VITE_USE_MOCK`。
|
||||
2. 删除 `mock/` 与 `viteMockServe` 配置。
|
||||
3. 全仓确认不再存在 mock 环境分支和旧 mock 图标来源。
|
||||
|
||||
## 文件删除
|
||||
|
||||
删除前分别对目标路径执行全仓 grep,确认只命中自身或已同步处理的引用:
|
||||
|
||||
- `src/assets/imgs/logo.png`
|
||||
- `src/assets/imgs/avatar.jpg`
|
||||
- `public/logo.png`
|
||||
- `public/favicon.ico`
|
||||
- `src/views/permission/CustomMenuView.vue`
|
||||
- `src/views/Login/components/RegisterForm.vue`
|
||||
- `mock/`
|
||||
|
||||
禁止删除仍被路由、菜单、组件或构建配置引用的文件。
|
||||
|
||||
## 门禁
|
||||
|
||||
- `pnpm lint:eslint`
|
||||
- `pnpm build:pro`
|
||||
- 浏览器自查登录页、后台壳、菜单、顶栏、表格工具栏与首屏 loading。
|
||||
- 控制台无 `/logo.png`、mock 或旧图标资源 404。
|
||||
|
||||
## 风险
|
||||
|
||||
- 在线图标关闭后必须确认 PurgeIcons 已本地打包全部实际使用图标。
|
||||
- 删除 mock 后需确认开发环境只依赖真实后台接口。
|
||||
- 删除文件前先处理所有引用,避免残留 import 或路由失败。
|
||||
@@ -0,0 +1,78 @@
|
||||
# 2026-10-19 K22 后台管理视觉与交互统一
|
||||
|
||||
## 基线
|
||||
|
||||
- ReelShortWeb `develop`: `5c087f4`
|
||||
- FruitServer `develop`: `b025bfd`
|
||||
- 只改 Web 视觉/交互与 FruitServer 菜单图标 SQL,不改接口、客户端、main。
|
||||
|
||||
## 图标体系
|
||||
|
||||
1. 新增 `src/constants/icons.ts`:
|
||||
- `AppIcons` 保存语义名到 `material-symbols:*-rounded` 的映射;
|
||||
- `normalizeAppIcon()` 兼容后端旧短名和历史 Iconify 名;
|
||||
- `MenuIconOptions` 供菜单管理页选择。
|
||||
2. 新增 `src/components/AppIcon`:
|
||||
- 复用现有 `Icon` 组件;
|
||||
- 默认尺寸 18,支持颜色/悬停色;
|
||||
- 全局注册 `AppIcon`。
|
||||
3. 替换 `src/components/**`、`src/views/**` 的旧图标前缀与 Element Plus 图标组件。
|
||||
4. 对 `node_modules/@iconify/json/json/material-symbols.json` 做存在性校验。
|
||||
|
||||
任务书要求的 `language/view-column/lock/chevron-down` 在当前 JSON 中没有对应的
|
||||
`*-rounded` 名,实施时使用同语义且存在的
|
||||
`translate-rounded/combine-columns-rounded/lock-person-rounded/keyboard-arrow-down-rounded`。
|
||||
|
||||
## 菜单落库
|
||||
|
||||
更新 `sql/data.sql` 与 `sql/data-phase1.sql` 中 id 1/2/3/6/15/17/20/22/24/26/32:
|
||||
|
||||
| 菜单 | 图标 |
|
||||
| --- | --- |
|
||||
| 工作台 | `material-symbols:dashboard-rounded` |
|
||||
| 内容管理 | `material-symbols:video-library-rounded` |
|
||||
| 后台管理 | `material-symbols:settings-rounded` |
|
||||
| 用户管理 | `material-symbols:group-rounded` |
|
||||
| 创作者管理 | `material-symbols:movie-edit-rounded` |
|
||||
| 内容治理 | `material-symbols:policy-rounded` |
|
||||
| 订单与权益 | `material-symbols:payments-rounded` |
|
||||
| 数据看板 | `material-symbols:monitoring-rounded` |
|
||||
| 创作者中心 | `material-symbols:video-camera-front-rounded` |
|
||||
| 运营管理 | `material-symbols:campaign-rounded` |
|
||||
|
||||
执行两份 SQL,管理员登录后请求 `/admin/auth/menus`,断言所有 icon 以
|
||||
`material-symbols:` 开头。
|
||||
|
||||
## 品牌与登录
|
||||
|
||||
- 复制客户端 `splash_mark.png` 为 `src/assets/imgs/brand-mark.png`。
|
||||
- Logo 组件展开/收起统一使用品牌 mark。
|
||||
- 删除 admin/admin123 占位、记住密码持久化、固定 `FruitShorts Studio`。
|
||||
- 记住我只保存用户名;store reset 时删除 loginInfo。
|
||||
- 表单回车提交、loading 覆盖请求与动态路由、防止重复。
|
||||
- 960 以下压缩 hero,登录卡首屏完整。
|
||||
|
||||
## 全局壳与主题
|
||||
|
||||
- 修复深色模式菜单、头部、标签关闭、主题开关、面包屑对比度。
|
||||
- body 去掉 `min-width: 980px`,补 1200/768 断点。
|
||||
- 顶栏、标签页、表格工具栏、弹窗统一 AppIcon。
|
||||
- CSS token:一组字体变量、4/6/12 圆角、`#409eff !important` 改
|
||||
`var(--el-color-primary)`,删除或合并未使用壳层选择器。
|
||||
- 用户信息读取 `userStore`,不再使用固定 avatar/Archer。
|
||||
- 清除缓存增加二次确认。
|
||||
|
||||
## 门禁与自查
|
||||
|
||||
- 静态扫描:无旧图标前缀、无 `<el-icon>`、无页面 `@element-plus/icons-vue` 引用。
|
||||
- `node_modules/@iconify/json/json/material-symbols.json` 逐个校验新图标。
|
||||
- `pnpm lint:eslint` 零错误。
|
||||
- `pnpm build:pro` 成功。
|
||||
- 浏览器自查:登录页、侧边栏展开/折叠、顶栏、标签页、浅/深色、1024/800/375。
|
||||
|
||||
## 风险
|
||||
|
||||
- 图标批量替换可能影响动态图标与右键菜单,保留 normalize 兜底。
|
||||
- 窄屏下侧栏与固定内容宽度可能冲突,优先保证内容区不裁切。
|
||||
- 登录 loading 必须覆盖动态路由生成,避免二次提交。
|
||||
- 本轮不碰表格、筛选、分页、拦截器、删除确认、rules、权限与上传校验。
|
||||
@@ -0,0 +1,32 @@
|
||||
# 2026-10-19 K23.1 后台修正
|
||||
|
||||
## 基线
|
||||
|
||||
- ReelShortWeb `develop`: `fe1ae95`
|
||||
- FruitServer `develop`: `b8676d0`
|
||||
- 只改 ReelShortWeb 视觉与交互,不改接口、后端、客户端、main。
|
||||
|
||||
## 品牌文字
|
||||
|
||||
1. 浅色菜单品牌字与浅色顶栏文字固定为 `#303133`。
|
||||
2. 处理本地持久化的旧 `inherit` 值,避免刷新后仍继承主色。
|
||||
3. 检查 Logo、ToolHeader、Breadcrumb 的实际颜色。
|
||||
|
||||
## 删除按钮
|
||||
|
||||
1. 扫描所有删除、移除、退款、回收、冻结危险按钮。
|
||||
2. 统一 `type="danger"`、表格内 `size="small"`,禁止 link/plain/text 和浅色 `danger-action`。
|
||||
3. 删除确认按钮保持 `el-button--danger` 实心红底。
|
||||
4. 调整过窄操作列,保证按钮不换行。
|
||||
|
||||
## 布局回归
|
||||
|
||||
1. 1440×900、1024×768、375×812。
|
||||
2. 检查侧栏品牌、菜单 42px 基线、popper、短剧编辑弹窗、锁屏弹窗和表格操作列。
|
||||
3. 检查顶栏、标签页、面包屑图标与文字基线。
|
||||
|
||||
## 门禁
|
||||
|
||||
- `pnpm lint:eslint`
|
||||
- `pnpm build:pro`
|
||||
- 浏览器控制台 0 error、0 404,页面无横向溢出。
|
||||
@@ -0,0 +1,41 @@
|
||||
# 2026-10-19 K23 后台视觉深化
|
||||
|
||||
## 基线
|
||||
|
||||
- ReelShortWeb `develop`: `3e8312e`
|
||||
- FruitServer `develop`: `9c96e18`
|
||||
- 只改后台视觉/交互与菜单图标种子,不改接口契约、权限和业务流程。
|
||||
|
||||
## 主色
|
||||
|
||||
1. Element Plus 主色改为辣椒红 `#c4322a`,同步 light-3/5/7/8/9 与 dark-2。
|
||||
2. 清理后台源码中的默认 Element 蓝与蓝色透明背景。
|
||||
3. 验证按钮、开关、链接、选中菜单、标签页和焦点环对比度。
|
||||
|
||||
## 菜单
|
||||
|
||||
1. 一级菜单保留 Material Symbols Rounded 图标;所有二级菜单图标置空。
|
||||
2. 开发库幂等执行后通过 `/admin/auth/menus` 检查一级图标存在、二级 icon 为空。
|
||||
3. 菜单管理只允许目录菜单选择图标,保存子菜单时强制清空。
|
||||
4. 一级菜单行高 44,二级菜单行高 40;父子文字统一落在 42px 基线。
|
||||
5. 二级菜单不渲染图标、不保留图标空位,折叠态和 popper 同样只显示文字。
|
||||
|
||||
## 短剧编辑弹窗
|
||||
|
||||
1. 680px 三区块表单:基础信息、付费设置、封面。
|
||||
2. 表单增加 model/rules,数字输入固定 180px 且控件在右。
|
||||
3. 封面改为预览卡:basename、状态、更换/移除、类型/大小校验、进度与失败提示、查看原图。
|
||||
4. 保存按钮防重复,保存中与上传中禁止关闭。
|
||||
|
||||
## 锁屏弹窗
|
||||
|
||||
1. 440px 紧凑弹窗,移除全屏入口。
|
||||
2. 重做标题、说明、内容和底部按钮。
|
||||
3. 支持回车锁定,删除调试日志。
|
||||
|
||||
## 门禁
|
||||
|
||||
- 图标名逐个对照 `node_modules/@iconify/json/json/material-symbols.json`。
|
||||
- `pnpm lint:eslint` 零错误。
|
||||
- `pnpm build:pro` 通过。
|
||||
- 浏览器自查登录页、工作台、短剧管理、锁屏;1024/375、明暗主题、控制台 0 error、0 404。
|
||||
@@ -0,0 +1,102 @@
|
||||
# K24 计划:客户端 UI 对齐设计稿
|
||||
|
||||
日期:2026-10-19
|
||||
客户端基线:`ReelShort/develop` = `b1c69e2`
|
||||
文档基线:`FruitServer/develop` = `93b2299`
|
||||
分支:`feature/flutter-k24-design-system`
|
||||
|
||||
## 一、范围
|
||||
|
||||
本批只做设计系统、3 Tab 底部导航、首页沉浸层、发现页:
|
||||
|
||||
- 设计 token:Obsidian Flare 色板、字体、间距/圆角、玻璃面板。
|
||||
- 底部导航:Home / Discover / Me 三项;My List 不再独立成 Tab,内容并入 Me 页。
|
||||
- 首页:保留 `PlayerPage(homeMode: true)` 播放链路,只替换叠加层与信息卡。
|
||||
- 发现页:品牌行、搜索、分类 chips、Continue Watching、4 个快捷入口、2 列 Trending。
|
||||
|
||||
不做:详情页、播放器、我的页、登录页的视觉重做(K25/K26);后端、Web、specs、main。
|
||||
|
||||
## 二、设计口径
|
||||
|
||||
权威来源:`docs/design/README.md` + `screens/01-home.html` + `screens/02-discover.html`。
|
||||
不采用 `DESIGN.md` 顶部 YAML 的 `#ffb4a5/#cdbdff`。
|
||||
|
||||
| 语义 | 值 |
|
||||
| --- | --- |
|
||||
| background / ink / bar | `#0B0C10` |
|
||||
| card | `#16181F` |
|
||||
| surface-elevated / raised | `#1D1E28` |
|
||||
| primary / blue | `#FF5B3D` |
|
||||
| pressed / bluePressed | `#FF4321` |
|
||||
| secondary / lavender / blueSoft | `#9278EA` |
|
||||
| gold | `#FBBF24` |
|
||||
| success | `#34D399` |
|
||||
| on-surface | `#FFFFFF` / `#E3E2E8` |
|
||||
| muted | `#A1A1AA` |
|
||||
| subtle | `#71717A` |
|
||||
| border | `rgba(255,255,255,0.08)` |
|
||||
|
||||
字体:Outfit(标题)、Plus Jakarta Sans(正文),OFL TTF 本地打包,不运行时联网。
|
||||
下载失败时保留系统字体,并在回执与 PROGRESS 标注未完成项。
|
||||
|
||||
## 三、TDD 顺序
|
||||
|
||||
1. 设计 token / 主题:先更新 `test/theme/app_theme_test.dart` 期望值与新增 token 断言,再改
|
||||
`app_colors.dart`、`app_theme.dart`、`app_dimens.dart`。
|
||||
2. GlassPanel:先写组件测试(blur、渐变、描边、圆角),再实现 `glass_panel.dart`。
|
||||
3. 3 Tab:先改导航测试为 `tab-home/tab-discover/tab-my`,覆盖选中态、映射、沉浸隐藏;
|
||||
再改 `app_bottom_nav.dart` 与 `home_view.dart`。
|
||||
4. 首页:先用现有 Player 测试保证播放/进度/收藏不回归,再新增首页结构断言
|
||||
(剧名、HOT、右侧互动栏、底部玻璃卡、Follow Series、Episodes)。
|
||||
5. 发现页:先写搜索过滤、2 列网格、Continue Watching 隐藏/显示测试,再改
|
||||
`discover_view.dart` / `discover_logic.dart` / `home_drama_grid.dart`。
|
||||
6. 回归:更新 4 Tab 与轮播挂载相关断言,保留播放、进度、收藏、举报等行为测试。
|
||||
|
||||
## 四、影响文件
|
||||
|
||||
- `lib/core/theme/app_colors.dart`
|
||||
- `lib/core/theme/app_theme.dart`
|
||||
- `lib/core/theme/app_dimens.dart`
|
||||
- `lib/core/widgets/glass_panel.dart`(新增)
|
||||
- `lib/core/widgets/app_bottom_nav.dart`
|
||||
- `lib/pages/home/home_view.dart`
|
||||
- `lib/pages/home/home_logic.dart`
|
||||
- `lib/pages/discover/discover_view.dart`
|
||||
- `lib/pages/discover/discover_logic.dart`
|
||||
- `lib/pages/discover/widgets/home_drama_grid.dart`
|
||||
- `lib/pages/player/player_view.dart`(仅 homeMode 叠加层)
|
||||
- `lib/pages/mine/mine_view.dart`(仅把 My List 区块并入 Me)
|
||||
- `pubspec.yaml`、`assets/fonts/*`
|
||||
- 相关 `test/**`
|
||||
|
||||
## 五、数据缺口与降级
|
||||
|
||||
| 设计字段 | 现有数据 | 处理 |
|
||||
| --- | --- | --- |
|
||||
| 评分 | `Drama` 无评分字段 | 隐藏,不伪造 |
|
||||
| 完结状态 | 无完结字段 | 隐藏 |
|
||||
| 榜单名次 | 无字段 | 用 `isHot` + `viewCount` 排序展示,不编名次 |
|
||||
| VIP 徽章 | 无 VIP 字段;`Episode.locked` 仅集级 | 列表不显示 VIP 徽章 |
|
||||
| Free 徽章 | `freeEpisodes` 仅详情接口 | 有值才显示 |
|
||||
| 点赞/评论数 | 互动接口无剧级计数 | 只显示图标或文案,不编数字 |
|
||||
| Continue Watching 集数/剩余时长 | `WatchProgress` 有位置/时长,无集号 | 有记录才显示,集号缺失时省略 |
|
||||
|
||||
## 六、风险
|
||||
|
||||
- 首页叠加层改动可能影响沉浸模式、PiP、下载入口与既有 tooltip;通过保留原有行为入口并跑
|
||||
`test/widget_test.dart`、`test/home/**`、`test/player/**` 控制风险。
|
||||
- 3 Tab 合并会触碰多个导航测试;只调整 Tab 数量/Key 断言,不改播放与收藏断言。
|
||||
- 新字体增加安装包体积;只打包 Regular/SemiBold/Bold 必要字重。
|
||||
- 发现页数据源仍用 `CategoryController.visibleDramas`,不新增接口。
|
||||
|
||||
## 七、门禁
|
||||
|
||||
```bash
|
||||
flutter pub get
|
||||
dart analyze lib test
|
||||
flutter test
|
||||
flutter build apk --debug
|
||||
```
|
||||
|
||||
提交作者/提交者:`Zhou Weidong <502333560@qq.com>`。
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
# K25 计划:客户端详情页 + 播放器对齐设计稿
|
||||
|
||||
日期:2026-10-19
|
||||
基线:`ReelShort/develop` = `4553606`
|
||||
分支:`feature/flutter-k25-detail-player`
|
||||
|
||||
## 一、范围
|
||||
|
||||
只改详情页与 `homeMode=false` 的播放器:
|
||||
|
||||
- 详情页:16:9 hero、玻璃导航、元数据、简介展开、CTA、选集 chips、2 列剧集卡。
|
||||
- 卡片播放器:顶部导航、9:10 视频框、进度条、三按钮行、精选评论卡。
|
||||
- `homeMode=true` 的 K24 首页沉浸 feed 保持现状。
|
||||
|
||||
不改:后端接口/模型字段、首页、发现页、我的页、登录页、`playback_session`/ticket 协议。
|
||||
|
||||
## 二、设计口径
|
||||
|
||||
沿用 K24 Obsidian Flare token、Outfit/Plus Jakarta Sans、`GlassPanel`。
|
||||
|
||||
详情页结构:
|
||||
|
||||
1. 16:9 hero(当前模型只有 `posterUrl`,作为 hero 图;无 `coverUrl` 字段)。
|
||||
2. 左侧玻璃返回,右侧分享/收藏/更多(举报在更多菜单)。
|
||||
3. 集数 pill、24px 标题、Season 副标题、viewCount、题材标签。
|
||||
4. 16px 简介卡,2 行 + More/Less。
|
||||
5. 橙色全宽 CTA + 48×48 收藏/下载,续看进度与错误重试保留。
|
||||
6. Episodes 标题 + 范围 chip(无区间数据时显示 All)+ 46×44 横向集数 chips。
|
||||
7. 2 列剧集预览卡:缩略图 96×64、Free/Coin、时长、锁态、下载/播放入口。
|
||||
|
||||
播放器结构(`homeMode=false`):
|
||||
|
||||
1. 顶部返回、剧名 + Ep.x、更多(下载/PiP)。
|
||||
2. 9:10 圆角 16 视频框,Auto-Next/1.0x pill、中心橙色播放、右侧点赞/全屏。
|
||||
3. 1.5px 进度条,白色缓冲、橙色播放、白色 thumb;保留拖动 seek。
|
||||
4. Episodes / Comments / Next Ep 三按钮;末集 Next Ep 置灰。
|
||||
5. 精选评论卡复用 `CommentController`,无评论隐藏;VIP/总评论数字段缺失时隐藏。
|
||||
|
||||
## 三、TDD 顺序
|
||||
|
||||
1. 详情 widget 测试:hero 16:9、CTA 行、简介展开、集数 chips、2 列剧集卡。
|
||||
2. 详情实现:先复用现有 `DramaDetailLogic`,只重排视图和控件。
|
||||
3. 播放器 widget 测试:卡片模式结构、三按钮行、进度条颜色/thumb、末集禁用。
|
||||
4. 播放器实现:新增卡片布局,保留原全屏 feed;复用 ticket/session/queue。
|
||||
5. 回归:PiP、票据错误、进度、收藏、下载、举报、评论、自动连播。
|
||||
|
||||
## 四、数据缺口
|
||||
|
||||
| 设计字段 | 模型状态 | 处理 |
|
||||
| --- | --- | --- |
|
||||
| coverUrl | 无(只有 posterUrl) | hero 使用 posterUrl |
|
||||
| 评分 | 无 | 隐藏 |
|
||||
| 完结状态 | 无 | 隐藏 |
|
||||
| Top 排名 | 无 | 隐藏 |
|
||||
| Trailer/4K | 无 | 隐藏 |
|
||||
| VIP | 无 | 隐藏 |
|
||||
| 剧级点赞/评论总数 | 无 | 只显示文案/已加载数量,不伪造 |
|
||||
| 场景标签 | 无 | 隐藏 |
|
||||
| 集数范围 | 无 | 显示 All chip |
|
||||
| 倍速能力 | 无播放速率接口 | 显示 1.0x,不伪造切换能力 |
|
||||
|
||||
## 五、风险
|
||||
|
||||
- 卡片播放器切换全屏时复用同一 `PageController`;只在二者之一挂载,避免控制器绑定两个 PageView。
|
||||
- 自动连播依赖 PageController 动画,卡片模式保留 PageView 作为视频底层。
|
||||
- 评论卡新增一次评论首屏请求;无评论/失败时直接隐藏,不影响播放。
|
||||
- 详情页 hero、2 列剧集卡在小屏下需自适应缩略图宽度,避免溢出。
|
||||
|
||||
## 六、门禁与 Git
|
||||
|
||||
```bash
|
||||
dart analyze lib test
|
||||
flutter test
|
||||
flutter build apk --debug
|
||||
```
|
||||
|
||||
完成后 `--no-ff` 合并回 `develop` 并 push;作者/提交者
|
||||
`Zhou Weidong <502333560@qq.com>`。真机验收由用户执行。
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# K26 计划:客户端按「移动端设计预览」校正六屏
|
||||
|
||||
日期:2026-10-19
|
||||
基线:`ReelShort/develop` = `eefabb6`
|
||||
分支:`feature/flutter-k26-mobile-preview`
|
||||
|
||||
## 一、范围
|
||||
|
||||
按本地 `/Users/jianghaifeng/Desktop/ReelShort/docs/移动端设计预览.html`
|
||||
校正六屏:首页、发现、详情、播放器、我的、登录。该文件优先于此前 Stitch screens。
|
||||
|
||||
保留 K24 的 Outfit / Plus Jakarta Sans、Provider 业务逻辑、现有接口与数据模型。
|
||||
不改后端、Web、specs、main。
|
||||
|
||||
## 二、Token
|
||||
|
||||
| 语义 | 值 |
|
||||
| --- | --- |
|
||||
| primary | `#FF5B3D` |
|
||||
| secondary | `#9278EA` |
|
||||
| background | `#0B0C10` |
|
||||
| nav | `#0D0D11` |
|
||||
| card | `#1B1C21` |
|
||||
| cardAlt | `#1C1D21` |
|
||||
| input / quick | `#25252A` / `#202126` |
|
||||
| gold card | `#201B1E` |
|
||||
| text / dim / accent | `#E6E1E3` / `#D2CDD0` / `#FFA490` |
|
||||
| border | `white 8%` |
|
||||
|
||||
圆角:卡片 10-14、按钮 9、chips 20、封面 10。
|
||||
新增紧凑字号 token(9/10/11/12/13/14/15/18/20)与按钮高度 token(28/32/34/40/44)。
|
||||
|
||||
## 三、六屏
|
||||
|
||||
1. 首页:剧名 + 搜索/菜单;Like/Comment/Share/Favorite 四互动;底部玻璃卡
|
||||
(tags、第 x/共 y 集、13px 标题、34px 追剧/选集);去掉 HOT/Season/Follow。
|
||||
2. 发现:Logo + 发现 + 搜索/头像;36px 搜索框;分类 chips;52×66 Continue Watching;
|
||||
4 个 62px 快捷入口;热门短剧标题 + 2 列封面高 120 网格。
|
||||
3. 详情:190px hero + 28px 返回;N 集、18px 标题、11px 简介、40px 开始观看、选集 chips;
|
||||
收藏/下载/举报收进更多;删除统计行、预览卡与底部 Tab。
|
||||
4. 播放器:全屏;46px 顶栏;中心 52px 播放 + 1.0x;3px 进度;32px 选集/评论/下一集;
|
||||
一条精选评论卡;无右侧互动栏;下载/PiP/互动收进更多。
|
||||
5. 我的:顶部 Logo + 我的 + 搜索/头像;48px 用户行;金币卡;Continue Watching;
|
||||
历史/收藏/喜欢;语言行;底部 3 Tab。
|
||||
6. 登录:64px 渐变 Logo + 水果短剧 + 副标题;Google/手机号/邮箱三个 44px 入口;
|
||||
Google/手机号置灰提示即将开放,邮箱进入 K21 表单;底部法律文案。
|
||||
|
||||
## 四、TDD 顺序
|
||||
|
||||
1. Token / AppDimens / GlassPanel 测试。
|
||||
2. 首页 overlay 结构与底部导航测试。
|
||||
3. 发现页搜索、Continue Watching、快捷入口、2 列网格测试。
|
||||
4. 详情页 190px hero、40px CTA、选集 chips 测试。
|
||||
5. 播放器全屏顶栏、三按钮、精选评论测试。
|
||||
6. 我的页用户行、金币卡、Continue Watching、语言行测试。
|
||||
7. 登录入口与邮箱二级表单测试。
|
||||
8. 回归播放、进度、收藏、下载、PiP、票据错误、评论与导航。
|
||||
|
||||
## 五、数据缺口
|
||||
|
||||
- 剧级点赞/评论数、已完结、Top 排名、VIP、评分、场景标签无模型字段:隐藏。
|
||||
- Continue Watching 仅有 `episodeId/position/duration`;集号能从剧集列表匹配时显示。
|
||||
- 金币余额与 Google/手机号登录后端未就绪:金币显示 0,Google/手机号入口提示即将开放。
|
||||
- 剧集时长只有 `durationSec`;缺失则不显示。
|
||||
|
||||
## 六、风险
|
||||
|
||||
- 六屏同时调整会触碰大量既有 widget 测试;只改视觉/布局与入口,不改业务逻辑。
|
||||
- 登录页改成入口页后,K21 邮箱表单测试需要先点击邮箱入口;表单本身与认证逻辑保持不变。
|
||||
- 播放器仍复用 ticket/PlaybackSession/PlaybackQueue;只替换非首页的 overlay。
|
||||
- 卡片圆角与按钮高度变化可能影响小屏布局,用 320×568、360×720、390×844 回归。
|
||||
|
||||
## 七、门禁
|
||||
|
||||
```bash
|
||||
dart analyze lib test
|
||||
flutter test
|
||||
flutter build apk --debug
|
||||
```
|
||||
|
||||
完成后 `--no-ff` 合并回 `develop` 并 push;作者/提交者
|
||||
`Zhou Weidong <502333560@qq.com>`。真机验收由用户执行。
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
# 2026-10-20 K28 客户端 UI 重构(按简图)
|
||||
|
||||
> 来源:用户 2026-10-19 提供的 5 屏 + 4 面板手绘简图。
|
||||
> 原则:先出 UI,再划分功能任务;本批不改后端契约、不伪造接口、不放假按钮的“可用”承诺。
|
||||
> 设计语言沿用现有深色主题(Obsidian Flare),简图只定结构与层级。
|
||||
|
||||
## 一、信息架构
|
||||
|
||||
底部 4 Tab:
|
||||
|
||||
| Tab | 页面 | 说明 |
|
||||
|---|---|---|
|
||||
| 首页 | `home` | 浏览型首页(Banner + 继续观看 + 热门漫剧) |
|
||||
| 剧场 | `theater` | 分类 + 语言筛选 + 两列剧库 + 搜索 |
|
||||
| 创作 | `create` | AI 制作 / 上传发布 两个入口 |
|
||||
| 我的 | `mine` | 账户、金币、会员、菜单 |
|
||||
|
||||
播放页改为**推入式全屏页**(保留现有 `PlayerPage` 双模式能力),从首页 Banner/卡片、“继续观看”、剧场卡片、选集进入。
|
||||
|
||||
## 二、分屏口径
|
||||
|
||||
### 01 首页
|
||||
|
||||
- 顶栏:搜索框(占满剩余宽度)+ 头像入口 + 星期文案(周一…周日)。
|
||||
- 频道 Tab:`热门 / 免费 / 新剧 / 榜单`,选中项主色下划线/胶囊;`榜单` 跳剧场榜单区。
|
||||
- Hero Banner:封面图、剧名(大字号 Outfit)、一句文案、底部页码点;自动轮播 + 手势切换。
|
||||
- 继续观看:标题行 + 「查看全部」;卡片含封面、剧名、`第 n 集 · 还剩 m 分钟`、播放按钮。
|
||||
- 热门漫剧:标题行 + 「查看更多」;两列卡片,封面 + 标题 + 题材 + `免费/集数` + 热度。
|
||||
- 无数据时用现有 `EmptyState`;下拉刷新可选(本批可不加)。
|
||||
|
||||
### 02 剧场
|
||||
|
||||
- 顶栏:搜索框 + 头像(与首页一致)。
|
||||
- 分类 chips:全部 + 服务端分类;语言 chips:全部语言 / 中文 / 印尼语 / 马来语 / 英语。
|
||||
- 两列剧卡:封面(原图比例铺满)、标题、题材、`免费` 角标、集数、热度。
|
||||
- 搜索:保留现有搜索输入与结果页;点击页面失焦。
|
||||
- 下拉刷新保留。
|
||||
- 语言筛选:当前接口未下发 `language`,本批只做 UI 选中态,不做数据过滤;在任务清单标注为后端缺口。
|
||||
|
||||
### 03 创作
|
||||
|
||||
- 标题「创作」+ 副标题「让故事成为漫剧」。
|
||||
- 卡 1「AI 制作」:从故事或想法开始,右侧箭头。
|
||||
- 卡 2「上传发布」:发布已完成的漫剧,右侧箭头。
|
||||
- 入口行为:本批统一进入「敬请期待 / 入驻申请」的诚实占位页,不做假上传、假 AI 生成。
|
||||
- 后续功能任务单列(见第五节)。
|
||||
|
||||
### 04 我的
|
||||
|
||||
- 头像 + 昵称 + 签名/身份文案 + 右侧箭头。
|
||||
- 三快捷入口:收藏/追剧、观看历史、本地下载。
|
||||
- 金币卡:`金币余额` + 数值 + `充值` 按钮(跳现有钱包/充值页)。
|
||||
- 会员卡:`开通会员,解锁更多精彩内容`(跳现有 VIP 页;无 C 端商品时展示“暂未开放”)。
|
||||
- 菜单:我的作品、创作者中心、消息通知(支持红点)、设置、帮助与反馈。
|
||||
- 未登录:头像区显示登录入口,金币/会员/菜单保持可点但需登录。
|
||||
|
||||
### 05 竖屏播放
|
||||
|
||||
- 顶栏:返回、更多(右上)。
|
||||
- 右侧互动 rail:点赞(含数量)、评论(含数量)、收藏、分享。
|
||||
- 底部:剧名、`第 n 集`、题材标签 + `关注`、简介、进度条 + `当前/总时长`、`选集`、`更多`。
|
||||
- 中心播放按钮:仅暂停时显示(已定口径)。
|
||||
- 清屏:保留现有清屏/退出清屏与“清屏状态跨集保持”。
|
||||
|
||||
### 面板
|
||||
|
||||
1. **选集**:标题「选集」+ 剧名 + `共 n 集` + 关闭;6 列等宽网格,当前集主色,锁定集显示锁图标,点击切集。
|
||||
2. **评论**:标题 `评论 (n)` + 关闭;列表项(头像、昵称、时间、内容、点赞数、回复);底部输入框 + 发送。
|
||||
3. **更多操作**:倍速(当前值)、清晰度(自动)、下载到本地、文字大小、投诉;行尾箭头/当前值。
|
||||
4. **内容解锁**:金币解锁、看广告解锁、查看会员内容三条;底部说明「具体方式以作品而定」;仅展示可行入口,不可用项明确禁用/说明。
|
||||
|
||||
## 二·五 视觉风格 v2(浅色暖橙,2026-10-20 用户指定)
|
||||
|
||||
> 用户提供两张参考图(剧场页、竖屏剧集页),以此为准;K28 各屏不再沿用深色主题。
|
||||
|
||||
### 色板
|
||||
|
||||
| 用途 | 值 |
|
||||
|---|---|
|
||||
| 页面背景 | `#FFF8F0`(顶部带 `#FFE9D6` 暖色渐变) |
|
||||
| 卡片/弹层 | `#FFFFFF` |
|
||||
| 主色(按钮/选中/图标) | `#FF7A1A` |
|
||||
| 主色渐变(中央按钮) | `#FF9A3D → #FF6A00` |
|
||||
| 主文字 | `#1F1B16` |
|
||||
| 次要文字 | `#8C837B` |
|
||||
| 弱文字/占位 | `#B3AAA1` |
|
||||
| 分割线/描边 | `#F0E4D6` |
|
||||
| 粉色角标底 | `#FFE3EC`(文字 `#FF6A8A`) |
|
||||
| 深色角标(锁定数) | `#33000000` + 白字 |
|
||||
|
||||
### 组件
|
||||
|
||||
- 圆角:卡片 16、封面 16、弹层 20、chips 999(胶囊)、按钮 999。
|
||||
- 阴影:`0x14FF8A3D`,blur 18,y 6;卡片不使用重描边。
|
||||
- 分类 chips:选中为橙色实心 + 白字;未选中为白底 + 深色字,间距 10。
|
||||
- 剧卡:大封面(原图比例或 3:4)、左上「桃花源」粉色胶囊、右上锁图标 + 数量、封面右下「全 24 集 / 大结局」米色胶囊、标题 15–16 粗体、副行「更新至 18 集 · 09-04」12px 灰字、右下橙色圆形「+」。
|
||||
- 底部导航:白/米色毛玻璃,**保持 4 槽(首页 / 剧场 / 创作 / 我的)**,选中图标与文字为橙色;参考图中间的橙色「+」不实现。
|
||||
- 播放/剧集页:大标题 24 粗体 + 橙点、副标题 14 灰、右侧「…」与圆形按钮;Hero 大图 20 圆角 + 右上题材胶囊 + 分页点;下方横向剧集卡(第 01 集 初遇 / 更新中胶囊)。
|
||||
|
||||
### 落地方式
|
||||
|
||||
1. 先改 `AppColors/AppTheme/AppDimens` 全局 token,使现有组件整体切换为浅色暖橙。
|
||||
2. `AppBottomNav` 保持 4 项(首页/剧场/创作/我的),只做视觉换肤;不新增中央按钮/`nav-center-action`。
|
||||
3. K28-A1 先完成结构;样式统一由 K28-S 批次落地,后续 A2/B/C 直接使用新 token。
|
||||
|
||||
## 三、复用与约束
|
||||
|
||||
- 底部导航复用 `AppBottomNav`(需支持 4 项)。
|
||||
- 主题色/字号沿用 `AppColors/AppDimens`;标题 Outfit、正文 Plus Jakarta Sans。
|
||||
- 所有新增文案走 l10n(en/zh/id),禁止硬编码。
|
||||
- 所有手写 Dart 首行 `// Author: fruit.com.cn`;public 类/方法有文档注释。
|
||||
- Key 约定:`tab-home` / `tab-theater` / `tab-create` / `tab-mine`;`home-channel-*`;`theater-language-*`;`create-ai` / `create-upload`;`mine-wallet` / `mine-vip`;播放面板沿用 `player-episodes` / `player-comments` / `player-more-*` / `player-unlock-*`。
|
||||
- 单文件 ≤500 行:现有 `player_view.dart` 已超限,本批允许拆文件,不新增超大文件。
|
||||
|
||||
## 四、实施批次(先 UI)
|
||||
|
||||
| 批次 | 范围 | 验收 |
|
||||
|---|---|---|
|
||||
| K28-A | 4 Tab IA + 首页 + 剧场 | 4 Tab 可切换;首页/剧场结构与简图一致;既有播放/详情链路可达;`dart analyze` 零告警 + `flutter test` 全过 |
|
||||
| K28-B | 创作 + 我的 | 两个新页面结构与简图一致;金币/会员/菜单入口可达;未登录态正确 |
|
||||
| K28-C | 竖屏播放 UI + 四面板 | 播放页结构与简图一致;四面板可开合;选集切集/评论/倍速/清屏回归通过 |
|
||||
| K28-D | 回归与门禁 | l10n 三语齐全;全部测试通过;APK 构建成功;PROGRESS 留痕 |
|
||||
|
||||
## 五、UI 之后的功能任务(待排期)
|
||||
|
||||
1. 首页频道真实数据(热门/免费/新剧/榜单)与 Banner 数据补齐。
|
||||
2. 剧场语言筛选:后端 VO 下发 `language` 后再接真实过滤。
|
||||
3. 创作:AI 制作与上传发布需 C 端创作接口/资质(当前契约缺口,见 INBOX 顶部)。
|
||||
4. 金币充值:支付通道接入前保持入口隐藏或明确“暂未开放”。
|
||||
5. 会员:C 端会员商品/订阅接口缺失。
|
||||
6. 看广告解锁:需要广告平台账号、广告位 ID 与发奖校验接口。
|
||||
7. 播放清晰度:接口仅下发 `AUTO`,多清晰度需后端补齐。
|
||||
8. 文字大小:需全局字号偏好与持久化。
|
||||
|
||||
## 六、风险 / 待确认
|
||||
|
||||
- 简图为浅色线稿,实际落地为现有深色主题;如需要浅色版需另出视觉稿。
|
||||
- 「创作」两个入口在后端能力缺失时只做诚实占位,不做假流程。
|
||||
- 首页频道与周几文案涉及新增 l10n key,需三语翻译。
|
||||
@@ -0,0 +1,44 @@
|
||||
# UX 改造计划:红果式 3 Tab + 剧场九宫格 + 我的页减法
|
||||
|
||||
日期:2026-10-20
|
||||
仓库:`C:\work\ReelShort`(Flutter)
|
||||
分支:`feature/ux-theatre-3tabs`(基线 `develop`)
|
||||
|
||||
## 一、范围
|
||||
|
||||
- 底部导航 4 → 3:推荐(播放)/ 发现(剧场)/ 我的。
|
||||
- 删除独立榜单 tab,榜单内容并入发现页。
|
||||
- 发现页改为剧场:顶部搜索框 + 分类九宫格 + 榜单区块 + 全部剧目网格。
|
||||
- 点击分类进入该分类剧目列表页。
|
||||
- 我的页只保留:继续观看、我的追剧、观看历史、下载、金币钱包、会员、设置。
|
||||
- 移除手动语言切换,App 跟随系统(默认印尼语/英语,系统中文仍可解析)。
|
||||
- 保留首页沉浸式上下滑播放。
|
||||
|
||||
## 二、实施顺序
|
||||
|
||||
1. 导航 4 → 3,删除 RankingPage 路由。
|
||||
2. 发现页重构:分类九宫格、分类剧目页、榜单区块、搜索;删除语言筛选与发现页续看。
|
||||
3. 我的页重构:删除语言行、内嵌历史/收藏/点赞列表、账号卡、通知入口;新增设置页承载通知与账号。
|
||||
4. 清理死代码:RankingPage、LocaleController 手动选择、CategoryController 筛选态、DiscoverLogic 续看/语言筛选。
|
||||
5. 更新测试与 l10n 断言,跑 `dart analyze lib test` + `flutter test`。
|
||||
6. `--no-ff` 合并回 `develop` 并 `git push origin develop`。
|
||||
|
||||
## 三、风险与对策
|
||||
|
||||
- 玩家页从 My/Discover 返回依赖 action 枚举:保留 home/discover/resume 必要动作,删除 watchlist/detail 等不再产生的动作。
|
||||
- 设置页承载账号卡与通知,避免删除入口后留下死路由。
|
||||
- 分类九宫格点击后进入独立列表页,避免全局筛选态残留。
|
||||
- 测试大量断言 4 Tab/语言行/内嵌列表;按新 UX 重写对应断言,不改播放链路。
|
||||
- 参数 ≤5:Discover/My 页使用 callbacks 聚合对象,页面 constructor 保持 ≤5 参数。
|
||||
|
||||
## 四、门禁
|
||||
|
||||
```bash
|
||||
dart analyze lib test
|
||||
flutter test
|
||||
```
|
||||
|
||||
## 五、待确认
|
||||
|
||||
- 系统语言为中文时是否仍显示中文:本计划保留系统中文解析,仅移除手动切换入口。
|
||||
- 通知功能保留但收进设置页;若要求彻底删除通知功能,需要另行删除 Notice 客户端链路。
|
||||
@@ -0,0 +1,26 @@
|
||||
# K100 后台剧集多选上传(分片 + 断点续传 + 批量建集)
|
||||
|
||||
> 日期:2026-10-21
|
||||
> 范围:仅 `ReelShortWeb`;不改 FruitServer 后端、不改 ReelShort 客户端、不改接口契约。
|
||||
|
||||
## 目标
|
||||
|
||||
剧集管理页「批量上传」:多选视频 → 队列分片上传(文件并发 2 / 分片并发 3)→ 单项与字节加权总进度 → 失败隔离/可重试 → localStorage 断点续传 → 上传完成后批量创建分集。
|
||||
|
||||
## 步骤
|
||||
|
||||
1. 从 `develop` 拉 `feature/episode-batch-upload`。
|
||||
2. 新建 `src/views/contentManagement/upload/uploadSessions.ts`:`reel_upload_sessions` 读写/过滤/清理。
|
||||
3. 新建 `useUploadQueue.ts`:状态机、文件并发泵、进度加权、pause/retry/remove、complete 写回 assetId/url、挂接 session。
|
||||
4. 新建 `UploadTaskRow.vue` / `BatchUploadDialog.vue` / `CreateEpisodesDialog.vue`。
|
||||
5. `EpisodeManagementView.vue` 仅加「批量上传」入口,保留原单文件上传。
|
||||
6. `zh-CN.ts` / `en.ts` 补齐文案;白名单 mp4/mov/mkv/webm;超限标红不入队;`beforeunload`。
|
||||
7. 门禁:`pnpm lint:eslint` + `pnpm build:dev`。
|
||||
8. 提交 `feat(admin): 剧集多选分片上传与断点续传` → `--no-ff` 合回 `develop` 并 push。
|
||||
|
||||
## 风险 / 待确认
|
||||
|
||||
- 续传需用户重新选择本地文件才能匹配;换机器/改名无法自动续传(产品已接受)。
|
||||
- 暂停不 abort 进行中分片,已在传任务会跑完再停派发。
|
||||
- `EpisodeManagementView.vue` 存量已超 500 行,本轮只加入口,不整体拆旧编辑器。
|
||||
- 手工联调(多选/暂停/刷新续传/建集)由 PM 在 8080+3005 复核,本轮不操作真机、不 kill 已运行端口。
|
||||
@@ -0,0 +1,46 @@
|
||||
# K85 收藏数 / 评论数实时更新实施计划
|
||||
|
||||
## 目标
|
||||
|
||||
修复收藏数、评论数在列表、播放页和详情页不实时更新的问题,并让服务端收藏计数与关系数据保持一致。
|
||||
|
||||
## 前置结论
|
||||
|
||||
根因已由任务书确认,不再重复排查:
|
||||
|
||||
- 收藏关系写入/删除时没有同步维护 `drama.favorite_count`。
|
||||
- 客户端首页收藏未复用现有计数增量逻辑。
|
||||
- 评论面板关闭后没有重新查询评论总数。
|
||||
- 详情页收藏切换后没有本地收藏数增量。
|
||||
|
||||
## A. FruitServer
|
||||
|
||||
1. `DramaService` 新增原子收藏计数调整方法,参考现有点赞计数实现。
|
||||
2. `FavoriteService` 在收藏、取消收藏、批量取消时按实际删除/插入结果同步增减,避免重复操作导致漂移。
|
||||
3. 新增一次性 `sql/backfill_favorite_count.sql`,从 `user_favorite` 回填现有收藏数,不在应用启动时自动执行。
|
||||
4. `AppCommentController` 新增匿名评论总数接口,复用 `CommentService.countByDrama`。
|
||||
5. 补收藏同步维护、批量取消、评论计数接口测试。
|
||||
6. 门禁:JDK 21 下完整 `mvn test`。
|
||||
|
||||
## B. ReelShort
|
||||
|
||||
1. `CommentApi` / `CommentRepository` 新增评论总数查询,兼容数字和字符串两种 Long 返回。
|
||||
2. 播放器统一维护按剧评论数缓存;评论面板关闭后刷新,失败保留旧值。
|
||||
3. 首页 feed 收藏复用 `_toggleSave`,与全屏播放页共用收藏增量更新。
|
||||
4. 详情页收藏成功后本地显示收藏数增量,失败回滚,不修改 `Drama` 模型。
|
||||
5. 补评论计数解析、收藏增量、首页 rail 刷新测试。
|
||||
6. 门禁:`dart analyze lib test` 零告警、`flutter test` 全过。
|
||||
|
||||
## 风险与处理
|
||||
|
||||
- 并发收藏切换可能造成计数竞争:服务端使用 SQL 原子自增/自减,减法不低于 0。
|
||||
- 历史收藏数全为 0:提供一次性回填脚本,由验收环境显式执行。
|
||||
- 评论面板取消打开时仍刷新一次计数,用于获取匿名新增评论带来的总数变化;查询失败静默保留旧值。
|
||||
- 详情页只在收藏状态确实变化时调整本地增量,避免重复点击造成累计误差。
|
||||
|
||||
## 合并与验收
|
||||
|
||||
- FruitServer:`fix/favorite-comment-count`,`--no-ff` 合回 `develop` 并推送。
|
||||
- ReelShort:`fix/interaction-count-refresh`,`--no-ff` 合回 `develop` 并推送。
|
||||
- 作者统一 `Zhou Weidong <502333560@qq.com>`。
|
||||
- 不修改 specs 仓库,不执行真机安装;完成后等待用户验收。
|
||||
@@ -0,0 +1,59 @@
|
||||
# K86 评论面板按参考图重做实施计划
|
||||
|
||||
## 目标
|
||||
|
||||
仅调整 ReelShort 客户端评论面板和评论行视觉,使顶部标题、评论元信息、回复入口和底部输入区接近参考图;不修改后端接口、控制器数据逻辑或评论业务能力。
|
||||
|
||||
## 范围
|
||||
|
||||
- `lib/pages/player/widgets/drama_comments_sheet.dart`
|
||||
- `lib/pages/player/widgets/comment_tile.dart`
|
||||
- `test/comment/drama_comments_sheet_test.dart`
|
||||
- 必要的 PROGRESS 留痕
|
||||
|
||||
## 实现计划
|
||||
|
||||
1. 顶部栏
|
||||
- 删除拖拽把手和剧名行。
|
||||
- 左侧放置 44x44 向下箭头,保留 `player-comments-close`,点击关闭面板。
|
||||
- 中间使用现有 `commentsWithCount` / `comments`,16px、w600、`AppColors.onSurface`,保留 `comment-count-label`。
|
||||
- 右侧留空,保持标题视觉居中。
|
||||
|
||||
2. 评论行
|
||||
- 头像改为 40px,回复行 28px;文字区左间距 12。
|
||||
- 昵称 12px muted、正文 16px cream、行高 1.4。
|
||||
- 时间与回复入口组合为灰色元信息行,时间继续使用 `formatLocalizedDateTime`。
|
||||
- 删除点赞按钮、心形图标与数字展示,控制器点赞逻辑保留但不绑定 UI。
|
||||
- 举报/删除入口改为右上角 18px 的更多图标,保留 `comment-menu-{id}` 和现有菜单行为。
|
||||
- 去除行间分隔线,调整上下留白为 12/14。
|
||||
|
||||
3. 回复
|
||||
- 展开/收起回复使用 12px muted 文本,前面增加 16x1 的 border 色短横线。
|
||||
- 展开后的回复沿用相同评论行样式,并通过 40px 头像宽度加 12px 间距与正文对齐。
|
||||
|
||||
4. 输入区
|
||||
- 输入框改为 44px 高、22px 圆角、`AppColors.commentInput` 底色。
|
||||
- 保留登录提示、回复态 banner、橙色 38px 发送按钮及 `comment-post` Key。
|
||||
- 保持现有键盘避让和面板高度 clamp。
|
||||
|
||||
5. 状态与交互
|
||||
- 保留加载、错误、空态、待审核、展开回复、翻页、回复、删除、举报和发送逻辑。
|
||||
- 保留登录闸、自动聚焦和登录后输入框聚焦行为。
|
||||
|
||||
## 测试
|
||||
|
||||
- 删除依赖 `comment-like-10` 的点赞展示用例。
|
||||
- 断言不存在任何 `comment-like-*` 按钮或心形计数。
|
||||
- 断言 `player-comments-close` 可关闭面板。
|
||||
- 断言标题居中、字号和字重符合规格。
|
||||
- 断言头像、正文、元信息、回复入口、输入框与发送按钮尺寸。
|
||||
- 保持既有评论分页、登录、发布、展开回复、删除和举报用例通过。
|
||||
|
||||
## 门禁与 Git
|
||||
|
||||
- ReelShort 从 `develop` 创建 `fix/comments-sheet-style`。
|
||||
- 提交:`fix(player): 评论面板按参考图重做`。
|
||||
- 作者:`Zhou Weidong <502333560@qq.com>`。
|
||||
- `--no-ff` 合回 ReelShort `develop` 并 push,不使用 force push,不执行 `git add -A`。
|
||||
- 门禁:`dart analyze lib test` 零告警、`flutter test` 全过。
|
||||
- 不安装真机;完成后等待用户验收。
|
||||
@@ -0,0 +1,46 @@
|
||||
# K86.21 评论输入浮层稳定定位实施计划
|
||||
|
||||
## 目标
|
||||
|
||||
修复 Android 收起评论输入键盘时,输入浮层因键盘收起动画中的瞬时 inset 被逐帧 `max` 抬高而向上跳动的问题。评论列表面板、输入内容和关闭规则保持不变。
|
||||
|
||||
## 根因
|
||||
|
||||
- `CommentComposerSheet.build` 每次重建都用 `math.max` 累积当前 effective keyboard inset。
|
||||
- IME 收起动画期间可能出现高于稳定值的瞬时 inset,累计后永久抬高 `_pinnedKeyboardInset`。
|
||||
- 面板布局随后按更高的 pinned 值重新定位,造成输入浮层向上跳一小段。
|
||||
|
||||
## 范围
|
||||
|
||||
- ReelShort `lib/pages/player/widgets/comment_composer_sheet.dart`
|
||||
- ReelShort `test/comment/drama_comments_sheet_test.dart`
|
||||
- FruitServer `docs/plans/PROGRESS.md`
|
||||
|
||||
## 实现计划
|
||||
|
||||
1. 移除 `build` 中逐帧更新 `_pinnedKeyboardInset` 的逻辑,新增键盘可见状态和 80ms 稳定捕获 Timer。
|
||||
2. effective inset 从 0 变为正数时启动 Timer;Timer 触发时只读取一次当前 inset,并取整后写入 pinned。
|
||||
3. 键盘持续可见期间,后续 inset 变大或变小都不更新 pinned;inset 归零只取消 Timer 并重置可见状态,下一次弹起可重新捕获。
|
||||
4. pinned 上限为屏幕高度的 60%;非有限值、负值或超过上限的异常值忽略,保证 pinned 不小于 0。
|
||||
5. 保持 `Positioned(bottom: 0)`、白色 Material 铺到屏幕底部及 `Padding(bottom: pinned)` 布局,不使用位移或回落动画。
|
||||
6. 返回键/IME 下箭头只收键盘;透明外部点击和发表成功仍为关闭入口。
|
||||
|
||||
## 测试计划
|
||||
|
||||
- 先新增失败测试:2200 高视口模拟 `0 → 1100(稳定)→ 1150(收起瞬时峰值)→ 600 → 0`,断言 1100 捕获后输入浮层 top、bottom、高度均保持不变。
|
||||
- 运行旧实现确认红灯,记录实际偏移。
|
||||
- 新实现后运行定向测试、完整评论面板测试文件、`dart analyze lib test` 和全量 `flutter test --no-pub`。
|
||||
|
||||
## 风险与处理
|
||||
|
||||
- 80ms 可能早于极慢 IME 动画结束;按任务要求采用固定稳定窗口,不在后续可见阶段继续累计。
|
||||
- 超过屏幕 60% 的异常值被忽略后,需等下一次 0 → 正数弹起再捕获,避免错误定位。
|
||||
- Timer 在 dispose 时取消,避免 Overlay 关闭后回调访问已卸载 State。
|
||||
|
||||
## Git
|
||||
|
||||
- ReelShort 从 `develop` 创建 `fix/composer-stable-inset`。
|
||||
- 提交:`fix(player): 固定评论输入浮层位置避免收键盘跳动`。
|
||||
- 作者:`Zhou Weidong <502333560@qq.com>`。
|
||||
- `--no-ff` 合回 `develop` 并 push,不使用 force push,不执行 `git add -A`。
|
||||
- FruitServer 追加 PROGRESS 留痕;不安装真机,完成后等待用户验收。
|
||||
@@ -0,0 +1,45 @@
|
||||
# K86.22 评论输入浮层去除底部安全区位移实施计划
|
||||
|
||||
## 目标
|
||||
|
||||
修复 Android 收起评论输入键盘后,`SafeArea` 引入底部手势条 padding,导致输入区上移约 48px 的问题。输入区位置只由固定 `_pinnedKeyboardInset` 决定,键盘收起前后保持像素级一致。
|
||||
|
||||
## 根因
|
||||
|
||||
- 输入面板 Material 内使用 `SafeArea(top: false)`。
|
||||
- 键盘可见时系统导航栏被 IME 覆盖,`MediaQuery.padding.bottom` 为 0。
|
||||
- 键盘收起后手势条 padding 恢复,`SafeArea` 自动追加约 48px 底部内边距,把输入区顶高。
|
||||
- K86.19 的白色实底和固定 12px 内容内边距本身正常,问题仅来自额外安全区。
|
||||
|
||||
## 范围
|
||||
|
||||
- ReelShort `lib/pages/player/widgets/comment_composer_sheet.dart`
|
||||
- ReelShort `test/comment/drama_comments_sheet_test.dart`
|
||||
- FruitServer `docs/plans/PROGRESS.md`
|
||||
|
||||
## 实现计划
|
||||
|
||||
1. 面板 `SafeArea` 设置 `bottom: false`,不再消费 `MediaQuery.padding.bottom`。
|
||||
2. 保持 `Positioned(bottom: 0)`、白色 Material 铺到屏幕底部、顶部圆角 20。
|
||||
3. 键盘区域继续由内部 `Padding(bottom: _pinnedKeyboardInset)` 决定,内容区底部保持固定 12。
|
||||
4. 透明外部点击或发表成功仍为关闭入口;返回键/IME 下箭头只收键盘。
|
||||
|
||||
## 测试计划
|
||||
|
||||
- 先新增失败测试:视口 390×844,键盘弹起时 `viewInsets.bottom=180`、`padding.bottom=0`,记录输入框全局矩形。
|
||||
- 收起键盘时同时设置 `viewInsets.bottom=0`、`padding.bottom=48`,断言输入框 top、bottom、height 偏移均小于 0.1。
|
||||
- 旧实现预期因 SafeArea 多出 48px 而失败;修复后运行完整评论面板测试、静态分析和全量 Flutter 测试。
|
||||
|
||||
## 风险与处理
|
||||
|
||||
- 关闭底部 SafeArea 后,输入内容依赖固定 12px 底部内边距;与 K86.19 白色实底填充一致,不再叠加系统手势条。
|
||||
- 面板本身仍延伸到屏幕底部,视觉圆角和白底不受影响。
|
||||
- 不改 KeyboardInsetNotifier、pinned 稳定捕获、关闭规则或评论列表布局。
|
||||
|
||||
## Git
|
||||
|
||||
- ReelShort 从 `develop` 创建 `fix/composer-safearea`。
|
||||
- 提交:`fix(player): 去除评论输入面板安全区导致的收键盘位移`。
|
||||
- 作者:`Zhou Weidong <502333560@qq.com>`。
|
||||
- `--no-ff` 合回 `develop` 并 push,不使用 force push,不执行 `git add -A`。
|
||||
- FruitServer 追加 PROGRESS 留痕;不安装真机,完成后等待用户验收。
|
||||
@@ -0,0 +1,47 @@
|
||||
# K87 下拉刷新完成后回弹实施计划
|
||||
|
||||
## 目标
|
||||
|
||||
将全局 `AppPullToRefresh` 改为刷新完成前保持下拉高度:松手达到阈值后内容停在 56px,显示“正在刷新”,`onRefresh` 完成后再用 200ms easeOut 回弹到 0。
|
||||
|
||||
## 根因
|
||||
|
||||
- 当前下拉位移主要由 `BouncingScrollPhysics` 的系统 overscroll 提供。
|
||||
- 松手后滚动位置立即执行系统回弹,组件只保留一个小指示器。
|
||||
- 刷新期间没有独立的内容保持位移,因此无法维持下拉状态。
|
||||
|
||||
## 范围
|
||||
|
||||
- ReelShort `lib/core/widgets/app_pull_to_refresh.dart`
|
||||
- ReelShort `test/core/app_pull_to_refresh_test.dart`
|
||||
- FruitServer `docs/plans/PROGRESS.md`
|
||||
|
||||
## 实现计划
|
||||
|
||||
1. 将 `AppPullToRefresh.physics` 从 Bouncing 改为 Clamping,阻止系统 overscroll 自行产生内容位移。
|
||||
2. 使用 `AnimationController` 和 `Transform.translate` 统一控制内容位移;pull/armed 使用当前拖动距离,refreshing 固定 56,完成后回 0。
|
||||
3. 松手达到阈值后,200ms easeOut 将当前距离过渡到 56;刷新期间忽略滚动通知并通过 `IgnorePointer` 阻止重复下拉。
|
||||
4. `onRefresh` 完成后以 200ms easeOut 回到 0;指示器透明度跟随位移回弹淡出,结束后状态为 idle。
|
||||
5. 检查全部 11 个使用方均传入 `AppPullToRefresh.physics`,保证全局组件行为一致。
|
||||
|
||||
## 测试计划
|
||||
|
||||
- 使用挂起的 `Completer` 模拟刷新未完成。
|
||||
- 松手瞬间断言内容仍高于 hold,200ms 后稳定为 56,再等待 300ms 仍保持 56。
|
||||
- 断言刷新状态显示 `CircularProgressIndicator` 与 `Refreshing…`。
|
||||
- 刷新中再次下拉,断言 `onRefresh` 调用数仍为 1、offset 仍为 56。
|
||||
- 完成 `Completer` 后断言 offset 回到 0、刷新指示器消失。
|
||||
|
||||
## 风险与处理
|
||||
|
||||
- 改为 Clamping 后不再依赖平台 overscroll 提供下拉视觉;内容位移完全由组件控制,避免双倍移动。
|
||||
- 刷新期间阻止列表交互,避免用户手势破坏保持高度。
|
||||
- 组件卸载时动画控制器会取消动画;异步刷新完成后仅在 mounted 时执行回弹收尾。
|
||||
|
||||
## Git
|
||||
|
||||
- ReelShort 从 `develop` 创建 `feat/pull-to-refresh-hold`。
|
||||
- 提交:`feat(ui): 下拉刷新完成后才回弹`。
|
||||
- 作者:`Zhou Weidong <502333560@qq.com>`。
|
||||
- `--no-ff` 合回 `develop` 并 push,不使用 force push,不执行 `git add -A`。
|
||||
- FruitServer 追加 PROGRESS 留痕;不安装真机,完成后等待用户验收。
|
||||
@@ -0,0 +1,46 @@
|
||||
# K87.1 下拉刷新冻结位移实施计划
|
||||
|
||||
## 目标
|
||||
|
||||
修复刷新 pending 期间仍从松手距离回收到 56px 的视觉回弹。达到阈值后冻结当前下拉距离 D,刷新完成前 offset 不变化,完成后才用 200ms easeOut 回到 0。
|
||||
|
||||
## 根因
|
||||
|
||||
- K87 已将系统 physics 改为 Clamping,避免原生 overscroll 回弹叠加。
|
||||
- 但 `_refresh` 仍先执行 `_animateOffsetTo(_holdDistance)`,会把松手时的 D(例如 96)回收到 56。
|
||||
- 用户感知为“页面已经弹回去”,实际是组件自身在刷新开始时主动缩短 offset。
|
||||
|
||||
## 范围
|
||||
|
||||
- ReelShort `lib/core/widgets/app_pull_to_refresh.dart`
|
||||
- ReelShort `test/core/app_pull_to_refresh_test.dart`
|
||||
- FruitServer `docs/plans/PROGRESS.md`
|
||||
|
||||
## 实现计划
|
||||
|
||||
1. 保留 `AlwaysScrollableScrollPhysics(parent: ClampingScrollPhysics())`,系统不移动 overscroll 内容。
|
||||
2. 删除 `_holdDistance` 与刷新前的 56px 过渡动画。
|
||||
3. 达到阈值松手后立即进入 refreshing,AnimationController 保持当前 D;刷新期间滚动通知和手势均忽略。
|
||||
4. `onRefresh` 完成后再从 D 执行 200ms easeOut 回 0,指示器随 offset 淡出。
|
||||
5. 未达阈值松手时新增 `_retracting` 状态,执行 200ms easeOut 回到 0,不触发 `onRefresh`。
|
||||
|
||||
## 测试计划
|
||||
|
||||
- 达阈值测试:记录松手 offset D,挂起 300ms 后仍等于 D;刷新中重复下拉不改变 D、不增加调用。
|
||||
- complete 后断言 offset 回 0、指示器消失。
|
||||
- 未达阈值测试:松手后立即开始回弹,100ms 时 offset 介于 0 与 D 之间,最终回 0 且 `onRefresh` 未调用。
|
||||
- 断言 `AppPullToRefresh.physics.parent` 为 `ClampingScrollPhysics`。
|
||||
|
||||
## 风险与处理
|
||||
|
||||
- 保持 D 时下拉越高,内容下移越明显,但这是用户松手时的真实位置,刷新完成后才回收。
|
||||
- 未达阈值回弹期间通过 `_retracting` 忽略新滚动通知,避免动画目标被手势覆盖。
|
||||
- 不逐个页面改动,所有使用共享 physics 与组件的页面自动生效。
|
||||
|
||||
## Git
|
||||
|
||||
- ReelShort 从 `develop` 创建 `fix/pull-refresh-freeze`。
|
||||
- 提交:`fix(ui): 下拉刷新刷新期间冻结下拉位移`。
|
||||
- 作者:`Zhou Weidong <502333560@qq.com>`。
|
||||
- `--no-ff` 合回 `develop` 并 push,不使用 force push,不执行 `git add -A`。
|
||||
- FruitServer 追加 PROGRESS 留痕;不安装真机,完成后等待用户验收。
|
||||
@@ -0,0 +1,51 @@
|
||||
# K88 内容类型、互动数据编辑与分类 Feed 实施计划
|
||||
|
||||
## 目标
|
||||
|
||||
- 后台短剧管理支持内容类型和互动数据编辑:收藏、点赞、热度可编辑,评论数实时统计只读。
|
||||
- 新增 `drama.drama_type`,取值为 `ANIME` / `LIVE`,默认 `LIVE`。
|
||||
- App 新增 `GET /app/feed`,支持 `ANIME,LIVE` 多选类型,不传类型时返回推荐全部。
|
||||
|
||||
## FruitServer A
|
||||
|
||||
1. 数据库
|
||||
- 新增 `sql/migrate-k88-drama-type.sql`,只提交迁移文件,不执行数据库变更。
|
||||
- `sql/schema.sql` 的 drama 建表语句补 `drama_type`,默认 `LIVE`。
|
||||
|
||||
2. 后台管理
|
||||
- `Drama`、`DramaSaveReqVO`、`DramaRespVO` 增加 `dramaType`。
|
||||
- `DramaSaveReqVO` 增加可空 `favoriteCount`、`likeCount`、`heat`;服务层校验非负,`heat` 映射 `view_count`。
|
||||
- create 默认内容类型 LIVE、互动数 0;update 仅覆盖请求非 null 的互动字段。
|
||||
- 后台分页增加 `dramaTypes` 多选过滤,并保持 CommentService 批量回填评论数。
|
||||
|
||||
3. App Feed
|
||||
- `AppDramaCardVO` 增加 `dramaType`,现有 home/discover/detail 仅新增字段。
|
||||
- `GET /app/feed` 支持 `types`、`cursor`、`size`;size 默认 20、最大 50。
|
||||
- 排序为 `recommend_weight DESC NULLS LAST, view_count DESC, id DESC`。
|
||||
- cursor 使用最后一条 drama id,服务端反查其 recommendWeight/viewCount/id,再按三元组做 keyset 查询,避免 offset 翻页重漏。
|
||||
- 卡片复用现有 `toCards`,确保 preview、互动数、评论数与首页一致。
|
||||
- 更新 `docs/api-phase1.md` 的 dramaType 与 `/app/feed` 契约。
|
||||
|
||||
4. 测试
|
||||
- `/app/feed`:全部、ANIME、ANIME+LIVE、游标翻页不重不漏。
|
||||
- 后台 update:部分字段更新、heat 写 viewCount、负数与非法 dramaType 报错。
|
||||
|
||||
## ReelShortWeb B
|
||||
|
||||
1. 类型定义补齐 dramaType、favoriteCount、likeCount、commentCount、heat。
|
||||
2. 短剧列表增加内容类型筛选和标签列,播放量列改为热度,增加收藏/点赞/评论列。
|
||||
3. 编辑弹窗增加必填内容类型、互动数据区块;评论数只读。
|
||||
4. 不改审核、发布、删除逻辑。
|
||||
|
||||
## 风险与处理
|
||||
|
||||
- 推荐排序包含可空 recommend_weight,SQL 与 Java 条件必须显式处理 NULLS LAST。
|
||||
- 三字段排序不能只按 id 做 cursor,需以 cursor id 反查上一页最后一条的排序值。
|
||||
- 存量数据不主动修改,迁移默认 LIVE;数据库脚本由 PM 执行。
|
||||
- 全部改动只使用显式文件暂存,不执行 `git add -A`,不改 specs 与 Flutter 客户端。
|
||||
|
||||
## 门禁与 Git
|
||||
|
||||
- FruitServer:`mvn test` 全过;提交 `feat(content): 新增内容类型与首页分类 feed`;`--no-ff` 合回 develop 并 push。
|
||||
- ReelShortWeb:`pnpm ts:check`、`pnpm build:dev` 通过;提交 `feat(admin): 短剧列表展示并编辑互动数据`;`--no-ff` 合回 develop 并 push。
|
||||
- 作者统一 `Zhou Weidong <502333560@qq.com>`;各自 PROGRESS 追加 K88 留痕。
|
||||
@@ -0,0 +1,59 @@
|
||||
# K89 点赞/评论按集、收藏/热度按剧实施计划
|
||||
|
||||
## 目标
|
||||
|
||||
- 收藏、热度继续归属整部剧。
|
||||
- 点赞、评论归属具体剧集:新增 `drama_episode.like_count`,`content_like` 使用 `EPISODE` 目标。
|
||||
- App 卡片、详情、播放响应按当前集装配点赞/评论;后台短剧/剧集页提供对应汇总与只读展示。
|
||||
|
||||
## FruitServer A
|
||||
|
||||
1. 数据库
|
||||
- 新增 `sql/migrate-k89-episode-like.sql`,只提交不执行。
|
||||
- `sql/schema-phase1.sql` 的 drama_episode 增量字段补 like_count,默认 0。
|
||||
|
||||
2. 分集点赞
|
||||
- `DramaEpisode` 增加 likeCount;`EpisodeService` 提供原子增减与批量 SUM。
|
||||
- `LikeService` 增加 `TYPE_EPISODE`,校验已上线剧集的已上线分集,切换时同步分集计数,返回该集最新值。
|
||||
- 保留 DRAMA/COMMENT 点赞兼容。
|
||||
|
||||
3. 分集评论
|
||||
- `CommentService.countByEpisodes` 按 episode_id 批量分组统计未删除评论。
|
||||
- `/app/comments/count` 增加可选 episodeId;传集数返回该集,只有 dramaId 时维持全剧兼容语义。
|
||||
|
||||
4. App 装配
|
||||
- 卡片 preview 集的 likeCount/commentCount 写入卡片;favoriteCount/viewCount 仍取剧。
|
||||
- 详情 episodes[] 每项增加 likeCount/commentCount。
|
||||
- 播放响应增加 episodeId 对应的 likeCount/commentCount。
|
||||
|
||||
5. 后台
|
||||
- EpisodeRespVO 增加本集 like/comment 与所属剧 favorite/heat;Controller.list 批量回填。
|
||||
- EpisodeSaveReqVO 增加可空 likeCount,update 仅覆盖非 null,负数 BAD_REQUEST。
|
||||
- DramaRespVO likeCount 改为分集 SUM,commentCount 保持全剧汇总;分页一次批量聚合避免 N+1。
|
||||
- 更新 API 契约。
|
||||
|
||||
6. 测试
|
||||
- EPISODE 点赞 +1/-1、不越界、目标不存在。
|
||||
- App 卡片按 preview 集、剧级 favorite/heat。
|
||||
- 后台分集列表计数与剧级收藏/热度。
|
||||
- 短剧分页 likeCount 为分集汇总。
|
||||
|
||||
## ReelShortWeb B
|
||||
|
||||
1. EpisodeItem / EpisodeSaveData 增加对应互动字段。
|
||||
2. 剧集表格增加本集点赞、评论,以及所属剧收藏、热度列。
|
||||
3. 编辑弹窗增加本集点赞输入和评论只读;“按集实时统计”。
|
||||
4. 短剧管理保持收藏/热度可编辑,点赞/评论展示为后端只读汇总。
|
||||
|
||||
## 风险与处理
|
||||
|
||||
- 存量 `drama.like_count` 保留不删,不回填分集;新展示以分集 SUM 为准。
|
||||
- App 评论数按 preview 集统计,只有 episodeId 为空的历史评论仍计入全剧汇总。
|
||||
- 评论/点赞接口保持匿名/登录既有安全语义,不新增第三方依赖。
|
||||
- 迁移脚本由 PM 执行;本地门禁不访问真实数据库。
|
||||
|
||||
## 门禁与 Git
|
||||
|
||||
- FruitServer:`mvn test` 全过;提交 `feat(interaction): 点赞与评论按集统计`;`--no-ff` 合回 develop 并 push。
|
||||
- ReelShortWeb:`pnpm ts:check`、`pnpm build:dev` 通过;提交 `feat(admin): 剧集列表展示分集互动数据`;`--no-ff` 合回 develop 并 push。
|
||||
- 作者统一 `Zhou Weidong <502333560@qq.com>`;禁止 `git add -A`;各自 PROGRESS 追加 K89 留痕。
|
||||
@@ -0,0 +1,114 @@
|
||||
# K91 后台观看记录独立菜单、评论分集展示与全部状态筛选
|
||||
|
||||
## 目标
|
||||
|
||||
- FruitServer 新增跨用户观看记录分页接口,并给后台评论补充短剧名、集号与集标题。
|
||||
- ReelShortWeb 新增「观看记录」独立页面,评论/举报状态筛选默认展示全部。
|
||||
- 迁移脚本只提交文件,不执行数据库变更;不改 specs 仓库和 Flutter 客户端。
|
||||
|
||||
## 分支
|
||||
|
||||
- FruitServer:`feat/k91-watch-history`,从 `origin/develop` 创建。
|
||||
- ReelShortWeb:`feat/k91-watch-history-page`,从 `origin/develop` 创建。
|
||||
|
||||
## A. FruitServer
|
||||
|
||||
### A1 观看记录分页
|
||||
|
||||
1. 新增 `WatchHistoryQueryReqVO`,字段:
|
||||
`pageIndex/pageSize/keyword/userId/dramaTitle/dramaId/episodeId/source/finished/startTime/endTime`。
|
||||
2. 新增 `AdminWatchHistoryVO`,返回用户、短剧、分集、进度、完成、来源、设备与观看时间。
|
||||
3. 新增 `WatchHistoryAdminService`,直接注入:
|
||||
- `WatchHistoryMapper`
|
||||
- `AppUserMapper`
|
||||
- `DramaMapper`
|
||||
- `DramaEpisodeMapper`
|
||||
4. 查询流程:
|
||||
- `keyword` 先批量命中 `app_user.uid/nickname` 的 id;无命中直接空页。
|
||||
- `dramaTitle` 先批量命中 `drama.title` 的 id;无命中直接空页。
|
||||
- 精确 id 条件与模糊命中集合取交集。
|
||||
- `finished` 在 SQL 层表达,允许区间两侧都落在 `duration_ms = 0` 等边界。
|
||||
- 按 `watched_at DESC, id DESC` 排序。
|
||||
- 对结果页的用户、剧、集各做一次批量查询后装配,禁止逐行查询。
|
||||
5. 新增 `WatchHistoryAdminController`,权限点 `watch-history:list`,保留旧用户详情观看流水接口。
|
||||
|
||||
### A2 评论后台分集信息
|
||||
|
||||
1. `CommentRespVO` 增加 `dramaTitle/episodeNo/episodeTitle`。
|
||||
2. 仅 `CommentService.adminPage` 对当前页批量补剧、集信息。
|
||||
3. `toRespList` 的 C 端路径保持不增加查询。
|
||||
|
||||
### A3 SQL 与契约
|
||||
|
||||
1. 新增幂等迁移 `sql/migrate-k91-watch-history-menu.sql`:
|
||||
- 权限点 `1105 watch-history:list`
|
||||
- 菜单使用 id `34`,挂 parent `15`
|
||||
- `component=views/userManagement/WatchHistoryView`
|
||||
- 超管角色权限与菜单关联
|
||||
2. 同步 `sql/data-phase1.sql`。
|
||||
3. 更新 `docs/api-phase1.md` §2.3、§2.5。
|
||||
|
||||
### A4 测试
|
||||
|
||||
- `WatchHistoryAdminServiceTest` 覆盖:
|
||||
- 默认分页与排序
|
||||
- keyword 用户命中
|
||||
- dramaTitle 剧名命中
|
||||
- finished 真/假 SQL 条件
|
||||
- 时间范围
|
||||
- 命中集合为空直接空页
|
||||
- pageSize 上限收敛为 100
|
||||
- `CommentServiceTest` 覆盖后台页批量补齐剧名、集号、集标题。
|
||||
- 门禁:`mvn test` 全模块通过。
|
||||
|
||||
## B. ReelShortWeb
|
||||
|
||||
### B1 类型/API
|
||||
|
||||
- 扩展 `WatchHistoryItem`:`userId/uid/nickname/episodeTitle`。
|
||||
- 扩展 `CommentItem`:`dramaTitle/episodeNo/episodeTitle`。
|
||||
- `appUser.ts` 新增 `pageWatchHistoryApi(params)`。
|
||||
|
||||
### B2 观看记录页面
|
||||
|
||||
- 新建 `src/views/userManagement/WatchHistoryView.vue`:
|
||||
- 用户、短剧名称、来源、完成状态、时间范围筛选。
|
||||
- 观看时间、用户、短剧、分集、进度、完成、来源、设备列。
|
||||
- 10/20/50 分页。
|
||||
- 复用 App 用户页的 `panel/console-toolbar/pagination/app-user-*` 视觉与格式化函数。
|
||||
|
||||
### B3 评论/举报全部状态
|
||||
|
||||
- 评论与举报状态首项增加 `{ value: '', label: '全部状态', tag: 'info' }`。
|
||||
- 两个筛选默认值改为空串,请求时空串转 `undefined`。
|
||||
- 评论表以「短剧 / 分集」替换短剧 ID 单列:
|
||||
- 显示剧名与集号/集标题。
|
||||
- 缺少剧名时回退短剧 id。
|
||||
- 缺少集号时回退分集 id;历史 `episodeId=0` 显示未关联分集。
|
||||
- 原始短剧 id / 分集 id 通过 tooltip 保留。
|
||||
|
||||
### B4 门禁
|
||||
|
||||
- `pnpm ts:check`
|
||||
- `pnpm build:dev`
|
||||
|
||||
## 风险与待确认
|
||||
|
||||
1. `watch_history` 是月分区表,现有索引为 `(user_id, watched_at)` 与
|
||||
`(drama_id, watched_at)`,没有跨用户的全局 `watched_at` 索引。本次按要求实现跨用户时间排序,
|
||||
不擅自新增索引;数据量增长后由 PM 评估是否增加全局观看时间索引。
|
||||
2. 用户/剧名模糊检索先取 id 集合,符合“命中为空不退化成全表”的要求;
|
||||
超大关键词命中集合的批大小由后续实际数据量评估,本次不擅自加截断以免漏结果。
|
||||
3. 历史评论的 `episode_id=0` 不回填;后台显示“未关联分集”,原始 id 仍保留在 tooltip。
|
||||
4. 迁移脚本只写文件,不执行数据库;菜单落库由 PM 按发布流程执行。
|
||||
5. 任务书建议菜单 id `26`,但当前 `data-phase1.sql` 已将 `26` 用作“创作者中心”目录,
|
||||
`27-30` 为其子菜单。为避免覆盖线上已有菜单树,本次使用下一个空闲 id `34`;
|
||||
父级、路由、组件与权限点均不变。
|
||||
|
||||
## 提交与合并
|
||||
|
||||
- FruitServer 提交:`feat(admin): 新增观看记录分页与评论分集信息`
|
||||
- ReelShortWeb 提交:`feat(admin): 观看记录独立菜单与治理状态全部筛选`
|
||||
- 两仓库均 `--no-ff` 合回 `develop` 并 push。
|
||||
- 作者与提交者:`Zhou Weidong <502333560@qq.com>`。
|
||||
- 禁止 `git add -A`,所有文件逐项暂存。
|
||||
@@ -0,0 +1,108 @@
|
||||
# K92 举报工单展示短剧名称与分集
|
||||
|
||||
## 目标
|
||||
|
||||
- `/admin/reports/page` 不再只返回 `targetType / targetId`,而是返回举报人、目标短剧与分集的展示信息。
|
||||
- Web 举报工单列表与处理弹窗使用同一份目标摘要,不再展示裸对象 ID。
|
||||
- 不改既有举报处理逻辑、评论列表接口、观看记录接口或数据库结构。
|
||||
|
||||
## 分支
|
||||
|
||||
- FruitServer:`feat/k92-report-target`,从 `origin/develop` 创建。
|
||||
- ReelShortWeb:`feat/k92-report-target-ui`,从 `origin/develop` 创建。
|
||||
|
||||
## A. FruitServer
|
||||
|
||||
### A1 返回模型
|
||||
|
||||
新增 `com.fruitshorts.admin.vo.AdminReportRespVO`,包含:
|
||||
|
||||
- 工单:`id/reasonCode/description/status/handleBy/handleAt/handleNote/createdAt`
|
||||
- 举报人:`reporterId/reporterNickname/reporterUid`
|
||||
- 目标:`targetType/targetId/targetSummary`
|
||||
- 剧集:`dramaId/dramaTitle/episodeId/episodeNo/episodeTitle`
|
||||
- 评论/用户:`commentContent/targetNickname/targetUid`
|
||||
|
||||
### A2 查询和解析
|
||||
|
||||
新增 `com.fruitshorts.admin.service.ReportAdminService`:
|
||||
|
||||
1. 分页查询 `content_report`,条件与 `ReportService.page` 保持一致:
|
||||
`status/targetType/reasonCode/reporterId` 均仅在有文本或非空时加入,空值返回全部;
|
||||
排序保持 `id DESC`。
|
||||
2. 当前页批量查询:
|
||||
- COMMENT 目标评论:一次查询,且必须包含逻辑删除记录,用于判断“评论已删除”。
|
||||
- 评论与 DRAMA 目标剧:一次批量查询 `drama`。
|
||||
- 评论目标分集:一次批量查询 `drama_episode`。
|
||||
- USER 目标用户与全部 reporter:合并 id 后一次批量查询 `app_user`。
|
||||
3. 禁止逐行查询。
|
||||
|
||||
`ContentCommentMapper` 增加显式批量查询方法,绕过 `@TableLogic` 的自动过滤;
|
||||
普通 `selectBatchIds` 仍保持原行为。
|
||||
|
||||
### A3 摘要规则
|
||||
|
||||
- COMMENT:
|
||||
- 正常评论且剧存在:`剧名 · 第 N 集`,有集标题时追加 ` · 集标题`。
|
||||
- 评论删除、逻辑删除、评论不存在或剧不存在:`评论 #targetId`。
|
||||
- DRAMA:
|
||||
- 剧存在:剧名。
|
||||
- 不存在:`短剧 #targetId`。
|
||||
- USER:
|
||||
- 用户存在:`昵称(uid)`。
|
||||
- 不存在:`用户 #targetId`。
|
||||
|
||||
### A4 Controller 与文档
|
||||
|
||||
- `ReportAdminController.page` 改为返回 `Result<PageResult<AdminReportRespVO>>`。
|
||||
- `handle` 继续调用原 `ReportService.handle`,不变更业务行为。
|
||||
- 更新 `docs/api-phase1.md` §2.5。
|
||||
|
||||
### A5 测试
|
||||
|
||||
新增 `ReportAdminServiceTest`,覆盖:
|
||||
|
||||
- COMMENT / DRAMA / USER 三类摘要。
|
||||
- 评论集标题、举报人昵称/uid、目标用户昵称/uid。
|
||||
- 空筛选条件表示全部。
|
||||
- 评论逻辑删除和目标剧不存在时退化文案。
|
||||
- 验证按页批量查询,不产生 N+1。
|
||||
|
||||
门禁:`mvn test` 全模块通过。
|
||||
|
||||
## B. ReelShortWeb
|
||||
|
||||
### B1 类型
|
||||
|
||||
`ReportItem` 补齐后台新增字段,保留原 `targetId` 用于 tooltip 排查。
|
||||
|
||||
### B2 治理页
|
||||
|
||||
1. 「对象」列:
|
||||
- 中文类型标签:评论 / 用户 / 短剧。
|
||||
- 显示 `targetSummary`。
|
||||
- tooltip 显示原始 `#targetId`,评论类型有内容时追加评论内容。
|
||||
2. 删除独立「对象ID」列。
|
||||
3. 「举报人」列显示昵称;无昵称回退 uid;再无回退 `#reporterId`。
|
||||
4. 处理弹窗「工单对象」显示类型标签 + `targetSummary`。
|
||||
|
||||
### B3 门禁
|
||||
|
||||
- `pnpm ts:check`
|
||||
- `pnpm build:dev`
|
||||
- 对改动文件执行定向 ESLint
|
||||
|
||||
## 风险与说明
|
||||
|
||||
1. 评论逻辑删除记录默认被 MyBatis-Plus 过滤;本次使用显式 mapper 查询识别,
|
||||
不改变评论正常查询和删除行为。
|
||||
2. 已删除评论不展示正文,避免后台误读已删除内容;仍保留 `targetId` tooltip 便于排查。
|
||||
3. 目标关联数据已物理删除时按任务书使用 `评论 #id / 短剧 #id / 用户 #id` 退化。
|
||||
4. 本任务无数据库迁移,不改 specs 仓库和 Flutter 客户端。
|
||||
|
||||
## Git
|
||||
|
||||
- FruitServer:`feat(admin): 举报工单返回短剧与分集信息`
|
||||
- ReelShortWeb:`feat(admin): 举报列表展示短剧与分集`
|
||||
- 两仓库均 `--no-ff` 合回 `develop` 并 push。
|
||||
- 作者:`Zhou Weidong <502333560@qq.com>`;禁止 `git add -A`。
|
||||
@@ -0,0 +1,121 @@
|
||||
# K93 短剧类型与内容类型支持多选
|
||||
|
||||
## 目标
|
||||
|
||||
- 后台短剧基础信息中的「类型」「内容类型」改为至少选一项的多选。
|
||||
- 后台列表筛选、列表展示支持多分类与多内容类型。
|
||||
- App 分类分区和内容类型 feed 使用多标签字段做整词匹配。
|
||||
- 单值字段继续保留,兼容创作者中心、旧接口和现有 App 卡片。
|
||||
|
||||
## 分支
|
||||
|
||||
- FruitServer:`feat/k93-drama-multi-tag`,从 `origin/develop` 创建。
|
||||
- ReelShortWeb:`feat/k93-drama-multi-tag-ui`,从 `origin/develop` 创建。
|
||||
|
||||
## A. FruitServer
|
||||
|
||||
### A1 数据库
|
||||
|
||||
- 新增 `sql/migrate-k93-drama-multi-tag.sql`:
|
||||
- `drama.drama_types VARCHAR(32) NOT NULL DEFAULT ''`
|
||||
- `drama.category_ids VARCHAR(255) NOT NULL DEFAULT ''`
|
||||
- 从现有 `drama_type / category_id` 幂等回填。
|
||||
- 同步 `sql/schema.sql` 的 drama 建表字段。
|
||||
- 只提交迁移文件,不执行数据库。
|
||||
|
||||
### A2 实体与 VO
|
||||
|
||||
- `Drama`:增加 `dramaTypes/categoryIds` 逗号字符串。
|
||||
- `DramaSaveReqVO`:
|
||||
- 新增 `List<String> dramaTypes`、`List<Long> categoryIds`,列表优先。
|
||||
- 保留 `dramaType/categoryId` 单值兜底。
|
||||
- `DramaPageReqVO`:增加 `List<Long> categoryIds`,保留 `categoryId`。
|
||||
- `DramaRespVO`:增加 `dramaTypes/categoryIds/categoryNames`,旧单值字段语义不变。
|
||||
|
||||
### A3 保存规则
|
||||
|
||||
- 内容类型列表:normalize、去重、保持提交顺序;主值写第一个,完整列表写 `drama_types`。
|
||||
- 分类列表:过滤 null/非正数、去重、保持提交顺序;主值写第一个或 0,完整列表写 `category_ids`。
|
||||
- 列表为空时回退单值;单值也没有时保留当前值。
|
||||
- 创建时内容类型最终为空则默认 LIVE。
|
||||
- 非法内容类型继续返回 BAD_REQUEST。
|
||||
|
||||
### A4 查询规则
|
||||
|
||||
统一使用整词匹配:
|
||||
|
||||
```sql
|
||||
(',' || column || ',') LIKE '%,value,%'
|
||||
```
|
||||
|
||||
- 后台分页:
|
||||
- `dramaTypes` 非空:`drama_types` token 匹配。
|
||||
- `categoryIds` 非空:`category_ids` token 匹配。
|
||||
- `categoryIds` 为空:回退 `category_id` 等值。
|
||||
- App `listPublishedFeed`:`drama_types` token 匹配。
|
||||
- App feed 游标:marker 的解析后 `dramaTypes` 与任一筛选类型相交才允许继续。
|
||||
- App `listPublished(categoryId)`:`category_ids` token 匹配,使多分类剧出现在每个分类分区。
|
||||
|
||||
### A5 响应装配
|
||||
|
||||
- 解析 `drama_types/category_ids`,空值回退单值。
|
||||
- `categoryNames` 按 categoryIds 顺序映射分类名。
|
||||
- 分类名缺失时回退 `genre`。
|
||||
- 现有 `dramaType/categoryId/category` 保持旧语义。
|
||||
|
||||
### A6 文档与测试
|
||||
|
||||
- 更新 `docs/api-phase1.md` 的后台保存/分页字段、App feed 和分类说明。
|
||||
- 增加服务测试覆盖:
|
||||
- 多类型/多分类去重、顺序与主值写回。
|
||||
- 单值兜底行为不变。
|
||||
- 后台分页 token 条件。
|
||||
- feed 多标签 marker 可被 ANIME/LIVE 命中。
|
||||
- App 分类分区 token 条件。
|
||||
- 响应多值解析和分类名顺序。
|
||||
- 门禁:`mvn test` 全模块通过。
|
||||
|
||||
## B. ReelShortWeb
|
||||
|
||||
### B1 类型
|
||||
|
||||
- `DramaItem` 增加 `dramaTypes/categoryIds/categoryNames`。
|
||||
- `DramaSaveData` 增加 `dramaTypes/categoryIds`。
|
||||
- `DramaPageParams` 增加 `categoryIds`。
|
||||
|
||||
### B2 表单
|
||||
|
||||
- `form.categoryIds: number[]`,默认空数组。
|
||||
- `form.dramaTypes: string[]`,创建默认 `['LIVE']`。
|
||||
- 两个下拉均使用 multiple、collapse-tags、collapse-tags-tooltip、filterable。
|
||||
- 校验至少 1 项。
|
||||
- 编辑时优先数组,缺失回退单值。
|
||||
- 提交数组;`genre` 使用所选分类名以 ` / ` 拼接。
|
||||
|
||||
### B3 筛选与表格
|
||||
|
||||
- 分类筛选改为 `categoryIds: number[]`。
|
||||
- 内容类型筛选改为 `dramaTypes: string[]`。
|
||||
- 查询传数组,重置为空数组。
|
||||
- 类型列显示 `categoryNames.join(' / ')`,回退 `genre`。
|
||||
- 内容类型列逐个渲染标签,缺失时回退 `dramaType`。
|
||||
|
||||
### B4 门禁
|
||||
|
||||
- `pnpm ts:check`
|
||||
- `pnpm build:dev`
|
||||
- 对修改文件执行定向 ESLint
|
||||
|
||||
## 风险与说明
|
||||
|
||||
1. 新代码依赖迁移后的 `drama_types/category_ids` 列,发布顺序必须先执行迁移再启动新版本。
|
||||
2. 逗号列仅存储受控内容类型和数字 id,不允许用户输入;查询值均来自校验后的数组。
|
||||
3. 主值继续保留,降低旧客户端、创作者中心和旧接口的兼容风险。
|
||||
4. 本次不改 specs 与 Flutter 客户端,不执行数据库迁移,不操作真机。
|
||||
|
||||
## Git
|
||||
|
||||
- FruitServer:`feat(content): 短剧类型与内容类型支持多选`
|
||||
- ReelShortWeb:`feat(admin): 短剧类型与内容类型多选`
|
||||
- 两仓库均 `--no-ff` 合回 `develop` 并 push。
|
||||
- 作者:`Zhou Weidong <502333560@qq.com>`;禁止 `git add -A`。
|
||||
@@ -0,0 +1,126 @@
|
||||
# K94 首页内容类型 Feed 与无感切换
|
||||
|
||||
## 目标
|
||||
|
||||
- 首页顶栏「漫剧 / 真人剧 / 推荐」接入既有 `/app/feed`。
|
||||
- 每频道独立缓存与分页,切换时先同步展示缓存,再后台静默刷新。
|
||||
- 推荐首屏复用 `/app/home/feed` 打平数据,首次进入不额外转圈。
|
||||
- 无缓存频道只在黑色内容区显示小转圈,顶栏和底栏保持。
|
||||
- 滑动接近末尾自动加载下一页,并在播放器队列中原地追加。
|
||||
|
||||
## 分支
|
||||
|
||||
- ReelShort:`feat/k94-home-type-feed`,从 `origin/develop` 创建。
|
||||
- FruitServer 仅文档留痕,不改功能代码。
|
||||
|
||||
## A. 数据层
|
||||
|
||||
### A1 FeedPage
|
||||
|
||||
新增 `lib/core/data/models/feed_page.dart`:
|
||||
|
||||
- `dramas` 使用 `Drama.fromCardJson`。
|
||||
- `nextCursor` 兼容数字/字符串,空值或字符串 `"null"` 转为 null。
|
||||
- `hasMore` 读取布尔值。
|
||||
|
||||
### A2 CatalogApi / Repository
|
||||
|
||||
- `CatalogApi.feed({types, cursor, size})` 请求 `/app/feed`。
|
||||
- types 为空不传;非空用逗号拼接。
|
||||
- cursor 为空不传。
|
||||
- 返回结构异常抛 `ApiException(-1, '返回数据格式异常')`。
|
||||
- `CatalogRepository` 与 HTTP 实现增加 `fetchFeed`。
|
||||
- 所有测试 CatalogRepository 实现同步补齐方法。
|
||||
|
||||
## B. 频道控制器
|
||||
|
||||
新增:
|
||||
|
||||
- `lib/pages/home/home_feed_channel.dart`
|
||||
- `lib/core/data/services/home_feed_controller.dart`
|
||||
|
||||
`HomeFeedController` 使用每个频道独立状态:
|
||||
|
||||
- dramas / cursor / hasMore / loaded / loadingMore / requestSeq
|
||||
- 当前 channel,默认 recommend
|
||||
- `seedRecommend`:同步写入推荐首屏,不发请求
|
||||
- `selectChannel`:同步切频道并 notify;无缓存加载第一页,有缓存静默刷新
|
||||
- `refreshCurrent`:失败保留旧列表
|
||||
- `loadMore`:cursor 追加,按 drama.id 去重
|
||||
- 所有响应必须同时满足“仍为当前频道 + requestSeq 最新”才应用
|
||||
- dispose 后停止 notify
|
||||
|
||||
## C. 首页接入
|
||||
|
||||
### C1 顶栏受控
|
||||
|
||||
`HomeFeedHeader`:
|
||||
|
||||
- 删除内部 tab 状态、comingSoon 和 SnackBar。
|
||||
- 新增 `channel` 与 `onChannelSelected`。
|
||||
- 三个 Key 保持不变。
|
||||
- refresh 内部 loading 状态保留。
|
||||
|
||||
### C2 HomePage
|
||||
|
||||
- `_HomePageState` 用 `CatalogController.repository` 创建 HomeFeedController。
|
||||
- Catalog 首次有数据时同步 seed recommend,随后在 post-frame 静默刷新 recommend。
|
||||
- `_HomeTabs` 使用稳定 Key,删除 `ValueKey(catalog.dramas.first.id)`。
|
||||
- 当前频道无数据时,保留 `_HomeTabs` 顶栏/底栏,body 用黑色背景 + 居中
|
||||
`home-feed-channel-loading`。
|
||||
- 当前频道有数据时把频道列表传给 PlayerPage。
|
||||
- 刷新回调改 `refreshCurrent`;分页回调改 `loadMore`。
|
||||
|
||||
### C3 PlayerPage / PlayerLogic
|
||||
|
||||
- PlayerPage 增加 `feedChannel` 和 `onLoadMore`。
|
||||
- 同频道 feed 列表变化:`updateFeed(..., keepDramaId: currentDramaId)`。
|
||||
- channel 变化:`updateFeed(..., keepDramaId: null)`,回到新频道第 1 个。
|
||||
- PlayerLogic 保存 factory/coordinator,支持需要换内容时替换 PlaybackSession。
|
||||
- 空列表清空 queue/visibleIndices 并停止旧播放。
|
||||
- 当前剧仍在新列表且索引不变时,只扩展队列与 episode 列表,不重新 select。
|
||||
- PageView 在 `position >= visibleIndices.length - 3` 时调用 onLoadMore。
|
||||
|
||||
## D. 测试
|
||||
|
||||
新增 `test/core/data/services/home_feed_controller_test.dart`:
|
||||
|
||||
- recommendation seed 不发请求
|
||||
- 三频道请求 types 分别为 `[] / [ANIME] / [LIVE]`
|
||||
- 缓存频道切换不清空并后台刷新
|
||||
- loadMore 追加去重、无更多后不再请求
|
||||
- 串包只接受最新频道请求
|
||||
- refresh 失败保留旧数据
|
||||
|
||||
新增顶栏 widget 测试:
|
||||
|
||||
- 三个 Key 存在
|
||||
- 点击分别回调 anime/live/recommend
|
||||
- 当前 channel 决定选中样式
|
||||
|
||||
PlayerLogic 测试补充:
|
||||
|
||||
- updateFeed 空列表安全
|
||||
- 追加列表保持当前剧
|
||||
- 切频道列表回到第 1 个
|
||||
|
||||
门禁:
|
||||
|
||||
- `dart analyze lib test`
|
||||
- `flutter test --no-pub`
|
||||
- `flutter build apk --debug`
|
||||
|
||||
## 风险与控制
|
||||
|
||||
1. PlaybackSession 的 episodes 是构造时绑定的列表;分页原地追加时会同步扩展该列表,
|
||||
避免仅换 queue 而 session 仍指向旧列表。
|
||||
2. 换频道可能释放并重建播放器 session,这是内容源变化;静默刷新/分页在顺序不变时
|
||||
不重新 select 当前剧,避免视频重启。
|
||||
3. 推荐 seed 只保证首帧立即有内容;后台 `/app/feed` 刷新失败时保留 seed。
|
||||
4. 首页仍在 `/app/home/feed` 首次加载期间使用既有启动页;频道切换不再触发整页 splash。
|
||||
|
||||
## Git
|
||||
|
||||
- 提交:`feat(home): 首页按内容类型分频道 Feed 并支持分页`
|
||||
- `--no-ff` 合回 ReelShort `develop` 并 push。
|
||||
- 作者:`Zhou Weidong <502333560@qq.com>`;禁止 `git add -A`。
|
||||
@@ -0,0 +1,100 @@
|
||||
# K95 修复首页频道快速切换卡 Loading
|
||||
|
||||
## 目标
|
||||
|
||||
- 频道请求完成后始终写回发起请求的频道缓存,不再因用户切走而丢失结果。
|
||||
- 每频道明确区分 loaded / loading / in-flight / error,无请求时绝不显示首屏转圈。
|
||||
- 首屏和刷新请求增加可注入的 10 秒超时兜底。
|
||||
- PlayerLogic 保证连续 feed 更新串行应用,只让最后一次 feed/session 生效。
|
||||
|
||||
## 分支
|
||||
|
||||
- ReelShort:`fix/k95-feed-switch-loading`,从 `origin/develop` 创建。
|
||||
- FruitServer 仅提交计划与 PROGRESS,不改功能代码。
|
||||
|
||||
## A. HomeFeedController
|
||||
|
||||
每个频道状态增加:
|
||||
|
||||
- `List<Drama> dramas`
|
||||
- `String? cursor`
|
||||
- `bool hasMore`
|
||||
- `bool loaded`
|
||||
- `bool loading`
|
||||
- `bool loadingMore`
|
||||
- `String? lastError`
|
||||
- `int requestSeq`
|
||||
- `Future<bool>? inFlight`
|
||||
|
||||
请求规则:
|
||||
|
||||
1. 响应成功/失败都写入发起请求的频道状态。
|
||||
2. 只有频道仍为当前频道时才 `notifyListeners`。
|
||||
3. `requestSeq` 只比较同一频道的新旧请求,不参与跨频道过滤。
|
||||
4. 超时时间通过构造参数注入,默认 10 秒。
|
||||
5. `loadingFirstPage = !loaded && loading`。
|
||||
6. `selectChannel`:
|
||||
- 有缓存:同步显示,未在飞时后台静默刷新
|
||||
- 无缓存且正在飞:等待现有请求,不重复发
|
||||
- 无缓存且有历史错误:自动重试
|
||||
- 从未加载:发起首屏请求
|
||||
7. `refreshCurrent` 同样复用 in-flight,防止并发重复刷新。
|
||||
8. `loadMore` 失败保留 cursor/hasMore,允许下次继续重试。
|
||||
|
||||
## B. PlayerLogic / PlayerPage
|
||||
|
||||
### B1 Feed revision
|
||||
|
||||
- PlayerLogic 增加 `int feedRevision`。
|
||||
- 每次 `updateFeed` 自增 revision,记录最新目标 feed。
|
||||
- `_replaceSession` 与 `selectEpisode` 在 await 后校验 revision,过期流程直接返回。
|
||||
- 连续 updateFeed 使用串行队列:当前应用结束后再应用最新待处理 feed。
|
||||
|
||||
### B2 空队列与频道切换
|
||||
|
||||
- 空 feed 不创建新 session,只清空 queue/visibleIndices 并停播。
|
||||
- 空 → 非空必须恢复 route visible,并 select 第 0 个。
|
||||
- 频道变化通过额外 reset 标志传入 `updateFeed`,即使 drama id 列表相同,
|
||||
也重置到第 1 个并开始播放。
|
||||
|
||||
### B3 PlayerPage 更新判定
|
||||
|
||||
- `didUpdateWidget` 用 `feedDramas` 的 drama id 列表签名判断内容变化。
|
||||
- 同一列表的新 List 实例不重复 updateFeed。
|
||||
- 频道变化始终触发 updateFeed,并传 `resetToFirst=true`。
|
||||
|
||||
## C. 测试
|
||||
|
||||
### HomeFeedController
|
||||
|
||||
- A 挂起 → B 成功 → A 成功:A/B loaded 均为 true,切回 A 立即有数据。
|
||||
- 同频道旧失败响应不得覆盖新成功响应。
|
||||
- 无在飞请求时 `loadingFirstPage=false`。
|
||||
- 永不返回的请求在注入超时后结束 loading、写 lastError、loaded=true。
|
||||
- 失败频道再次 select 自动重试。
|
||||
- loadMore 失败保留原有 hasMore/cursor。
|
||||
|
||||
### PlayerLogic
|
||||
|
||||
- 连续 5 次 updateFeed,最终 queue/session 对应最后一次列表。
|
||||
- 空 → 非空会创建 session 并 select 第 0 个。
|
||||
- 频道变化时相同 id 列表也回到第 1 个。
|
||||
|
||||
门禁:
|
||||
|
||||
- `dart analyze lib test`
|
||||
- `flutter test --no-pub`
|
||||
- `flutter build apk --debug`
|
||||
|
||||
## 风险与控制
|
||||
|
||||
1. 跨频道响应写回缓存必须与同频道 seq 校验同时存在;前者解决缓存丢失,后者解决同频道旧请求覆盖新结果。
|
||||
2. Player session 替换以 revision 作为唯一有效性判断,避免旧 close/select 回调干扰新 session。
|
||||
3. 空队列期间不创建 PlaybackSession;恢复非空时重新创建并起播。
|
||||
4. 不改后端、ReelShortWeb、specs;不安装或操作真机。
|
||||
|
||||
## Git
|
||||
|
||||
- 提交:`fix(home): 修复频道快速切换卡 loading`
|
||||
- `--no-ff` 合回 ReelShort `develop` 并 push。
|
||||
- 作者:`Zhou Weidong <502333560@qq.com>`;禁止 `git add -A`。
|
||||
@@ -0,0 +1,83 @@
|
||||
# K95.1 首次切换频道无感显示
|
||||
|
||||
## 目标
|
||||
|
||||
- 推荐首屏成功后后台预取 anime/live,避免第一次切换出现阻断式 loading。
|
||||
- 目标频道尚未返回时保留上一频道 PlayerPage 和视频画面,只叠加轻量 loading 遮罩。
|
||||
- 数据到达后原子替换为新频道 feed,并从第 1 个播放。
|
||||
|
||||
## 分支
|
||||
|
||||
- ReelShort:`fix/k95.1-seamless-first-switch`,从已包含 K95 的 `origin/develop` 创建。
|
||||
- FruitServer 仅文档留痕,不改功能代码。
|
||||
|
||||
## A. HomeFeedController
|
||||
|
||||
新增 `Future<void> prefetchChannels()`:
|
||||
|
||||
- 仅处理 anime/live。
|
||||
- 只对 `!loaded && !loading` 的频道请求。
|
||||
- 请求结果写回对应频道缓存。
|
||||
- 不切换当前频道、不改变当前列表;仅目标恰为当前频道时 notify。
|
||||
- 失败只写 lastError,不向外抛。
|
||||
- 成功预取设置一次性 `skipNextRefresh`:首次切到该频道直接使用缓存,不立刻重复静默刷新;
|
||||
后续再次切回仍执行正常缓存静默刷新。
|
||||
- 预取期间用户切换到该频道时等待已有 inFlight,不重复请求。
|
||||
|
||||
## B. HomePage / _HomeTabs
|
||||
|
||||
### B1 最近可见 feed
|
||||
|
||||
`_HomeTabsState` 维护:
|
||||
|
||||
- `List<Drama>? _visibleDramas`
|
||||
- `HomeFeedChannel? _visibleChannel`
|
||||
|
||||
当前频道有数据时更新这两个值,并以当前频道渲染 PlayerPage。
|
||||
|
||||
### B2 首次切换
|
||||
|
||||
当前频道无数据且 loading:
|
||||
|
||||
- 继续复用上一频道 `_visibleDramas/_visibleChannel` 渲染同一个 PlayerPage。
|
||||
- header 使用当前选中频道,但 PlayerPage.feedChannel 仍使用可见旧频道,避免队列更新。
|
||||
- Stack 上叠加 `IgnorePointer + ColoredBox(black26) + 24px spinner`,
|
||||
Key 为 `home-feed-channel-loading`。
|
||||
- 数据返回后页面树保持同一层级的 PlayerPage,传入新 feed/channel,触发原子更新和第 1 个起播。
|
||||
- 空结果/失败后才切到「暂无剧目 / 重试」占位。
|
||||
|
||||
### B3 Prefetch 触发
|
||||
|
||||
推荐首屏后台刷新成功后 `unawaited(prefetchChannels())`。
|
||||
|
||||
## C. 测试
|
||||
|
||||
HomeFeedController:
|
||||
|
||||
- prefetch 后首次 select anime 不再发请求。
|
||||
- prefetch 期间选择 anime 不重复请求。
|
||||
- prefetch 失败不影响推荐,也不向外抛。
|
||||
|
||||
Widget:
|
||||
|
||||
- 首切未缓存频道时 PlayerPage 仍在树中且出现 loading 遮罩。
|
||||
- 数据返回后遮罩消失并使用新频道 feed。
|
||||
|
||||
门禁:
|
||||
|
||||
- `dart analyze lib test`
|
||||
- `flutter test --no-pub`
|
||||
- `flutter build apk --debug`
|
||||
|
||||
## 风险与控制
|
||||
|
||||
1. 预取完成与 select 同时发生时,select 等待同一 inFlight,避免重复请求。
|
||||
2. 加载遮罩 IgnorePointer,不阻断顶栏/底栏交互。
|
||||
3. PlayerPage 在正常和 loading 状态都放在相同 Stack 层级,保证 State 不因分支切换被销毁。
|
||||
4. 不改后端、ReelShortWeb、specs;不安装或操作真机。
|
||||
|
||||
## Git
|
||||
|
||||
- 提交:`fix(home): 首切频道预取并保留播放画面`
|
||||
- `--no-ff` 合回 ReelShort `develop` 并 push。
|
||||
- 作者:`Zhou Weidong <502333560@qq.com>`;禁止 `git add -A`。
|
||||
@@ -0,0 +1,54 @@
|
||||
# K95.2 首切频道用封面过渡
|
||||
|
||||
## 目标
|
||||
|
||||
- 首页频道切换后立即显示目标短剧封面,视频首帧就绪后再淡入。
|
||||
- 首页模式视频初始化期间不再显示 `player-session-loading` 大转圈。
|
||||
- 非首页播放器及票据加载状态保持现有行为。
|
||||
|
||||
## 分支
|
||||
|
||||
- ReelShort:`fix/k95.2-poster-transition`,从最新 `origin/develop` 创建。
|
||||
- FruitServer 仅写计划与 PROGRESS 留痕,不改后端功能代码。
|
||||
|
||||
## A. PlayerVideoSurface
|
||||
|
||||
- 新增可选参数 `posterUrl = ''`。
|
||||
- 未 reveal 时:
|
||||
- `posterUrl` 非空显示 `RemoteImage(path: posterUrl, fit: BoxFit.cover)`,
|
||||
Key 为 `player-video-poster`。
|
||||
- `posterUrl` 为空继续显示黑色 `ColoredBox`,保留
|
||||
`player-fallback-background` Key。
|
||||
- 视频 reveal 后继续通过现有 200ms `AnimatedOpacity` 淡入覆盖封面。
|
||||
|
||||
## B. PlayerPage
|
||||
|
||||
- `PlayerVideoSurface` 传入当前 `drama.posterUrl`。
|
||||
- `player-session-loading` 条件增加 `!widget.homeMode`:
|
||||
- 首页模式视频初始化期间只显示封面。
|
||||
- 非首页播放器继续显示原 session loading。
|
||||
- 首页 `player-ticket-loading` 不变。
|
||||
|
||||
## C. 测试
|
||||
|
||||
- 视频表面:非空 poster 显示 `player-video-poster`,空 poster 保留黑底且无封面。
|
||||
- 首页模式:视频未就绪时不出现 `player-session-loading`。
|
||||
- 非首页模式:视频未就绪时仍出现 `player-session-loading`。
|
||||
- 复跑既有播放器、首页相关测试。
|
||||
|
||||
## 门禁
|
||||
|
||||
- `dart analyze lib test`
|
||||
- `flutter test`
|
||||
- `flutter build apk --debug`
|
||||
|
||||
## Git
|
||||
|
||||
- ReelShort 提交:`fix(home): 频道切换用封面过渡`
|
||||
- `--no-ff` 合回 `develop` 并 push。
|
||||
- 作者 `Zhou Weidong <502333560@qq.com>`;禁止 `git add -A`。
|
||||
|
||||
## 约束
|
||||
|
||||
- 全程中文;不改后端、ReelShortWeb、specs。
|
||||
- 不安装或操作真机;完成后停住等待验收。
|
||||
@@ -0,0 +1,86 @@
|
||||
# K96 剧场页服务端分类分页
|
||||
|
||||
## 目标
|
||||
|
||||
- `/app/feed` 支持按分类过滤,并与内容类型过滤叠加。
|
||||
- 剧场页「全部」展示全部已上线短剧,任意分类展示该分类全部已上线短剧。
|
||||
- 列表使用游标分页,切分类优先命中缓存,支持静默刷新、加载更多和失败重试。
|
||||
|
||||
## 分支
|
||||
|
||||
- FruitServer:`feat/k96-feed-category`
|
||||
- ReelShort:`feat/k96-theater-feed`
|
||||
|
||||
## A. FruitServer
|
||||
|
||||
1. `AppCatalogController.feed` 增加可选 `Long categoryId` 并传给服务层。
|
||||
2. `AppCatalogService.feed` 增加 `categoryId`,传给
|
||||
`DramaService.listPublishedFeed`。
|
||||
3. `DramaService.listPublishedFeed` 增加 `categoryId`:
|
||||
- 非空时使用 `DramaMultiTagSupport.applyCategoryIdTokens`
|
||||
按 `category_ids` 整词匹配。
|
||||
- 游标 marker 必须同时满足已上线、内容类型命中和分类命中,否则返回空列表。
|
||||
4. 补充服务层、控制器契约测试:
|
||||
- 仅 categoryId。
|
||||
- categoryId + types。
|
||||
- 分类游标翻页。
|
||||
- marker 分类不命中返回空。
|
||||
5. 更新 `docs/api-phase1.md` 的 `/app/feed` 参数和分类过滤说明。
|
||||
|
||||
门禁:`mvn test` 全模块通过。
|
||||
|
||||
## B. ReelShort
|
||||
|
||||
### B1. API 与仓库
|
||||
|
||||
- `CatalogApi.feed` 增加可选 `String? categoryId`,非空才拼 query。
|
||||
- `CatalogRepository.fetchFeed` 同步参数,HTTP 实现透传。
|
||||
|
||||
### B2. TheaterFeedController
|
||||
|
||||
- 新增 `lib/core/data/services/theater_feed_controller.dart`。
|
||||
- 按 `String? categoryId` 独立缓存状态:
|
||||
`dramas / cursor / hasMore / loaded / loading / loadingMore / lastError /
|
||||
requestSeq / inFlight`。
|
||||
- `select(id)` 同步切分类;有数据先渲染并静默刷新,无数据时加载。
|
||||
- `loadMore` 游标追加并按 id 去重;`hasMore=false` 停止。
|
||||
- `refreshCurrent` 失败保留旧数据;切换回失败分类自动重试。
|
||||
- 单请求 10 秒超时,响应写回发起分类,requestSeq 仅处理同分类顺序。
|
||||
|
||||
### B3. 剧场接入
|
||||
|
||||
- `DiscoverPage` 创建并持有 TheaterFeedController,初始请求「全部」。
|
||||
- 「全部」和分类 chips 的网格统一读取 `theater.dramas`,不再使用
|
||||
`categories.feed.dramas` / `dramasOf`。
|
||||
- `_selectCategory` 同时更新 `DiscoverLogic.selectedCategoryId` 和
|
||||
`theater.select(categoryId)`。
|
||||
- 滚动剩余不足 400px 时触发 `loadMore`;搜索模式不触发剧场分页。
|
||||
- 下拉刷新并行执行 `categories.load()` 和 `theater.refreshCurrent()`。
|
||||
- 无缓存首屏显示转圈;空、失败和重试保持既有剧场视觉。
|
||||
|
||||
### B4. 测试
|
||||
|
||||
- TheaterFeedController:
|
||||
- 全部使用空 categoryId,分类使用对应 id。
|
||||
- 缓存切回不闪烁。
|
||||
- 分页去重、hasMore=false 停止。
|
||||
- 失败保留旧数据、失败分类切回自动重试。
|
||||
- 剧场 widget:
|
||||
- 点击分类请求对应 categoryId。
|
||||
- 接近底部触发下一页。
|
||||
- 搜索、下拉刷新与既有布局不回归。
|
||||
|
||||
门禁:`dart analyze lib test` 零告警、`flutter test` 全过、
|
||||
`flutter build apk --debug` 成功。
|
||||
|
||||
## Git
|
||||
|
||||
- FruitServer 提交:`feat(app): 推荐流支持分类过滤`
|
||||
- ReelShort 提交:`feat(theater): 剧场分类列表服务端分页`
|
||||
- 两仓库作者:`Zhou Weidong <502333560@qq.com>`,禁止 `git add -A`。
|
||||
- 各自 `--no-ff` 合回 `develop` 并 push,两仓库 PROGRESS 留痕。
|
||||
|
||||
## 约束
|
||||
|
||||
- 全程中文;不改 specs、ReelShortWeb,不改首页 K94/K95 已交付逻辑。
|
||||
- 不安装或操作真机;完成后停住等待验收。
|
||||
@@ -0,0 +1,64 @@
|
||||
# K97 修复 iOS 评论输入弹窗键盘避让
|
||||
|
||||
## 目标
|
||||
|
||||
- iOS 评论输入浮层实时跟随 `MediaQuery.viewInsets.bottom`,确保输入框与发表按钮
|
||||
位于键盘上方。
|
||||
- Android 保留既有 MethodChannel + 80ms 防抖 pinned 策略,不恢复底部 SafeArea,
|
||||
避免键盘收起时 48px 抖动回归。
|
||||
- 聚焦、`TextInput.show` 兜底和发表成功提示逻辑不变。
|
||||
|
||||
## 分支
|
||||
|
||||
- ReelShort:`fix/k97-ios-comment-keyboard`,从最新 `origin/develop` 创建。
|
||||
- FruitServer 仅写计划与 PROGRESS 留痕,不改后端功能代码。
|
||||
|
||||
## A. 平台区分
|
||||
|
||||
- `_isAndroid = !kIsWeb && defaultTargetPlatform == TargetPlatform.android`。
|
||||
- Android:
|
||||
- 继续监听 `KeyboardInsetNotifier`。
|
||||
- 继续使用 80ms 防抖后的 `_pinnedKeyboardInset`。
|
||||
- iOS / 其他平台:
|
||||
- 不读取 pinned/channel 值。
|
||||
- `build` 中直接读取 `MediaQuery.viewInsetsOf(context).bottom`。
|
||||
- inset 超过屏幕高度 60% 时按 0 处理,负值归零。
|
||||
|
||||
## B. 面板布局
|
||||
|
||||
- 面板主体使用 `AnimatedPadding`,只设置 bottom:
|
||||
- `duration: 160ms`
|
||||
- `curve: Curves.easeOutCubic`
|
||||
- Android 使用 pinned 值。
|
||||
- iOS / 其他平台使用实时 viewInsets。
|
||||
- Material 仍铺到屏幕底部,用于键盘收起后的实色填充。
|
||||
- Android 不包裹 SafeArea。
|
||||
- iOS / 其他平台包裹 `SafeArea(top: false)`,保留 home indicator 底部避让。
|
||||
|
||||
## C. 测试
|
||||
|
||||
- iOS + `viewInsets.bottom=300`:
|
||||
- 键盘避让 AnimatedPadding 的 bottom 为 300。
|
||||
- `comment-composer-post` 底边位于屏幕高度减 300 之上。
|
||||
- iOS + `viewInsets=0`:padding 为 0。
|
||||
- Android 既有 pinned/channel、焦点、弹出、关闭、发布用例保持通过。
|
||||
- 所有平台 override 测试结束恢复
|
||||
`debugDefaultTargetPlatformOverride = null`。
|
||||
|
||||
## 门禁
|
||||
|
||||
- `dart analyze lib test`
|
||||
- `flutter test`
|
||||
- `flutter build apk --debug`
|
||||
- `flutter build ios --simulator --no-codesign`
|
||||
|
||||
## Git
|
||||
|
||||
- ReelShort 提交:`fix(comment): 修复 iOS 评论输入弹窗键盘避让`
|
||||
- 作者 `Zhou Weidong <502333560@qq.com>`;禁止 `git add -A`。
|
||||
- `--no-ff` 合回 `develop` 并 push,两仓库 PROGRESS 留痕。
|
||||
|
||||
## 约束
|
||||
|
||||
- 全程中文;不改后端、ReelShortWeb、specs。
|
||||
- 不安装或操作真机;完成后停住等待验收。
|
||||
@@ -0,0 +1,73 @@
|
||||
# K98 修复登录与手机号登录键盘遮挡
|
||||
|
||||
## 目标
|
||||
|
||||
- 登录/注册页在邮箱或密码框聚焦后,自动滚动到键盘上方。
|
||||
- 手机号登录弹窗的手机号/验证码框同样保持可见。
|
||||
- Android `adjustNothing` 下通过既有 MethodChannel 获取键盘高度,iOS 使用实时
|
||||
`MediaQuery.viewInsets`。
|
||||
|
||||
## 分支
|
||||
|
||||
- ReelShort:`fix/k98-auth-keyboard`,从最新 `origin/develop` 创建。
|
||||
- FruitServer 仅写计划与 PROGRESS 留痕,不改后端功能代码。
|
||||
|
||||
## A. 有效键盘高度
|
||||
|
||||
在 `keyboard_inset.dart` 增加:
|
||||
|
||||
```dart
|
||||
double effectiveKeyboardInset(
|
||||
BuildContext context,
|
||||
KeyboardInsetNotifier notifier, {
|
||||
double maxRatio = 0.6,
|
||||
});
|
||||
```
|
||||
|
||||
- 取 MediaQuery viewInsets 与 Android channel 逻辑像素值的最大值。
|
||||
- Web/非 Android 不读取 channel。
|
||||
- 超过屏幕高度 60% 时按 0 处理,负值/非法值归零。
|
||||
|
||||
## B. AuthPage
|
||||
|
||||
1. `initState` 启动 `KeyboardInsetNotifier`,监听并用 setState 刷新。
|
||||
2. `SingleChildScrollView` 增加 `ScrollController`。
|
||||
3. 底部 padding 使用固定底部留白 + effectiveKeyboardInset。
|
||||
4. 邮箱/密码 FocusNode 监听焦点;聚焦或键盘高度变化后:
|
||||
- 通过 FocusNode.context 的 RenderBox 获取字段全局底边。
|
||||
- 与屏幕高度 - 键盘高度 - 24 比较。
|
||||
- 被遮挡时用 200ms easeOutCubic animateTo 补足滚动。
|
||||
5. `resizeToAvoidBottomInset` 保持 false。
|
||||
|
||||
## C. PhoneAuthSheet
|
||||
|
||||
1. 接入 KeyboardInsetNotifier 和 ScrollController。
|
||||
2. 底部 padding 改用 effectiveKeyboardInset。
|
||||
3. 手机号/验证码 FocusNode 增加与 AuthPage 相同的焦点/键盘变化滚动校正。
|
||||
4. 保持现有 SingleChildScrollView、弹窗和返回键行为。
|
||||
|
||||
## D. 测试
|
||||
|
||||
- iOS viewInsets=300:登录密码框、注册密码框均在键盘上方。
|
||||
- Android platform + MethodChannel 键盘高度:密码框仍在键盘上方。
|
||||
- iOS:手机号弹窗验证码框在键盘上方。
|
||||
- 所有平台 override 测试返回前显式恢复
|
||||
`debugDefaultTargetPlatformOverride = null`。
|
||||
|
||||
## 门禁
|
||||
|
||||
- `dart analyze lib test`
|
||||
- `flutter test`
|
||||
- `flutter build apk --debug`
|
||||
|
||||
## Git
|
||||
|
||||
- ReelShort 提交:`fix(auth): 登录注册与手机号登录键盘避让`
|
||||
- 作者 `Zhou Weidong <502333560@qq.com>`;禁止 `git add -A`。
|
||||
- `--no-ff` 合回 `develop` 并 push,两仓库 PROGRESS 留痕。
|
||||
|
||||
## 约束
|
||||
|
||||
- 全程中文;不改后端、ReelShortWeb、specs。
|
||||
- 不改评论输入框已验证的 Android pinned 策略。
|
||||
- 不安装或操作真机;完成后停住等待验收。
|
||||
@@ -0,0 +1,30 @@
|
||||
# 2026-10-21 | 短剧保存免费集数同步分集
|
||||
|
||||
## 目标
|
||||
|
||||
后台短剧编辑改 `freeEpisodes` / `unlockCoin` 后,同步 `drama_episode.is_free` / `unlock_coin`,与定价页 `PriceService.save()` 规则一致。
|
||||
|
||||
## 方案
|
||||
|
||||
1. 抽出 `EpisodePriceSync.syncByDramaRule(dramaId, freeEpisodes, unlockCoin)`,供 `DramaService.update` 与 `PriceService.save` 共用。
|
||||
2. `DramaService.update` 在 `updateById` 后,仅当免费集数或解锁金币相对更新前有变化时调用同步。
|
||||
3. TDD:先写 `DramaServiceTest` 复现失败,再改实现转绿。
|
||||
|
||||
## 范围
|
||||
|
||||
- 仅 `fruitshorts-module-content`
|
||||
- 不改 Controller / VO / 契约 / 前端
|
||||
|
||||
## 门禁
|
||||
|
||||
```bash
|
||||
mvn -pl fruitshorts-module-content test -Dtest=DramaServiceTest
|
||||
mvn -pl fruitshorts-module-content test
|
||||
```
|
||||
|
||||
## 分支 / 提交
|
||||
|
||||
- `feature/drama-free-episodes-sync` ← `develop`
|
||||
- `test(content): 覆盖短剧免费集数同步分集价格`
|
||||
- `fix(content): 短剧保存免费集数时同步分集免费状态`
|
||||
- `merge --no-ff` 回 develop 并 push
|
||||
@@ -0,0 +1,24 @@
|
||||
# 2026-10-21 | 短剧保存始终同步分集价格(幂等纠偏)
|
||||
|
||||
## 背景
|
||||
|
||||
承接 K104。短剧 `free_episodes=9` 重存后,分集 5~9 仍收费。
|
||||
|
||||
## 根因
|
||||
|
||||
`DramaService.update()` 仅在 `freeEpisodes` / `unlockCoin` 相对更新前有变化时调用 `EpisodePriceSync`。历史数据已漂移时,同值重存不触发同步。
|
||||
|
||||
## 方案
|
||||
|
||||
1. 测试:覆盖「规则字段未变、分集已漂移」仍纠正。
|
||||
2. `DramaService.update()`:每次保存都调用 `EpisodePriceSync.syncByDramaRule(drama)`。
|
||||
3. `EpisodePriceSync`:仅对有差异的行走 `updateById`(已具备,保持)。
|
||||
|
||||
## 范围
|
||||
|
||||
只改 `fruitshorts-module-content` 的 `DramaService` / `EpisodePriceSync` / `DramaServiceTest`。不改 Controller / VO / 契约 / 前端。
|
||||
|
||||
## 提交
|
||||
|
||||
1. `test(content): 覆盖免费集数未变但分集漂移的修复场景`
|
||||
2. `fix(content): 短剧保存时始终同步分集价格`
|
||||
@@ -0,0 +1,24 @@
|
||||
# 客户端收藏与观看历史分页
|
||||
|
||||
## 目标
|
||||
|
||||
- `/app/favorites` 改为 `PageResult<AppDramaCardVO>`,默认第 1 页、每页 20,最大 100。
|
||||
- `/app/watch/recent` 默认返回 `PageResult<ProgressRespVO>`;请求带 `limit` 时保留一版旧
|
||||
`List<ProgressRespVO>` 响应。
|
||||
- 观看历史补充短剧标题、封面、集号和总集数,剧/集均批量查询。
|
||||
|
||||
## 实现步骤
|
||||
|
||||
1. 收藏关系使用 `selectPage`,按 `created_at DESC, drama_id DESC` 稳定排序;
|
||||
只统计已上线短剧收藏,再按当前页 ID 批量加载短剧。
|
||||
2. 观看进度使用 `selectPage`,按 `updated_at DESC, drama_id DESC` 稳定排序。
|
||||
3. 当前页的 dramaId / episodeId 去重排序后,分别执行一次 IN 查询并装配展示字段。
|
||||
4. Controller 归一化 pageIndex/pageSize;观看历史根据是否传 `limit` 分流新旧响应。
|
||||
5. 更新 API 契约 §1.5,补 service/controller 测试。
|
||||
|
||||
## 风险与约束
|
||||
|
||||
- `limit` 分支仅用于旧客户端兼容,新分页响应与旧 List 响应不能混用。
|
||||
- 已下线短剧不计入收藏 total,也不出现在收藏页。
|
||||
- 观看历史展示字段找不到对应剧或集时保持 null,不影响历史记录返回。
|
||||
- 不修改客户端、不改表结构、不启停服务、不操作真机。
|
||||
@@ -0,0 +1,38 @@
|
||||
# 转码产物查询接口
|
||||
|
||||
## 目标
|
||||
|
||||
- 媒体维度查询 rendition 与帧图产物。
|
||||
- 分集维度聚合转码任务、rendition、帧图状态。
|
||||
- `/admin/dashboard/transcode` 改为明确 VO,OpenAPI 不再出现匿名 Object。
|
||||
|
||||
## 设计
|
||||
|
||||
1. `MediaTranscodeOutputService` 统一读取媒体、任务、rendition 与 thumbnail。
|
||||
2. rendition 按高度、视频码率、质量倒序,id 正序保证稳定。
|
||||
3. thumbnail 优先读取 `thumbnails.vtt`,解析 cue 后分页;无记录返回 `EMPTY`,
|
||||
记录失败返回 `FAILED`,不把缺产物当服务错误。
|
||||
4. 分集聚合对不存在、无视频、无媒资、无任务返回明确 status 和空列表。
|
||||
5. dashboard 使用强类型 queue/failed task VO,保留现有字段语义并补 total。
|
||||
|
||||
## 接口
|
||||
|
||||
- `GET /admin/media/{id}/renditions`
|
||||
- `GET /admin/media/{id}/thumbnails?pageIndex=1&pageSize=100`
|
||||
- `GET /admin/episodes/{id}/transcode`
|
||||
- `GET /admin/dashboard/transcode`(响应类型由 Map 收敛为 VO)
|
||||
|
||||
缩略图响应内嵌 `PageResult<MediaThumbnailFrameVO>`,同时返回 sprite/VTT 元数据;
|
||||
空产物 status 为 `EMPTY`,无绑定分集为 `NO_EPISODE`,损坏 VTT 为 `INVALID`。
|
||||
|
||||
## TDD
|
||||
|
||||
- 先提交媒体有/无产物、不存在、VTT 解析与分页边界测试。
|
||||
- 再提交接口、VO、聚合服务和 dashboard 类型收敛实现。
|
||||
- 门禁:`mvn -pl fruitshorts-module-media test`。
|
||||
|
||||
## 红线
|
||||
|
||||
- 不改 `/app` 契约、specs、ReelShortWeb、Flutter。
|
||||
- 不改 P1 入队与手动重转逻辑。
|
||||
- 不启停服务,不操作真机。
|
||||
@@ -0,0 +1,40 @@
|
||||
# 后台转码链路打通
|
||||
|
||||
## 现状取证
|
||||
|
||||
- 上传完成时 `MediaService.complete` 已为视频调用 `TranscodeService.enqueue`。
|
||||
- 分集创建/替换视频地址时 `EpisodeService` 已调用
|
||||
`EpisodeTranscodeBindingService.bind`,会复用并绑定同一媒体的未完成任务。
|
||||
- 转码失败原因已写入 `transcode_task.error_msg`,最终状态写入 `status`。
|
||||
- 缺口是后台手动触发/重转接口,以及对应幂等和链路测试。
|
||||
|
||||
## 实现
|
||||
|
||||
1. 保留上传完成和改片自动入队逻辑,补测试锁定行为。
|
||||
2. `TranscodeService` 增加手动触发:
|
||||
- QUEUED/RUNNING 直接返回现有任务;
|
||||
- FAILED 重置原任务为 QUEUED;
|
||||
- SUCCESS 才创建新任务,紧接着重复触发会复用新 QUEUED 任务。
|
||||
3. 新增 `POST /admin/media/{id}/transcode`,校验媒资存在,复用 `episode:upload`。
|
||||
4. 返回任务 id 与状态,便于后台提示。
|
||||
|
||||
实现时对同一媒资行使用 `FOR UPDATE`,让重复请求在事务内串行判定;
|
||||
平台不存在的媒资保持 `DATA_NOT_FOUND`,不产生任务或 500。
|
||||
|
||||
## TDD 测试矩阵
|
||||
|
||||
| 场景 | 断言 |
|
||||
| --- | --- |
|
||||
| 视频上传完成 | `MediaService.complete` 调用一次 `enqueue(assetId, 0, 0, sourceUrl)` |
|
||||
| 图片上传完成 | 不创建转码任务 |
|
||||
| 手动触发成功媒资 | 新建一个 QUEUED 任务,重复调用复用同一任务 |
|
||||
| 手动触发进行中媒资 | 直接返回 QUEUED/RUNNING 任务,不新增记录 |
|
||||
| 手动触发失败媒资 | 原任务重置为 QUEUED,保留任务 id |
|
||||
| 媒资不存在 | 返回既有 `DATA_NOT_FOUND`,控制器不产生 500 |
|
||||
| worker 最终失败 | 任务状态 FAILED,`error_msg` 保留 ffmpeg 原因 |
|
||||
|
||||
## 验证
|
||||
|
||||
- 先提交失败测试,再提交实现。
|
||||
- `mvn -pl fruitshorts-module-media,fruitshorts-transcode-worker test`
|
||||
- 不启停任何服务,不执行数据库变更,不改 Web/Flutter/specs/API 文档。
|
||||
@@ -0,0 +1,53 @@
|
||||
# 转码档位配置、雪碧图与播放缩略图轴
|
||||
|
||||
## 目标
|
||||
|
||||
1. 后台可配置转码档位与雪碧图参数,worker 对之后的新任务在 30 秒内自动生效。
|
||||
2. 转码成功后生成雪碧图与 VTT,登记到 `media_thumbnail`。
|
||||
3. 播放接口与详情剧集返回 `thumbnailsUrl`,无产物时为 `null`。
|
||||
|
||||
## 配置模型
|
||||
|
||||
- `sys_config.config_key = media.transcode.profile`,值为 JSON。
|
||||
- 配置包含总开关、分片秒数、码率阶梯与雪碧图参数。
|
||||
- 缺省配置等价于现有 360p/480p/720p/1080p 四档。
|
||||
- 后台 GET 缺省或历史配置非法时返回 yml 等价默认值;PUT 非法时返回统一 400,且不写库。
|
||||
- worker 读取配置缓存 30 秒;缺省、解析失败或校验失败时回退 yml 默认阶梯。
|
||||
|
||||
## 权限取舍
|
||||
|
||||
现有权限点没有 `media:transcode`。本次两个接口复用最小可用的
|
||||
`episode:upload`,避免新增权限点导致已有角色需要补授权;不新增菜单或权限 SQL。
|
||||
|
||||
## 数据与产物
|
||||
|
||||
- 新增 `media_thumbnail`,按 `episode_id` 唯一,记录 VTT、雪碧图前缀、采样参数、
|
||||
尺寸、帧数、时长、状态、错误与总大小。
|
||||
- 雪碧图目录固定在 `transcoded/{taskId}/thumbnails/`:
|
||||
`thumbnails.vtt` + `sprite_001.jpg` 等多张图。
|
||||
- VTT cue 链接使用相对路径 `sprite_XXX.jpg#xywh=x,y,w,h`,同一 VTT 目录下可直接解析。
|
||||
- 缩略图失败只把 `media_thumbnail.status` 置 `FAILED` 并记录错误;主 HLS 仍成功。
|
||||
|
||||
## 播放
|
||||
|
||||
- `PlayRespVO` 和 `AppEpisodeVO` 增加 `thumbnailsUrl`。
|
||||
- 查询 `media_thumbnail` 仅读取 `READY` 产物;objectKey 经
|
||||
`MediaStorageService.toPublicUrl` 后使用现有 `PlaybackSigner` 签名。
|
||||
- 详情剧集列表批量查询缩略图,禁止 N+1。
|
||||
- 不改变现有 HLS/原文件回落与 qualities 列表。
|
||||
|
||||
## 测试
|
||||
|
||||
- worker:配置解析、非法配置回退 yml、30 秒缓存、VTT 坐标、多雪碧图索引、
|
||||
缩略图失败不阻断主转码。
|
||||
- admin:GET 默认值、PUT 非法不落库、PUT 成功落库。
|
||||
- playback:有 READY 缩略图返回签名 `thumbnailsUrl`,无产物返回 `null`。
|
||||
- 门禁:`mvn -pl fruitshorts-transcode-worker,fruitshorts-admin-api,fruitshorts-app-api -am test`。
|
||||
|
||||
## 风险 / 边界
|
||||
|
||||
- 本次只对合并后的新转码任务生效,不回跑历史任务。
|
||||
- 配置中的顶层 `enabled` 会持久化并返回;本单不改变既有队列消费开关语义,
|
||||
worker 仍以 `worker-enabled` 决定是否消费任务。
|
||||
- 雪碧图生成依赖 ffmpeg `tile` 滤镜;真实产物由 worker 门禁和 PM 后续环境验收,
|
||||
本任务不启动服务、不改客户端。
|
||||
@@ -0,0 +1,38 @@
|
||||
# 转码分集绑定与运行态修复
|
||||
|
||||
## 已确认现场
|
||||
|
||||
admin-api/app-api/worker 均运行旧包;worker 未运行;`media_thumbnail` 表缺失;
|
||||
新上传任务 drama_id/episode_id 为 0;旧 worker jar 缺 MediaThumbnail。
|
||||
|
||||
## 代码修复
|
||||
|
||||
1. 分集保存后按视频 URL 的 objectKey 查找 `media_asset`。
|
||||
2. media 域新增绑定服务:
|
||||
- 将 dramaId/episodeId 回填到对应 `transcode_task`;
|
||||
- QUeued/RUNNING/SUCCESS 任务复用,不重复入队;
|
||||
- FAILED/CANCELED 或不存在时新建任务;
|
||||
- 已成功但 episodeId=0 的 rendition 同步回填。
|
||||
3. `claimNext` 只认领 `episode_id > 0`,零绑定任务保留 QUEUED。
|
||||
4. 缩略图登记使用 REQUIRES_NEW 独立事务;生成或登记失败只记 warn/error_msg,
|
||||
主任务仍 SUCCESS。
|
||||
5. 对 episode_id=0 且源文件不存在的明显测试垃圾标记 CANCELED,不删除。
|
||||
|
||||
## 迁移与运行
|
||||
|
||||
1. 确认 `media_thumbnail` 不存在后执行幂等 patch。
|
||||
2. `mvn -DskipTests package` 全量重建。
|
||||
3. 检查三个 jar 分别含:
|
||||
- admin-api:MediaTranscodeProfile;
|
||||
- app-api:PlayRespVO.thumbnailsUrl 对应新类;
|
||||
- worker:MediaThumbnail / MediaThumbnailMapper。
|
||||
4. 重启 8080/8081/worker,日志写 `logs/*.log`。
|
||||
5. 冒烟 admin 配置、App 详情 thumbnailsUrl、worker 轮询。
|
||||
6. 上传真实视频,创建绑定分集,等待 worker 消费,验证任务、四档 HLS、
|
||||
media_thumbnail、VTT 与 sprite HTTP 200。
|
||||
|
||||
## 风险
|
||||
|
||||
- 旧 QUEUED 中无法绑定且源文件不存在的测试任务将被取消并记录 id。
|
||||
- 真实视频端到端验证会写入运行数据库和媒资目录。
|
||||
- 不修改 Web/Flutter,不操作真机。
|
||||
@@ -0,0 +1,24 @@
|
||||
# 转码任务认领与媒资 ID 校验
|
||||
|
||||
## 现场结论
|
||||
|
||||
- `media_asset.id=21` 确实存在,source_url 对应分集 id=13。
|
||||
- 分集 13 的 video_asset_id=0,旧手动触发只拿媒资,不知道分集绑定,
|
||||
因而创建了 media_asset_id=21、episode_id=0 的 QUEUED 任务。
|
||||
- claim 只筛选 episode_id>0,因此该任务永久跳过且没有原因日志。
|
||||
|
||||
## 修复
|
||||
|
||||
1. POST /admin/media/{id}/transcode 严格只按 media_asset.id 查询;
|
||||
不再把候选 id 当分集 id 兜底或补登记。
|
||||
2. 媒资存在时按 source_url 反查分集;找到后绑定 drama_id/episode_id。
|
||||
3. 找不到分集时拒绝建任务,避免生成永远无法认领的 episode_id=0 记录。
|
||||
4. claim 增加 media_asset_id/source_url 条件,并记录被跳过任务 id 与原因。
|
||||
5. RUNNING 无更新阈值收敛到 5 分钟,覆盖 worker 重启后的孤儿任务。
|
||||
6. 一次性 patch 将 media_asset_id 不存在且 episode_id=0 的 QUEUED/RUNNING 标记 FAILED。
|
||||
|
||||
## 验证
|
||||
|
||||
- 非法 media id 拒绝、未绑定分集拒绝、合法 URL 自动绑定。
|
||||
- claim 跳过原因、进度更新、僵尸任务恢复。
|
||||
- `mvn -pl fruitshorts-module-media,fruitshorts-transcode-worker test`。
|
||||
@@ -0,0 +1,28 @@
|
||||
# 转码媒资 ID 精度与存量兜底修复
|
||||
|
||||
## 取证
|
||||
|
||||
- 示例分集 `2113150431755636737` 的 `video_asset_id` 为
|
||||
`2113150398670966786`,与 `media_asset.id` 完全一致。
|
||||
- JS `Number('2113150398670966786')` 序列化为 `2113150398670966800`,
|
||||
超出安全整数后发生精度丢失,导致手动转码查询了错误 ID。
|
||||
|
||||
## 修复
|
||||
|
||||
1. 聚合响应的 episodeId/mediaAssetId/taskId 使用字符串。
|
||||
2. 手动转码仍由后端 Long 接收精确路径 ID。
|
||||
3. 媒资不存在时通过 content 模块的端口按候选 ID 查找分集:
|
||||
- 分集 id;
|
||||
- video_asset_id;
|
||||
- transcode_task.id。
|
||||
4. 找到分集后按 video_url/source_url/objectKey 反查媒资;
|
||||
文件存在但媒资缺失时补登记并回填分集 video_asset_id。
|
||||
5. 无可用视频时保持明确空态/错误语义。
|
||||
|
||||
## 验证
|
||||
|
||||
- 超 2^53 ID 字符串契约。
|
||||
- 聚合无媒资空态。
|
||||
- video_url 反查命中。
|
||||
- 文件存在时补登记。
|
||||
- `mvn -pl fruitshorts-module-media,fruitshorts-transcode-worker test`。
|
||||
@@ -0,0 +1,27 @@
|
||||
# 转码保持原始宽高比
|
||||
|
||||
## 目标
|
||||
|
||||
- 横屏源按档位短边作为高度,竖屏源按档位短边作为宽度。
|
||||
- 源短边小于档位短边时按源短边输出,不放大。
|
||||
- 输出宽高均为偶数,SAR 固定为 1。
|
||||
- rendition 的 width/height 使用 ffprobe 探测到的实际值。
|
||||
|
||||
## 实施
|
||||
|
||||
1. ffprobe 读取源显示方向尺寸,旋转 90/270 度时交换宽高。
|
||||
2. `effectiveShort = min(sourceShort, rungShort)` 并向下取偶数。
|
||||
3. 横屏使用 `scale=-2:<effectiveShort>:flags=lanczos,setsar=1`;
|
||||
竖屏使用 `scale=<effectiveShort>:-2:flags=lanczos,setsar=1`。
|
||||
4. 转码完成后 ffprobe variant playlist,写入实际输出尺寸。
|
||||
5. master playlist 的 RESOLUTION 同步使用实际尺寸。
|
||||
|
||||
## 不放大策略
|
||||
|
||||
选用“用源尺寸输出”:高于源短边的档位仍保留原 quality 标识和码率,
|
||||
但分辨率封顶到源短边,避免所有档位都被跳过导致无产物。
|
||||
|
||||
## 验证
|
||||
|
||||
- 先补横屏、竖屏、小源码片、偶数、SAR=1 与实际尺寸回写测试。
|
||||
- 门禁:`mvn -pl fruitshorts-module-media,fruitshorts-transcode-worker test`。
|
||||
@@ -0,0 +1,29 @@
|
||||
# 转码错误截断与进度上报
|
||||
|
||||
## 问题
|
||||
|
||||
- ffmpeg 错误输出超过 `error_msg varchar(500)`,失败回写 UPDATE 再次失败,
|
||||
任务停在 RUNNING/0。
|
||||
- worker 未解析 ffmpeg progress,前端只能看到 0。
|
||||
- 缺少 RUNNING 超时收口。
|
||||
|
||||
## 修复
|
||||
|
||||
1. SQL patch 将 transcode_task/media_thumbnail 的 error_msg 改为 TEXT,可重复执行。
|
||||
2. 新增统一错误消息截断,最多保留 500 字符并附总长度;即使补丁尚未执行,
|
||||
也不会超过旧 varchar(500) 限制。
|
||||
3. ffmpeg 使用 `-progress` 临时文件,worker 节流为约 1 秒写 transcode_task.progress。
|
||||
4. rendition 阶段映射 0-90%,封面/缩略图 90-99%,成功后 100。
|
||||
5. 失败保留最后进度;RUNNING 超过 10 分钟无 updated_at 变化标记 FAILED。
|
||||
6. 手动重转复用最新任务,SUCCESS/FAILED/CANCELED 原地重置为 QUEUED、progress=0。
|
||||
7. 成功写 rendition 前替换同媒资旧产物,避免重复重转唯一键冲突。
|
||||
|
||||
## 风险
|
||||
|
||||
- 进度写入只允许 RUNNING 状态,避免覆盖已完成/失败状态。
|
||||
- 历史僵尸任务由 worker 下一轮自动收口,无需手工 SQL。
|
||||
|
||||
## 验证
|
||||
|
||||
- 错误截断、进度更新、僵尸重置、重复触发幂等测试。
|
||||
- `mvn -pl fruitshorts-module-media,fruitshorts-transcode-worker test`。
|
||||
@@ -0,0 +1,24 @@
|
||||
# 转码 rendition 幂等与失败落库
|
||||
|
||||
## 根因
|
||||
|
||||
- 成功事务只按 media_asset_id 删除旧 rendition。
|
||||
- 同一分集替换视频后 media_asset_id 改变、episode_id 不变,
|
||||
旧行未被删除,触发 uk_rendition(episode_id, quality, format)。
|
||||
- rendition 插入异常后任务未被可靠置为 FAILED。
|
||||
|
||||
## 修复
|
||||
|
||||
1. 成功事务删除条件分组为:
|
||||
`media_asset_id = 本次媒体 OR (episode_id > 0 AND episode_id = 本次分集)`。
|
||||
2. 缩略图登记按 episode_id 删除旧行后重新插入。
|
||||
3. 主流程异常调用 failFinal,直接写 FAILED、错误、finished_at,保留 progress。
|
||||
4. failFinal 自身异常在 worker 中 catch 并打印 ERROR,不静默。
|
||||
5. error 截断同时保留头部与尾部,长度仍 <= 500。
|
||||
|
||||
## 验证
|
||||
|
||||
- 不同 media_asset_id、同 episode_id 的重复转码清理条件。
|
||||
- thumbnail 旧行替换。
|
||||
- 失败落库字段与尾段错误保留。
|
||||
- `mvn -q -DskipTests=false test -pl ... -am`。
|
||||
+72
-2505
File diff suppressed because it is too large.
Load diff
+21976
File diff suppressed because it is too large.
Load diff
+13
-2
@@ -4,6 +4,7 @@ package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.admin.service.AppSessionSystemService;
|
||||
import com.fruitshorts.admin.vo.AppUserWatchHistoryVO;
|
||||
import com.fruitshorts.content.dal.entity.Drama;
|
||||
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
||||
@@ -13,6 +14,7 @@ import com.fruitshorts.content.service.EpisodeService;
|
||||
import com.fruitshorts.framework.log.OperationLog;
|
||||
import com.fruitshorts.framework.security.SecurityUtils;
|
||||
import com.fruitshorts.playback.dal.entity.WatchHistory;
|
||||
import com.fruitshorts.user.dal.entity.AppUserSession;
|
||||
import com.fruitshorts.playback.service.WatchProgressService;
|
||||
import com.fruitshorts.user.dal.entity.AppUserBanRecord;
|
||||
import com.fruitshorts.user.service.AppUserAdminService;
|
||||
@@ -44,6 +46,7 @@ public class AppUserAdminController {
|
||||
private final WatchProgressService watchProgressService;
|
||||
private final DramaService dramaService;
|
||||
private final EpisodeService episodeService;
|
||||
private final AppSessionSystemService sessionSystem;
|
||||
|
||||
@Operation(summary = "App 用户分页查询")
|
||||
@GetMapping("/page")
|
||||
@@ -83,11 +86,15 @@ public class AppUserAdminController {
|
||||
Map<Long, DramaEpisode> episodes = episodeService
|
||||
.listByIds(rows.stream().map(WatchHistory::getEpisodeId).distinct().toList())
|
||||
.stream().collect(Collectors.toMap(DramaEpisode::getId, item -> item, (a, b) -> a));
|
||||
return Result.ok(rows.stream().map(row -> toVo(row, dramas, episodes)).toList());
|
||||
List<AppUserSession> sessions = sessionSystem.groupByUser(List.of(id))
|
||||
.getOrDefault(id, List.of());
|
||||
return Result.ok(rows.stream()
|
||||
.map(row -> toVo(row, dramas, episodes, sessionSystem.match(sessions, row.getDeviceId())))
|
||||
.toList());
|
||||
}
|
||||
|
||||
private AppUserWatchHistoryVO toVo(WatchHistory row, Map<Long, Drama> dramas,
|
||||
Map<Long, DramaEpisode> episodes) {
|
||||
Map<Long, DramaEpisode> episodes, AppUserSession session) {
|
||||
AppUserWatchHistoryVO vo = new AppUserWatchHistoryVO();
|
||||
vo.setId(row.getId());
|
||||
vo.setDramaId(row.getDramaId());
|
||||
@@ -100,6 +107,10 @@ public class AppUserAdminController {
|
||||
long position = row.getPositionMs() == null ? 0L : row.getPositionMs();
|
||||
long duration = row.getDurationMs() == null ? 0L : row.getDurationMs();
|
||||
vo.setFinished(duration > 0 && position + 1000L >= duration);
|
||||
if (session != null) {
|
||||
vo.setPlatform(session.getPlatform());
|
||||
vo.setOsVersion(session.getOsVersion());
|
||||
}
|
||||
Drama drama = dramas.get(row.getDramaId());
|
||||
if (drama != null) {
|
||||
vo.setDramaTitle(drama.getTitle());
|
||||
|
||||
+2
-2
@@ -35,8 +35,8 @@ public class CommentAdminController {
|
||||
|
||||
private final CommentService commentService;
|
||||
|
||||
/** 检索评论:默认按状态过滤,`status=pending` 即审核队列。 */
|
||||
@Operation(summary = "评论检索(默认按状态过滤,待审队列)")
|
||||
/** 检索评论:status 为空时返回全部状态,传 pending 即审核队列。 */
|
||||
@Operation(summary = "评论检索(status 为空返回全部状态)")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@ss.hasPermission('comment:list')")
|
||||
public Result<PageResult<CommentRespVO>> page(CommentQueryReqVO req) {
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.admin.service.DashboardService;
|
||||
import com.fruitshorts.admin.vo.TranscodeDashboardRespVO;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -40,7 +41,7 @@ public class DashboardAdminController {
|
||||
@Operation(summary = "转码看板(队列积压与失败任务)")
|
||||
@GetMapping("/transcode")
|
||||
@PreAuthorize("@ss.hasPermission('dashboard:view')")
|
||||
public Result<Map<String, Object>> transcode() {
|
||||
public Result<TranscodeDashboardRespVO> transcode() {
|
||||
return Result.ok(dashboardService.transcode());
|
||||
}
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.content.service.DramaClassificationService;
|
||||
import com.fruitshorts.content.vo.DramaBriefVO;
|
||||
import com.fruitshorts.content.vo.DramaClassificationRespVO;
|
||||
import com.fruitshorts.content.vo.DramaClassificationSaveReqVO;
|
||||
import com.fruitshorts.content.vo.DramaIdsReqVO;
|
||||
import com.fruitshorts.framework.log.OperationLog;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 运营分类管理。分类与短剧类型(drama-categories)是两套独立概念,
|
||||
* 分类可自定义增删,并关联任意多部短剧。
|
||||
*/
|
||||
@Tag(name = "后台-运营分类")
|
||||
@RestController
|
||||
@RequestMapping("/admin/drama-classifications")
|
||||
@RequiredArgsConstructor
|
||||
public class DramaClassificationController {
|
||||
|
||||
private final DramaClassificationService classificationService;
|
||||
|
||||
@Operation(summary = "分类列表(带关联数量)")
|
||||
@GetMapping
|
||||
@PreAuthorize("@ss.hasPermission('drama:list')")
|
||||
public Result<List<DramaClassificationRespVO>> list() {
|
||||
return Result.ok(classificationService.list());
|
||||
}
|
||||
|
||||
@Operation(summary = "新建分类")
|
||||
@PostMapping
|
||||
@PreAuthorize("@ss.hasPermission('drama:create')")
|
||||
@OperationLog(module = "内容管理", action = "新增分类")
|
||||
public Result<Long> create(@Valid @RequestBody DramaClassificationSaveReqVO req) {
|
||||
return Result.ok(classificationService.create(req));
|
||||
}
|
||||
|
||||
@Operation(summary = "编辑分类")
|
||||
@PutMapping("/{id}")
|
||||
@PreAuthorize("@ss.hasPermission('drama:update')")
|
||||
@OperationLog(module = "内容管理", action = "编辑分类")
|
||||
public Result<Void> update(@PathVariable Long id,
|
||||
@Valid @RequestBody DramaClassificationSaveReqVO req) {
|
||||
classificationService.update(id, req);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "删除分类")
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@ss.hasPermission('drama:delete')")
|
||||
@OperationLog(module = "内容管理", action = "删除分类")
|
||||
public Result<Void> delete(@PathVariable Long id) {
|
||||
classificationService.delete(id);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "分类下已关联的短剧")
|
||||
@GetMapping("/{id}/dramas")
|
||||
@PreAuthorize("@ss.hasPermission('drama:list')")
|
||||
public Result<PageResult<DramaBriefVO>> dramas(
|
||||
@PathVariable Long id,
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(defaultValue = "1") int pageIndex,
|
||||
@RequestParam(defaultValue = "10") int pageSize) {
|
||||
return Result.ok(classificationService.pageDramas(id, keyword, pageIndex, pageSize));
|
||||
}
|
||||
|
||||
@Operation(summary = "尚未关联到该分类的短剧")
|
||||
@GetMapping("/{id}/dramas/candidates")
|
||||
@PreAuthorize("@ss.hasPermission('drama:list')")
|
||||
public Result<PageResult<DramaBriefVO>> candidates(
|
||||
@PathVariable Long id,
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(defaultValue = "1") int pageIndex,
|
||||
@RequestParam(defaultValue = "10") int pageSize) {
|
||||
return Result.ok(classificationService.pageCandidates(id, keyword, pageIndex, pageSize));
|
||||
}
|
||||
|
||||
@Operation(summary = "批量关联短剧")
|
||||
@PostMapping("/{id}/dramas")
|
||||
@PreAuthorize("@ss.hasPermission('drama:update')")
|
||||
@OperationLog(module = "内容管理", action = "分类关联短剧")
|
||||
public Result<Integer> bindDramas(@PathVariable Long id,
|
||||
@Valid @RequestBody DramaIdsReqVO req) {
|
||||
return Result.ok(classificationService.bindDramas(id, req.getDramaIds()));
|
||||
}
|
||||
|
||||
@Operation(summary = "移除分类下的短剧")
|
||||
@DeleteMapping("/{id}/dramas/{dramaId}")
|
||||
@PreAuthorize("@ss.hasPermission('drama:update')")
|
||||
@OperationLog(module = "内容管理", action = "分类移除短剧")
|
||||
public Result<Void> unbindDrama(@PathVariable Long id, @PathVariable Long dramaId) {
|
||||
classificationService.unbindDrama(id, dramaId);
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
||||
+25
-3
@@ -6,12 +6,14 @@ import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.content.dal.entity.DramaReviewRecord;
|
||||
import com.fruitshorts.content.service.DramaService;
|
||||
import com.fruitshorts.content.service.EpisodeService;
|
||||
import com.fruitshorts.content.vo.DramaPageReqVO;
|
||||
import com.fruitshorts.content.vo.DramaRespVO;
|
||||
import com.fruitshorts.content.vo.DramaSaveReqVO;
|
||||
import com.fruitshorts.content.vo.DramaStatusReqVO;
|
||||
import com.fruitshorts.framework.security.SecurityUtils;
|
||||
import com.fruitshorts.framework.log.OperationLog;
|
||||
import com.fruitshorts.framework.security.SecurityUtils;
|
||||
import com.fruitshorts.interaction.service.CommentService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -27,6 +29,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Tag(name = "后台-短剧管理")
|
||||
@RestController
|
||||
@@ -35,19 +38,25 @@ import java.util.List;
|
||||
public class DramaController {
|
||||
|
||||
private final DramaService dramaService;
|
||||
private final CommentService commentService;
|
||||
private final EpisodeService episodeService;
|
||||
|
||||
@Operation(summary = "短剧分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@ss.hasPermission('drama:list')")
|
||||
public Result<PageResult<DramaRespVO>> page(DramaPageReqVO req) {
|
||||
return Result.ok(dramaService.page(req));
|
||||
PageResult<DramaRespVO> page = dramaService.page(req);
|
||||
fillInteractionCounts(page.getList());
|
||||
return Result.ok(page);
|
||||
}
|
||||
|
||||
@Operation(summary = "短剧详情")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@ss.hasPermission('drama:list')")
|
||||
public Result<DramaRespVO> get(@PathVariable Long id) {
|
||||
return Result.ok(dramaService.get(id));
|
||||
DramaRespVO drama = dramaService.get(id);
|
||||
fillInteractionCounts(List.of(drama));
|
||||
return Result.ok(drama);
|
||||
}
|
||||
|
||||
@Operation(summary = "新建短剧")
|
||||
@@ -133,4 +142,17 @@ public class DramaController {
|
||||
dramaService.changeStatus(id, action, req == null ? null : req.getReason(),
|
||||
SecurityUtils.getUserId(), SecurityUtils.getUsername());
|
||||
}
|
||||
|
||||
private void fillInteractionCounts(List<DramaRespVO> dramas) {
|
||||
if (dramas == null || dramas.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<Long> ids = dramas.stream().map(DramaRespVO::getId).toList();
|
||||
Map<Long, Long> likeCounts = episodeService.sumLikeCountsByDramas(ids);
|
||||
Map<Long, Long> commentCounts = commentService.countByDramas(ids);
|
||||
dramas.forEach(drama -> {
|
||||
drama.setLikeCount(likeCounts.getOrDefault(drama.getId(), 0L));
|
||||
drama.setCommentCount(commentCounts.getOrDefault(drama.getId(), 0L));
|
||||
});
|
||||
}
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.content.service.DramaPlaylistCategoryService;
|
||||
import com.fruitshorts.content.vo.DramaBriefVO;
|
||||
import com.fruitshorts.content.vo.DramaIdsReqVO;
|
||||
import com.fruitshorts.content.vo.DramaPlaylistCategoryRespVO;
|
||||
import com.fruitshorts.content.vo.DramaPlaylistCategorySaveReqVO;
|
||||
import com.fruitshorts.framework.log.OperationLog;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 剧单分类管理:分类直接关联短剧,没有「剧单」这一层。
|
||||
* 与「类型」「分类管理」均无关。
|
||||
*/
|
||||
@Tag(name = "后台-剧单分类")
|
||||
@RestController
|
||||
@RequestMapping("/admin/drama-playlist-categories")
|
||||
@RequiredArgsConstructor
|
||||
public class DramaPlaylistCategoryController {
|
||||
|
||||
private final DramaPlaylistCategoryService categoryService;
|
||||
|
||||
@Operation(summary = "剧单分类列表")
|
||||
@GetMapping
|
||||
@PreAuthorize("@ss.hasPermission('drama:list')")
|
||||
public Result<List<DramaPlaylistCategoryRespVO>> list() {
|
||||
return Result.ok(categoryService.list());
|
||||
}
|
||||
|
||||
@Operation(summary = "新建剧单分类")
|
||||
@PostMapping
|
||||
@PreAuthorize("@ss.hasPermission('drama:create')")
|
||||
@OperationLog(module = "内容管理", action = "新增剧单分类")
|
||||
public Result<Long> create(@Valid @RequestBody DramaPlaylistCategorySaveReqVO req) {
|
||||
return Result.ok(categoryService.create(req));
|
||||
}
|
||||
|
||||
@Operation(summary = "编辑剧单分类")
|
||||
@PutMapping("/{id}")
|
||||
@PreAuthorize("@ss.hasPermission('drama:update')")
|
||||
@OperationLog(module = "内容管理", action = "编辑剧单分类")
|
||||
public Result<Void> update(@PathVariable Long id,
|
||||
@Valid @RequestBody DramaPlaylistCategorySaveReqVO req) {
|
||||
categoryService.update(id, req);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "删除剧单分类")
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@ss.hasPermission('drama:delete')")
|
||||
@OperationLog(module = "内容管理", action = "删除剧单分类")
|
||||
public Result<Void> delete(@PathVariable Long id) {
|
||||
categoryService.delete(id);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "分类下已关联的短剧")
|
||||
@GetMapping("/{id}/dramas")
|
||||
@PreAuthorize("@ss.hasPermission('drama:list')")
|
||||
public Result<PageResult<DramaBriefVO>> dramas(
|
||||
@PathVariable Long id,
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(defaultValue = "1") int pageIndex,
|
||||
@RequestParam(defaultValue = "10") int pageSize) {
|
||||
return Result.ok(categoryService.pageDramas(id, keyword, pageIndex, pageSize));
|
||||
}
|
||||
|
||||
@Operation(summary = "尚未关联到该分类的短剧")
|
||||
@GetMapping("/{id}/dramas/candidates")
|
||||
@PreAuthorize("@ss.hasPermission('drama:list')")
|
||||
public Result<PageResult<DramaBriefVO>> candidates(
|
||||
@PathVariable Long id,
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(defaultValue = "1") int pageIndex,
|
||||
@RequestParam(defaultValue = "10") int pageSize) {
|
||||
return Result.ok(categoryService.pageCandidates(id, keyword, pageIndex, pageSize));
|
||||
}
|
||||
|
||||
@Operation(summary = "批量关联短剧")
|
||||
@PostMapping("/{id}/dramas")
|
||||
@PreAuthorize("@ss.hasPermission('drama:update')")
|
||||
@OperationLog(module = "内容管理", action = "剧单分类关联短剧")
|
||||
public Result<Integer> bindDramas(@PathVariable Long id,
|
||||
@Valid @RequestBody DramaIdsReqVO req) {
|
||||
return Result.ok(categoryService.bindDramas(id, req.getDramaIds()));
|
||||
}
|
||||
|
||||
@Operation(summary = "移除分类下的短剧")
|
||||
@DeleteMapping("/{id}/dramas/{dramaId}")
|
||||
@PreAuthorize("@ss.hasPermission('drama:update')")
|
||||
@OperationLog(module = "内容管理", action = "剧单分类移除短剧")
|
||||
public Result<Void> unbindDrama(@PathVariable Long id, @PathVariable Long dramaId) {
|
||||
categoryService.unbindDrama(id, dramaId);
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
||||
+23
-4
@@ -2,12 +2,16 @@
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.content.dal.entity.Drama;
|
||||
import com.fruitshorts.content.service.DramaService;
|
||||
import com.fruitshorts.content.service.EpisodeService;
|
||||
import com.fruitshorts.content.vo.EpisodeRespVO;
|
||||
import com.fruitshorts.content.vo.EpisodeSaveReqVO;
|
||||
import com.fruitshorts.content.vo.EpisodeSortReqVO;
|
||||
import com.fruitshorts.framework.log.OperationLog;
|
||||
import com.fruitshorts.interaction.service.CommentService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -24,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Tag(name = "后台-剧集管理")
|
||||
@RestController
|
||||
@@ -32,13 +37,27 @@ import java.util.List;
|
||||
public class EpisodeController {
|
||||
|
||||
private final EpisodeService episodeService;
|
||||
private final CommentService commentService;
|
||||
private final DramaService dramaService;
|
||||
|
||||
@Operation(summary = "剧集列表")
|
||||
@Operation(summary = "剧集列表(分页)")
|
||||
@GetMapping
|
||||
@PreAuthorize("@ss.hasPermission('episode:list')")
|
||||
public Result<List<EpisodeRespVO>> list(@RequestParam Long dramaId,
|
||||
@RequestParam(required = false) String status) {
|
||||
return Result.ok(episodeService.listByDrama(dramaId, status));
|
||||
public Result<PageResult<EpisodeRespVO>> list(@RequestParam Long dramaId,
|
||||
@RequestParam(required = false) String status,
|
||||
@RequestParam(required = false) Integer pageIndex,
|
||||
@RequestParam(required = false) Integer pageSize) {
|
||||
PageResult<EpisodeRespVO> page = episodeService.pageByDrama(dramaId, status, pageIndex, pageSize);
|
||||
List<EpisodeRespVO> episodes = page.getList();
|
||||
Map<Long, Long> commentCounts = commentService.countByEpisodes(
|
||||
episodes.stream().map(EpisodeRespVO::getId).toList());
|
||||
Drama drama = dramaService.getExisting(dramaId);
|
||||
episodes.forEach(episode -> {
|
||||
episode.setCommentCount(commentCounts.getOrDefault(episode.getId(), 0L));
|
||||
episode.setFavoriteCount(drama.getFavoriteCount());
|
||||
episode.setHeat(drama.getViewCount());
|
||||
});
|
||||
return Result.ok(new PageResult<>(page.getTotal(), episodes));
|
||||
}
|
||||
|
||||
@Operation(summary = "新建剧集")
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.admin.service.EpisodeTranscodeAdminService;
|
||||
import com.fruitshorts.admin.vo.EpisodeTranscodeRespVO;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/** 后台剧集转码聚合查询。 */
|
||||
@Tag(name = "后台-剧集转码")
|
||||
@RestController
|
||||
@RequestMapping("/admin/episodes")
|
||||
@RequiredArgsConstructor
|
||||
public class EpisodeTranscodeController {
|
||||
|
||||
private final EpisodeTranscodeAdminService service;
|
||||
|
||||
@Operation(summary = "查询分集转码聚合信息")
|
||||
@GetMapping("/{id}/transcode")
|
||||
@PreAuthorize("@ss.hasPermission('episode:list')")
|
||||
public Result<EpisodeTranscodeRespVO> detail(@PathVariable Long id) {
|
||||
return Result.ok(service.detail(id));
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.framework.log.OperationLog;
|
||||
import com.fruitshorts.system.service.LegalDocumentService;
|
||||
import com.fruitshorts.system.vo.LegalDocumentVO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 后台维护服务条款和隐私协议。公开页面由客户端服务按语言输出。
|
||||
*/
|
||||
@Tag(name = "后台-协议")
|
||||
@RestController
|
||||
@RequestMapping("/admin/legal-documents")
|
||||
@RequiredArgsConstructor
|
||||
public class LegalDocumentAdminController {
|
||||
|
||||
private final LegalDocumentService legalDocumentService;
|
||||
|
||||
@Operation(summary = "协议列表(服务条款、隐私协议,各含中英印尼语)")
|
||||
@GetMapping
|
||||
@PreAuthorize("@ss.hasAnyPermission('system:role','system:menu')")
|
||||
public Result<List<LegalDocumentVO>> list() {
|
||||
return Result.ok(legalDocumentService.list());
|
||||
}
|
||||
|
||||
@Operation(summary = "保存协议")
|
||||
@PutMapping
|
||||
@PreAuthorize("@ss.hasPermission('system:role')")
|
||||
@OperationLog(module = "后台管理", action = "修改服务条款或隐私协议")
|
||||
public Result<Void> save(@RequestBody List<LegalDocumentVO> items) {
|
||||
legalDocumentService.save(items);
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
||||
+32
@@ -5,8 +5,12 @@ package com.fruitshorts.admin.controller;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.framework.security.SecurityUtils;
|
||||
import com.fruitshorts.framework.security.ImpersonationGuard;
|
||||
import com.fruitshorts.framework.log.OperationLog;
|
||||
import com.fruitshorts.media.config.MediaTranscodeProfile;
|
||||
import com.fruitshorts.media.service.MediaService;
|
||||
import com.fruitshorts.media.service.MediaTranscodeProfileService;
|
||||
import com.fruitshorts.media.vo.MediaAssetRespVO;
|
||||
import com.fruitshorts.media.vo.TranscodeTriggerRespVO;
|
||||
import com.fruitshorts.media.vo.UploadCompleteReqVO;
|
||||
import com.fruitshorts.media.vo.UploadInitReqVO;
|
||||
import com.fruitshorts.media.vo.UploadInitRespVO;
|
||||
@@ -19,6 +23,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -35,6 +40,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
public class MediaController {
|
||||
|
||||
private final MediaService mediaService;
|
||||
private final MediaTranscodeProfileService profileService;
|
||||
|
||||
@Operation(summary = "初始化分片上传")
|
||||
@PostMapping("/upload/init")
|
||||
@@ -78,4 +84,30 @@ public class MediaController {
|
||||
public Result<MediaAssetRespVO> get(@PathVariable Long id) {
|
||||
return Result.ok(mediaService.get(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "手动触发或重转媒资")
|
||||
@PostMapping("/{id}/transcode")
|
||||
@PreAuthorize("@ss.hasPermission('episode:upload')")
|
||||
@OperationLog(module = "后台管理", action = "触发媒资转码")
|
||||
public Result<TranscodeTriggerRespVO> transcode(@PathVariable Long id) {
|
||||
ImpersonationGuard.rejectWrite();
|
||||
return Result.ok(mediaService.triggerTranscode(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "读取转码档位配置")
|
||||
@GetMapping("/transcode-profile")
|
||||
@PreAuthorize("@ss.hasPermission('episode:upload')")
|
||||
public Result<MediaTranscodeProfile> transcodeProfile() {
|
||||
return Result.ok(profileService.readConfiguredProfile());
|
||||
}
|
||||
|
||||
@Operation(summary = "保存转码档位配置")
|
||||
@PutMapping("/transcode-profile")
|
||||
@PreAuthorize("@ss.hasPermission('episode:upload')")
|
||||
@OperationLog(module = "后台管理", action = "修改转码设置")
|
||||
public Result<MediaTranscodeProfile> saveTranscodeProfile(
|
||||
@Valid @RequestBody MediaTranscodeProfile profile) {
|
||||
ImpersonationGuard.rejectWrite();
|
||||
return Result.ok(profileService.save(profile));
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.media.service.MediaTranscodeOutputService;
|
||||
import com.fruitshorts.media.vo.MediaRenditionRespVO;
|
||||
import com.fruitshorts.media.vo.MediaThumbnailRespVO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** 后台媒资转码产物只读查询。 */
|
||||
@Tag(name = "后台-媒资转码产物")
|
||||
@RestController
|
||||
@RequestMapping("/admin/media")
|
||||
@RequiredArgsConstructor
|
||||
public class MediaTranscodeOutputController {
|
||||
|
||||
private final MediaTranscodeOutputService outputService;
|
||||
|
||||
@Operation(summary = "查询媒资清晰度产物")
|
||||
@GetMapping("/{id}/renditions")
|
||||
@PreAuthorize("@ss.hasPermission('episode:upload')")
|
||||
public Result<List<MediaRenditionRespVO>> renditions(@PathVariable Long id) {
|
||||
return Result.ok(outputService.renditions(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询媒资帧图产物")
|
||||
@GetMapping("/{id}/thumbnails")
|
||||
@PreAuthorize("@ss.hasPermission('episode:upload')")
|
||||
public Result<MediaThumbnailRespVO> thumbnails(
|
||||
@PathVariable Long id,
|
||||
@RequestParam(defaultValue = "1") Integer pageIndex,
|
||||
@RequestParam(defaultValue = "100") Integer pageSize) {
|
||||
return Result.ok(outputService.thumbnails(id, pageIndex, pageSize));
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -2,11 +2,12 @@
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.admin.service.ReportAdminService;
|
||||
import com.fruitshorts.admin.vo.AdminReportRespVO;
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.framework.log.OperationLog;
|
||||
import com.fruitshorts.framework.security.SecurityUtils;
|
||||
import com.fruitshorts.interaction.dal.entity.ContentReport;
|
||||
import com.fruitshorts.interaction.service.ReportService;
|
||||
import com.fruitshorts.interaction.vo.ReportHandleReqVO;
|
||||
import com.fruitshorts.interaction.vo.ReportQueryReqVO;
|
||||
@@ -28,13 +29,14 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequiredArgsConstructor
|
||||
public class ReportAdminController {
|
||||
|
||||
private final ReportAdminService reportAdminService;
|
||||
private final ReportService reportService;
|
||||
|
||||
@Operation(summary = "举报工单分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@ss.hasPermission('report:list')")
|
||||
public Result<PageResult<ContentReport>> page(ReportQueryReqVO req) {
|
||||
return Result.ok(reportService.page(req));
|
||||
public Result<PageResult<AdminReportRespVO>> page(ReportQueryReqVO req) {
|
||||
return Result.ok(reportAdminService.page(req));
|
||||
}
|
||||
|
||||
/** 处理工单:结论成立会联动驳回被举报评论,可选择同时封禁被举报用户。 */
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.admin.service.WatchHistoryAdminService;
|
||||
import com.fruitshorts.admin.vo.AdminWatchHistoryVO;
|
||||
import com.fruitshorts.admin.vo.WatchHistoryQueryReqVO;
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/** 后台跨用户观看记录检索。 */
|
||||
@Tag(name = "后台-观看记录")
|
||||
@RestController
|
||||
@RequestMapping("/admin/watch-history")
|
||||
@RequiredArgsConstructor
|
||||
public class WatchHistoryAdminController {
|
||||
|
||||
private final WatchHistoryAdminService watchHistoryAdminService;
|
||||
|
||||
@Operation(summary = "观看记录分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@ss.hasPermission('watch-history:list')")
|
||||
public Result<PageResult<AdminWatchHistoryVO>> page(WatchHistoryQueryReqVO req) {
|
||||
return Result.ok(watchHistoryAdminService.page(req));
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.fruitshorts.user.dal.entity.AppUserSession;
|
||||
import com.fruitshorts.user.dal.mapper.AppUserSessionMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 按用户最近会话解析系统。同一设备优先,否则用仍有效的最近一次登录。
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AppSessionSystemService {
|
||||
|
||||
private final AppUserSessionMapper sessionMapper;
|
||||
|
||||
/** 按用户分组,组内按最近活跃倒序。 */
|
||||
public Map<Long, List<AppUserSession>> groupByUser(Collection<Long> userIds) {
|
||||
Map<Long, List<AppUserSession>> grouped = new HashMap<>();
|
||||
if (userIds == null || userIds.isEmpty()) {
|
||||
return grouped;
|
||||
}
|
||||
List<AppUserSession> sessions = sessionMapper.selectList(Wrappers.<AppUserSession>lambdaQuery()
|
||||
.in(AppUserSession::getUserId, userIds)
|
||||
.orderByDesc(AppUserSession::getLastActiveAt)
|
||||
.orderByDesc(AppUserSession::getId));
|
||||
for (AppUserSession session : sessions) {
|
||||
grouped.computeIfAbsent(session.getUserId(), key -> new ArrayList<>()).add(session);
|
||||
}
|
||||
return grouped;
|
||||
}
|
||||
|
||||
/** 观看记录优先匹配同一设备,其次取未吊销会话。 */
|
||||
public AppUserSession match(List<AppUserSession> sessions, String deviceId) {
|
||||
if (sessions == null || sessions.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (StringUtils.hasText(deviceId)) {
|
||||
for (AppUserSession session : sessions) {
|
||||
if (deviceId.equals(session.getDeviceId())) {
|
||||
return session;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (AppUserSession session : sessions) {
|
||||
if (session.getRevokedAt() == null) {
|
||||
return session;
|
||||
}
|
||||
}
|
||||
return sessions.get(0);
|
||||
}
|
||||
}
|
||||
+17
-12
@@ -3,6 +3,7 @@
|
||||
package com.fruitshorts.admin.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.fruitshorts.admin.vo.TranscodeDashboardRespVO;
|
||||
import com.fruitshorts.commerce.dal.entity.CoinLedger;
|
||||
import com.fruitshorts.commerce.dal.entity.Entitlement;
|
||||
import com.fruitshorts.commerce.dal.entity.Orders;
|
||||
@@ -21,6 +22,8 @@ import com.fruitshorts.interaction.dal.entity.ContentReport;
|
||||
import com.fruitshorts.interaction.dal.mapper.ContentCommentMapper;
|
||||
import com.fruitshorts.interaction.dal.mapper.ContentReportMapper;
|
||||
import com.fruitshorts.media.service.TranscodeService;
|
||||
import com.fruitshorts.media.vo.TranscodeQueueStatsVO;
|
||||
import com.fruitshorts.media.vo.TranscodeTaskRespVO;
|
||||
import com.fruitshorts.playback.dal.entity.WatchHistory;
|
||||
import com.fruitshorts.playback.dal.entity.WatchProgress;
|
||||
import com.fruitshorts.playback.dal.mapper.WatchHistoryMapper;
|
||||
@@ -101,12 +104,14 @@ public class DashboardService {
|
||||
}
|
||||
|
||||
/** 转码看板:队列积压与失败明细。 */
|
||||
public Map<String, Object> transcode() {
|
||||
Map<String, Object> data = new LinkedHashMap<>();
|
||||
data.put("generatedAt", LocalDateTime.now());
|
||||
data.put("queue", transcodeService.stats());
|
||||
data.put("failedTasks", transcodeService.failedTasks(20));
|
||||
data.put("notes", List.of(
|
||||
public TranscodeDashboardRespVO transcode() {
|
||||
TranscodeDashboardRespVO data = new TranscodeDashboardRespVO();
|
||||
data.setGeneratedAt(LocalDateTime.now());
|
||||
data.setQueue(transcodeService.stats());
|
||||
data.setFailedTasks(transcodeService.failedTasks(20).stream()
|
||||
.map(TranscodeTaskRespVO::from)
|
||||
.toList());
|
||||
data.setNotes(List.of(
|
||||
"queue 为累计口径(不限时间),反映当前积压与历史成败分布",
|
||||
"failedTasks 最多返回 20 条,按 id 倒序"));
|
||||
return data;
|
||||
@@ -205,12 +210,12 @@ public class DashboardService {
|
||||
|
||||
private Map<String, Object> costMetrics(LocalDateTime sevenDaysAgo) {
|
||||
Map<String, Object> cost = new LinkedHashMap<>();
|
||||
Map<String, Object> queue = transcodeService.stats();
|
||||
cost.put("transcodeQueued", queue.get("queued"));
|
||||
cost.put("transcodeRunning", queue.get("running"));
|
||||
cost.put("transcodeFailed", queue.get("failed"));
|
||||
cost.put("transcodeSuccess", queue.get("success"));
|
||||
cost.put("renditions", queue.get("renditions"));
|
||||
TranscodeQueueStatsVO queue = transcodeService.stats();
|
||||
cost.put("transcodeQueued", queue.getQueued());
|
||||
cost.put("transcodeRunning", queue.getRunning());
|
||||
cost.put("transcodeFailed", queue.getFailed());
|
||||
cost.put("transcodeSuccess", queue.getSuccess());
|
||||
cost.put("renditions", queue.getRenditions());
|
||||
cost.put("otpSent7d", appUserOtpMapper.selectCount(Wrappers.<AppUserOtp>lambdaQuery()
|
||||
.ge(AppUserOtp::getCreatedAt, sevenDaysAgo)));
|
||||
cost.put("cdnTrafficBytes", null);
|
||||
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.service;
|
||||
|
||||
import com.fruitshorts.admin.vo.EpisodeTranscodeRespVO;
|
||||
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
||||
import com.fruitshorts.content.dal.mapper.DramaEpisodeMapper;
|
||||
import com.fruitshorts.media.service.MediaTranscodeOutputService;
|
||||
import com.fruitshorts.media.vo.MediaThumbnailRespVO;
|
||||
import com.fruitshorts.media.vo.TranscodeTaskRespVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/** 聚合剧集与媒资转码产物,供后台编辑页一次读取。 */
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EpisodeTranscodeAdminService {
|
||||
|
||||
private static final String STATUS_EPISODE_NOT_FOUND = "EPISODE_NOT_FOUND";
|
||||
private static final String STATUS_NO_VIDEO = "NO_VIDEO";
|
||||
private static final String STATUS_NO_MEDIA_ASSET = "NO_MEDIA_ASSET";
|
||||
private static final String STATUS_NO_TASK = "NO_TASK";
|
||||
private static final String REASON_EPISODE_NOT_FOUND = "分集不存在或已删除";
|
||||
private static final String REASON_NO_VIDEO = "分集未配置视频";
|
||||
private static final String REASON_NO_MEDIA_ASSET = "未找到分集视频对应的媒资";
|
||||
private static final int THUMBNAIL_PAGE_INDEX = 1;
|
||||
private static final int THUMBNAIL_PAGE_SIZE = 100;
|
||||
|
||||
private final DramaEpisodeMapper episodeMapper;
|
||||
private final MediaTranscodeOutputService outputService;
|
||||
|
||||
public EpisodeTranscodeRespVO detail(Long episodeId) {
|
||||
DramaEpisode episode = episodeId == null ? null : episodeMapper.selectById(episodeId);
|
||||
if (episode == null) {
|
||||
return empty(episodeId, STATUS_EPISODE_NOT_FOUND, REASON_EPISODE_NOT_FOUND);
|
||||
}
|
||||
boolean hasVideoAsset = episode.getVideoAssetId() != null
|
||||
&& episode.getVideoAssetId() > 0;
|
||||
if (!StringUtils.hasText(episode.getVideoUrl()) && !hasVideoAsset) {
|
||||
return empty(episodeId, STATUS_NO_VIDEO, REASON_NO_VIDEO);
|
||||
}
|
||||
Long mediaAssetId = outputService.resolveMediaAssetId(episode.getVideoUrl());
|
||||
if ((mediaAssetId == null || mediaAssetId <= 0) && hasVideoAsset
|
||||
&& outputService.mediaAssetExists(episode.getVideoAssetId())) {
|
||||
mediaAssetId = episode.getVideoAssetId();
|
||||
}
|
||||
if (mediaAssetId == null || mediaAssetId <= 0) {
|
||||
return empty(episodeId, STATUS_NO_MEDIA_ASSET, REASON_NO_MEDIA_ASSET);
|
||||
}
|
||||
|
||||
EpisodeTranscodeRespVO result = new EpisodeTranscodeRespVO();
|
||||
result.setEpisodeId(idString(episodeId));
|
||||
result.setMediaAssetId(idString(mediaAssetId));
|
||||
result.setRenditions(outputService.renditionsForMediaAssetId(mediaAssetId));
|
||||
result.setThumbnails(outputService.thumbnailForEpisode(
|
||||
episodeId, mediaAssetId, THUMBNAIL_PAGE_INDEX, THUMBNAIL_PAGE_SIZE));
|
||||
|
||||
TranscodeTaskRespVO task = outputService.latestTask(mediaAssetId);
|
||||
if (task == null) {
|
||||
result.setStatus(taskStatusOf(episode));
|
||||
result.setProgress(0);
|
||||
result.setRetryCount(0);
|
||||
result.setErrorMsg("");
|
||||
result.setUpdatedAt(episode.getUpdatedAt());
|
||||
return result;
|
||||
}
|
||||
result.setTaskId(idString(task.getId()));
|
||||
result.setStatus(task.getStatus());
|
||||
result.setProgress(task.getProgress());
|
||||
result.setRetryCount(task.getRetryCount());
|
||||
result.setErrorMsg(task.getErrorMsg());
|
||||
result.setUpdatedAt(task.getUpdatedAt());
|
||||
return result;
|
||||
}
|
||||
|
||||
private EpisodeTranscodeRespVO empty(Long episodeId, String status, String reason) {
|
||||
EpisodeTranscodeRespVO result = new EpisodeTranscodeRespVO();
|
||||
result.setEpisodeId(idString(episodeId));
|
||||
result.setStatus(status);
|
||||
result.setProgress(0);
|
||||
result.setRetryCount(0);
|
||||
result.setErrorMsg(reason);
|
||||
result.setRenditions(List.of());
|
||||
result.setThumbnails(MediaThumbnailRespVO.empty(
|
||||
null, episodeId, MediaThumbnailRespVO.STATUS_EMPTY,
|
||||
THUMBNAIL_PAGE_INDEX, THUMBNAIL_PAGE_SIZE));
|
||||
return result;
|
||||
}
|
||||
|
||||
private String idString(Long id) {
|
||||
return id == null ? null : String.valueOf(id);
|
||||
}
|
||||
|
||||
private String taskStatusOf(DramaEpisode episode) {
|
||||
return StringUtils.hasText(episode.getTranscodeStatus())
|
||||
? episode.getTranscodeStatus().toUpperCase(Locale.ROOT)
|
||||
: STATUS_NO_TASK;
|
||||
}
|
||||
}
|
||||
+283
@@ -0,0 +1,283 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fruitshorts.admin.vo.AdminReportRespVO;
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.content.dal.entity.Drama;
|
||||
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
||||
import com.fruitshorts.content.dal.mapper.DramaEpisodeMapper;
|
||||
import com.fruitshorts.content.dal.mapper.DramaMapper;
|
||||
import com.fruitshorts.interaction.dal.entity.ContentComment;
|
||||
import com.fruitshorts.interaction.dal.entity.ContentReport;
|
||||
import com.fruitshorts.interaction.dal.mapper.ContentCommentMapper;
|
||||
import com.fruitshorts.interaction.dal.mapper.ContentReportMapper;
|
||||
import com.fruitshorts.interaction.service.CommentService;
|
||||
import com.fruitshorts.interaction.service.ReportService;
|
||||
import com.fruitshorts.interaction.vo.ReportQueryReqVO;
|
||||
import com.fruitshorts.user.dal.entity.AppUser;
|
||||
import com.fruitshorts.user.dal.mapper.AppUserMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 后台举报工单分页与目标展示信息装配。
|
||||
*
|
||||
* <p>举报只保存目标类型和 id;该服务在当前页一次性加载评论、剧、集和用户,
|
||||
* 避免列表逐行查询,同时保持原举报处理流程不变。
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ReportAdminService {
|
||||
|
||||
private static final int DEFAULT_PAGE_INDEX = 1;
|
||||
private static final int DEFAULT_PAGE_SIZE = 10;
|
||||
private static final int DELETED_FLAG = 1;
|
||||
|
||||
private final ContentReportMapper reportMapper;
|
||||
private final ContentCommentMapper commentMapper;
|
||||
private final DramaMapper dramaMapper;
|
||||
private final DramaEpisodeMapper episodeMapper;
|
||||
private final AppUserMapper appUserMapper;
|
||||
|
||||
/** 按举报工单筛选条件分页查询,并补齐展示字段。 */
|
||||
public PageResult<AdminReportRespVO> page(ReportQueryReqVO req) {
|
||||
Page<ContentReport> page = new Page<>(
|
||||
req.getPageIndex() == null || req.getPageIndex() < 1
|
||||
? DEFAULT_PAGE_INDEX : req.getPageIndex(),
|
||||
req.getPageSize() == null || req.getPageSize() < 1
|
||||
? DEFAULT_PAGE_SIZE : req.getPageSize());
|
||||
IPage<ContentReport> result = reportMapper.selectPage(page,
|
||||
Wrappers.<ContentReport>lambdaQuery()
|
||||
.eq(StringUtils.hasText(req.getStatus()),
|
||||
ContentReport::getStatus, req.getStatus())
|
||||
.eq(StringUtils.hasText(req.getTargetType()),
|
||||
ContentReport::getTargetType, req.getTargetType())
|
||||
.eq(StringUtils.hasText(req.getReasonCode()),
|
||||
ContentReport::getReasonCode, req.getReasonCode())
|
||||
.eq(req.getReporterId() != null,
|
||||
ContentReport::getReporterId, req.getReporterId())
|
||||
.orderByDesc(ContentReport::getId));
|
||||
return new PageResult<>(result.getTotal(), toVoList(result.getRecords()));
|
||||
}
|
||||
|
||||
private List<AdminReportRespVO> toVoList(List<ContentReport> rows) {
|
||||
if (rows.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
Map<Long, ContentComment> comments = loadComments(rows);
|
||||
Map<Long, Drama> dramas = loadDramas(rows, comments);
|
||||
Map<Long, DramaEpisode> episodes = loadEpisodes(comments);
|
||||
Map<Long, AppUser> users = loadUsers(rows);
|
||||
List<AdminReportRespVO> list = new ArrayList<>(rows.size());
|
||||
for (ContentReport row : rows) {
|
||||
list.add(toVo(row, comments, dramas, episodes, users));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private Map<Long, ContentComment> loadComments(List<ContentReport> rows) {
|
||||
List<Long> ids = rows.stream()
|
||||
.filter(row -> ReportService.TYPE_COMMENT.equals(row.getTargetType()))
|
||||
.map(ContentReport::getTargetId)
|
||||
.filter(id -> id != null && id > 0L)
|
||||
.distinct()
|
||||
.toList();
|
||||
Map<Long, ContentComment> result = new HashMap<>();
|
||||
if (ids.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
for (ContentComment comment : commentMapper.selectByIdsIncludingDeleted(ids)) {
|
||||
result.put(comment.getId(), comment);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Map<Long, Drama> loadDramas(List<ContentReport> rows,
|
||||
Map<Long, ContentComment> comments) {
|
||||
Set<Long> ids = new LinkedHashSet<>();
|
||||
for (ContentReport row : rows) {
|
||||
if (ReportService.TYPE_DRAMA.equals(row.getTargetType())) {
|
||||
addPositive(ids, row.getTargetId());
|
||||
continue;
|
||||
}
|
||||
if (ReportService.TYPE_COMMENT.equals(row.getTargetType())) {
|
||||
ContentComment comment = comments.get(row.getTargetId());
|
||||
if (!isDeleted(comment)) {
|
||||
addPositive(ids, comment.getDramaId());
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<Long, Drama> result = new HashMap<>();
|
||||
if (ids.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
for (Drama drama : dramaMapper.selectBatchIds(ids)) {
|
||||
result.put(drama.getId(), drama);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Map<Long, DramaEpisode> loadEpisodes(Map<Long, ContentComment> comments) {
|
||||
Set<Long> ids = new LinkedHashSet<>();
|
||||
for (ContentComment comment : comments.values()) {
|
||||
if (!isDeleted(comment)) {
|
||||
addPositive(ids, comment.getEpisodeId());
|
||||
}
|
||||
}
|
||||
Map<Long, DramaEpisode> result = new HashMap<>();
|
||||
if (ids.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
for (DramaEpisode episode : episodeMapper.selectBatchIds(ids)) {
|
||||
result.put(episode.getId(), episode);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Map<Long, AppUser> loadUsers(List<ContentReport> rows) {
|
||||
Set<Long> ids = new LinkedHashSet<>();
|
||||
for (ContentReport row : rows) {
|
||||
addPositive(ids, row.getReporterId());
|
||||
if (ReportService.TYPE_USER.equals(row.getTargetType())) {
|
||||
addPositive(ids, row.getTargetId());
|
||||
}
|
||||
}
|
||||
Map<Long, AppUser> result = new HashMap<>();
|
||||
if (ids.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
for (AppUser user : appUserMapper.selectBatchIds(ids)) {
|
||||
result.put(user.getId(), user);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private AdminReportRespVO toVo(ContentReport report,
|
||||
Map<Long, ContentComment> comments,
|
||||
Map<Long, Drama> dramas,
|
||||
Map<Long, DramaEpisode> episodes,
|
||||
Map<Long, AppUser> users) {
|
||||
AdminReportRespVO vo = new AdminReportRespVO();
|
||||
copyReport(report, vo);
|
||||
fillReporter(report, users.get(report.getReporterId()), vo);
|
||||
if (ReportService.TYPE_COMMENT.equals(report.getTargetType())) {
|
||||
fillCommentTarget(report, comments.get(report.getTargetId()), dramas, episodes, vo);
|
||||
} else if (ReportService.TYPE_DRAMA.equals(report.getTargetType())) {
|
||||
fillDramaTarget(report, dramas.get(report.getTargetId()), vo);
|
||||
} else if (ReportService.TYPE_USER.equals(report.getTargetType())) {
|
||||
fillUserTarget(report, users.get(report.getTargetId()), vo);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
private void copyReport(ContentReport report, AdminReportRespVO vo) {
|
||||
vo.setId(report.getId());
|
||||
vo.setReporterId(report.getReporterId());
|
||||
vo.setTargetType(report.getTargetType());
|
||||
vo.setTargetId(report.getTargetId());
|
||||
vo.setReasonCode(report.getReasonCode());
|
||||
vo.setDescription(report.getDescription());
|
||||
vo.setStatus(report.getStatus());
|
||||
vo.setHandleBy(report.getHandleBy());
|
||||
vo.setHandleAt(report.getHandleAt());
|
||||
vo.setHandleNote(report.getHandleNote());
|
||||
vo.setCreatedAt(report.getCreatedAt());
|
||||
}
|
||||
|
||||
private void fillReporter(ContentReport report, AppUser reporter, AdminReportRespVO vo) {
|
||||
if (reporter != null) {
|
||||
vo.setReporterNickname(reporter.getNickname());
|
||||
vo.setReporterUid(reporter.getUid());
|
||||
}
|
||||
}
|
||||
|
||||
private void fillCommentTarget(ContentReport report, ContentComment comment,
|
||||
Map<Long, Drama> dramas,
|
||||
Map<Long, DramaEpisode> episodes,
|
||||
AdminReportRespVO vo) {
|
||||
if (isDeleted(comment)) {
|
||||
vo.setTargetSummary("评论 #" + report.getTargetId());
|
||||
return;
|
||||
}
|
||||
Drama drama = dramas.get(comment.getDramaId());
|
||||
if (drama == null) {
|
||||
vo.setTargetSummary("评论 #" + report.getTargetId());
|
||||
return;
|
||||
}
|
||||
DramaEpisode episode = episodes.get(comment.getEpisodeId());
|
||||
vo.setDramaId(comment.getDramaId());
|
||||
vo.setDramaTitle(drama.getTitle());
|
||||
vo.setEpisodeId(comment.getEpisodeId());
|
||||
vo.setCommentContent(comment.getContent());
|
||||
if (episode == null) {
|
||||
vo.setTargetSummary(drama.getTitle());
|
||||
return;
|
||||
}
|
||||
vo.setEpisodeNo(episode.getEpNo());
|
||||
vo.setEpisodeTitle(episode.getTitle());
|
||||
String summary = drama.getTitle() + " · 第 " + episode.getEpNo() + " 集";
|
||||
if (StringUtils.hasText(episode.getTitle())) {
|
||||
summary += " · " + episode.getTitle();
|
||||
}
|
||||
vo.setTargetSummary(summary);
|
||||
}
|
||||
|
||||
private void fillDramaTarget(ContentReport report, Drama drama, AdminReportRespVO vo) {
|
||||
vo.setDramaId(report.getTargetId());
|
||||
if (drama == null) {
|
||||
vo.setTargetSummary("短剧 #" + report.getTargetId());
|
||||
return;
|
||||
}
|
||||
vo.setDramaTitle(drama.getTitle());
|
||||
vo.setTargetSummary(drama.getTitle());
|
||||
}
|
||||
|
||||
private void fillUserTarget(ContentReport report, AppUser user, AdminReportRespVO vo) {
|
||||
if (user == null) {
|
||||
vo.setTargetSummary("用户 #" + report.getTargetId());
|
||||
return;
|
||||
}
|
||||
vo.setTargetNickname(user.getNickname());
|
||||
vo.setTargetUid(user.getUid());
|
||||
vo.setTargetSummary(formatUser(user, report.getTargetId()));
|
||||
}
|
||||
|
||||
private String formatUser(AppUser user, Long fallbackId) {
|
||||
boolean hasNickname = StringUtils.hasText(user.getNickname());
|
||||
boolean hasUid = StringUtils.hasText(user.getUid());
|
||||
if (hasNickname && hasUid) {
|
||||
return user.getNickname() + "(" + user.getUid() + ")";
|
||||
}
|
||||
if (hasNickname) {
|
||||
return user.getNickname();
|
||||
}
|
||||
if (hasUid) {
|
||||
return user.getUid();
|
||||
}
|
||||
return "用户 #" + fallbackId;
|
||||
}
|
||||
|
||||
private boolean isDeleted(ContentComment comment) {
|
||||
return comment == null
|
||||
|| CommentService.STATUS_DELETED.equals(comment.getStatus())
|
||||
|| Integer.valueOf(DELETED_FLAG).equals(comment.getDeleted());
|
||||
}
|
||||
|
||||
private void addPositive(Set<Long> ids, Long id) {
|
||||
if (id != null && id > 0L) {
|
||||
ids.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fruitshorts.admin.vo.AdminWatchHistoryVO;
|
||||
import com.fruitshorts.admin.vo.WatchHistoryQueryReqVO;
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.content.dal.entity.Drama;
|
||||
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
||||
import com.fruitshorts.content.dal.mapper.DramaEpisodeMapper;
|
||||
import com.fruitshorts.content.dal.mapper.DramaMapper;
|
||||
import com.fruitshorts.content.enums.ContentStatus;
|
||||
import com.fruitshorts.playback.dal.entity.WatchHistory;
|
||||
import com.fruitshorts.playback.dal.mapper.WatchHistoryMapper;
|
||||
import com.fruitshorts.user.dal.entity.AppUser;
|
||||
import com.fruitshorts.user.dal.entity.AppUserSession;
|
||||
import com.fruitshorts.user.dal.mapper.AppUserMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 后台观看记录分页与跨域装配。
|
||||
*
|
||||
* <p>观看流水是播放域的原始事件,用户、短剧与分集资料分别位于用户和内容域。
|
||||
* 该服务位于 admin-api 聚合层,直接注入只读 Mapper,避免反向扩展业务模块依赖。
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class WatchHistoryAdminService {
|
||||
|
||||
private static final int DEFAULT_PAGE_INDEX = 1;
|
||||
private static final int DEFAULT_PAGE_SIZE = 10;
|
||||
private static final int MAX_PAGE_SIZE = 100;
|
||||
private static final long FINISHED_TOLERANCE_MS = 1000L;
|
||||
|
||||
private final WatchHistoryMapper watchHistoryMapper;
|
||||
private final AppUserMapper appUserMapper;
|
||||
private final DramaMapper dramaMapper;
|
||||
private final DramaEpisodeMapper dramaEpisodeMapper;
|
||||
private final AppSessionSystemService sessionSystem;
|
||||
|
||||
/** 按后台筛选条件分页查询观看记录。 */
|
||||
public PageResult<AdminWatchHistoryVO> page(WatchHistoryQueryReqVO req) {
|
||||
int pageIndex = req.getPageIndex() == null || req.getPageIndex() < 1
|
||||
? DEFAULT_PAGE_INDEX : req.getPageIndex();
|
||||
int pageSize = req.getPageSize() == null || req.getPageSize() < 1
|
||||
? DEFAULT_PAGE_SIZE : Math.min(req.getPageSize(), MAX_PAGE_SIZE);
|
||||
List<Long> matchedUserIds = StringUtils.hasText(req.getKeyword())
|
||||
? searchUserIds(req.getKeyword()) : null;
|
||||
if (matchedUserIds != null && matchedUserIds.isEmpty()) {
|
||||
return emptyPage();
|
||||
}
|
||||
List<Long> matchedDramaIds = StringUtils.hasText(req.getDramaTitle())
|
||||
? searchDramaIds(req.getDramaTitle()) : null;
|
||||
if (matchedDramaIds != null && matchedDramaIds.isEmpty()) {
|
||||
return emptyPage();
|
||||
}
|
||||
IPage<WatchHistory> result = watchHistoryMapper.selectPage(new Page<>(pageIndex, pageSize),
|
||||
buildQuery(req, matchedUserIds, matchedDramaIds));
|
||||
return new PageResult<>(result.getTotal(), toVoList(result.getRecords()));
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<WatchHistory> buildQuery(WatchHistoryQueryReqVO req,
|
||||
List<Long> matchedUserIds,
|
||||
List<Long> matchedDramaIds) {
|
||||
LambdaQueryWrapper<WatchHistory> wrapper = Wrappers.<WatchHistory>lambdaQuery()
|
||||
.eq(req.getUserId() != null, WatchHistory::getUserId, req.getUserId())
|
||||
.in(matchedUserIds != null, WatchHistory::getUserId, matchedUserIds)
|
||||
.eq(req.getDramaId() != null, WatchHistory::getDramaId, req.getDramaId())
|
||||
.in(matchedDramaIds != null, WatchHistory::getDramaId, matchedDramaIds)
|
||||
.eq(req.getEpisodeId() != null, WatchHistory::getEpisodeId, req.getEpisodeId())
|
||||
.eq(StringUtils.hasText(req.getSource()), WatchHistory::getSource, req.getSource())
|
||||
.ge(req.getStartTime() != null, WatchHistory::getWatchedAt, req.getStartTime())
|
||||
.le(req.getEndTime() != null, WatchHistory::getWatchedAt, req.getEndTime());
|
||||
applyFinished(wrapper, req.getFinished());
|
||||
return wrapper.orderByDesc(WatchHistory::getWatchedAt)
|
||||
.orderByDesc(WatchHistory::getId);
|
||||
}
|
||||
|
||||
private void applyFinished(LambdaQueryWrapper<WatchHistory> wrapper, Boolean finished) {
|
||||
if (Boolean.TRUE.equals(finished)) {
|
||||
wrapper.gt(WatchHistory::getDurationMs, 0L)
|
||||
.apply("position_ms + {0} >= duration_ms", FINISHED_TOLERANCE_MS);
|
||||
} else if (Boolean.FALSE.equals(finished)) {
|
||||
wrapper.and(query -> query.eq(WatchHistory::getDurationMs, 0L)
|
||||
.or()
|
||||
.apply("position_ms + {0} < duration_ms", FINISHED_TOLERANCE_MS));
|
||||
}
|
||||
}
|
||||
|
||||
private List<Long> searchUserIds(String keyword) {
|
||||
String value = keyword.trim();
|
||||
return appUserMapper.selectList(Wrappers.<AppUser>lambdaQuery()
|
||||
.select(AppUser::getId)
|
||||
.and(query -> query.like(AppUser::getUid, value)
|
||||
.or()
|
||||
.like(AppUser::getNickname, value)))
|
||||
.stream()
|
||||
.map(AppUser::getId)
|
||||
.toList();
|
||||
}
|
||||
|
||||
private List<Long> searchDramaIds(String dramaTitle) {
|
||||
String value = dramaTitle.trim();
|
||||
return dramaMapper.selectList(Wrappers.<Drama>lambdaQuery()
|
||||
.select(Drama::getId)
|
||||
.like(Drama::getTitle, value))
|
||||
.stream()
|
||||
.map(Drama::getId)
|
||||
.toList();
|
||||
}
|
||||
|
||||
private List<AdminWatchHistoryVO> toVoList(List<WatchHistory> rows) {
|
||||
if (rows.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
Map<Long, AppUser> users = loadUsers(rows);
|
||||
Map<Long, Drama> dramas = loadDramas(rows);
|
||||
Map<Long, DramaEpisode> episodes = loadEpisodes(rows);
|
||||
Map<Long, List<AppUserSession>> sessions = sessionSystem.groupByUser(
|
||||
rows.stream().map(WatchHistory::getUserId).distinct().toList());
|
||||
List<AdminWatchHistoryVO> list = new ArrayList<>(rows.size());
|
||||
for (WatchHistory row : rows) {
|
||||
list.add(toVo(row, users.get(row.getUserId()), dramas.get(row.getDramaId()),
|
||||
episodes.get(row.getEpisodeId()),
|
||||
sessionSystem.match(sessions.get(row.getUserId()), row.getDeviceId())));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private Map<Long, AppUser> loadUsers(List<WatchHistory> rows) {
|
||||
Map<Long, AppUser> result = new HashMap<>();
|
||||
List<Long> ids = rows.stream().map(WatchHistory::getUserId).distinct().toList();
|
||||
for (AppUser user : appUserMapper.selectBatchIds(ids)) {
|
||||
result.put(user.getId(), user);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Map<Long, Drama> loadDramas(List<WatchHistory> rows) {
|
||||
Map<Long, Drama> result = new HashMap<>();
|
||||
List<Long> ids = rows.stream().map(WatchHistory::getDramaId).distinct().toList();
|
||||
for (Drama drama : dramaMapper.selectBatchIds(ids)) {
|
||||
result.put(drama.getId(), drama);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Map<Long, DramaEpisode> loadEpisodes(List<WatchHistory> rows) {
|
||||
Map<Long, DramaEpisode> result = new HashMap<>();
|
||||
List<Long> ids = rows.stream().map(WatchHistory::getEpisodeId).distinct().toList();
|
||||
for (DramaEpisode episode : dramaEpisodeMapper.selectBatchIds(ids)) {
|
||||
result.put(episode.getId(), episode);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private AdminWatchHistoryVO toVo(WatchHistory row, AppUser user, Drama drama,
|
||||
DramaEpisode episode, AppUserSession session) {
|
||||
AdminWatchHistoryVO vo = new AdminWatchHistoryVO();
|
||||
vo.setId(row.getId());
|
||||
vo.setUserId(row.getUserId());
|
||||
vo.setDramaId(row.getDramaId());
|
||||
vo.setEpisodeId(row.getEpisodeId());
|
||||
vo.setPositionMs(row.getPositionMs());
|
||||
vo.setDurationMs(row.getDurationMs());
|
||||
vo.setSource(row.getSource());
|
||||
vo.setDeviceId(row.getDeviceId());
|
||||
vo.setWatchedAt(row.getWatchedAt());
|
||||
if (session != null) {
|
||||
vo.setPlatform(session.getPlatform());
|
||||
vo.setOsVersion(session.getOsVersion());
|
||||
}
|
||||
long position = row.getPositionMs() == null ? 0L : row.getPositionMs();
|
||||
long duration = row.getDurationMs() == null ? 0L : row.getDurationMs();
|
||||
vo.setFinished(duration > 0L && position + FINISHED_TOLERANCE_MS >= duration);
|
||||
if (user != null) {
|
||||
vo.setUid(user.getUid());
|
||||
vo.setNickname(user.getNickname());
|
||||
}
|
||||
if (drama != null) {
|
||||
vo.setDramaTitle(drama.getTitle());
|
||||
vo.setDramaPublished(ContentStatus.PUBLISHED.getCode().equals(drama.getStatus()));
|
||||
} else {
|
||||
vo.setDramaPublished(false);
|
||||
}
|
||||
if (episode != null) {
|
||||
vo.setEpisodeNo(episode.getEpNo());
|
||||
vo.setEpisodeTitle(episode.getTitle());
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
private PageResult<AdminWatchHistoryVO> emptyPage() {
|
||||
return new PageResult<>(0L, List.of());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/** 后台举报工单视图,附带举报人与被举报目标的展示信息。 */
|
||||
@Data
|
||||
public class AdminReportRespVO {
|
||||
|
||||
private Long id;
|
||||
private Long reporterId;
|
||||
private String reporterNickname;
|
||||
private String reporterUid;
|
||||
private String targetType;
|
||||
private Long targetId;
|
||||
private String targetSummary;
|
||||
private Long dramaId;
|
||||
private String dramaTitle;
|
||||
private Long episodeId;
|
||||
private Integer episodeNo;
|
||||
private String episodeTitle;
|
||||
private String commentContent;
|
||||
private String targetNickname;
|
||||
private String targetUid;
|
||||
private String reasonCode;
|
||||
private String description;
|
||||
private String status;
|
||||
private Long handleBy;
|
||||
private LocalDateTime handleAt;
|
||||
private String handleNote;
|
||||
private LocalDateTime createdAt;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 后台观看记录行。
|
||||
*
|
||||
* <p>页面需要识别用户、短剧、分集与完播状态,因此由 admin-api 聚合流水与基础资料。
|
||||
*/
|
||||
@Data
|
||||
public class AdminWatchHistoryVO {
|
||||
|
||||
private Long id;
|
||||
private Long userId;
|
||||
private String uid;
|
||||
private String nickname;
|
||||
private Long dramaId;
|
||||
private String dramaTitle;
|
||||
private Boolean dramaPublished;
|
||||
private Long episodeId;
|
||||
private Integer episodeNo;
|
||||
private String episodeTitle;
|
||||
private Long positionMs;
|
||||
private Long durationMs;
|
||||
private Boolean finished;
|
||||
private String source;
|
||||
private String deviceId;
|
||||
/** ANDROID / IOS / WEB,来自该次设备的登录会话。 */
|
||||
private String platform;
|
||||
/** 系统版本,例如 Android 16。 */
|
||||
private String osVersion;
|
||||
private LocalDateTime watchedAt;
|
||||
}
|
||||
+4
@@ -28,5 +28,9 @@ public class AppUserWatchHistoryVO {
|
||||
private Boolean finished;
|
||||
private String source;
|
||||
private String deviceId;
|
||||
/** ANDROID / IOS / WEB,来自该次设备的登录会话。 */
|
||||
private String platform;
|
||||
/** 系统版本。 */
|
||||
private String osVersion;
|
||||
private LocalDateTime watchedAt;
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.vo;
|
||||
|
||||
import com.fruitshorts.media.vo.MediaRenditionRespVO;
|
||||
import com.fruitshorts.media.vo.MediaThumbnailRespVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/** 后台剧集编辑页一次性获取的转码状态。 */
|
||||
@Data
|
||||
@Schema(description = "分集转码聚合信息")
|
||||
public class EpisodeTranscodeRespVO {
|
||||
|
||||
private String episodeId;
|
||||
private String mediaAssetId;
|
||||
private String taskId;
|
||||
private String status;
|
||||
private Integer progress;
|
||||
private Integer retryCount;
|
||||
private String errorMsg;
|
||||
private LocalDateTime updatedAt;
|
||||
private List<MediaRenditionRespVO> renditions = List.of();
|
||||
private MediaThumbnailRespVO thumbnails;
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.vo;
|
||||
|
||||
import com.fruitshorts.media.vo.TranscodeQueueStatsVO;
|
||||
import com.fruitshorts.media.vo.TranscodeTaskRespVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/** 后台转码看板强类型响应。 */
|
||||
@Data
|
||||
@Schema(description = "转码看板")
|
||||
public class TranscodeDashboardRespVO {
|
||||
|
||||
private LocalDateTime generatedAt;
|
||||
private TranscodeQueueStatsVO queue;
|
||||
private List<TranscodeTaskRespVO> failedTasks = List.of();
|
||||
private List<String> notes = List.of();
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/** 后台观看记录分页检索条件。 */
|
||||
@Data
|
||||
public class WatchHistoryQueryReqVO {
|
||||
|
||||
private Integer pageIndex = 1;
|
||||
private Integer pageSize = 10;
|
||||
/** uid / 昵称模糊检索 */
|
||||
private String keyword;
|
||||
private Long userId;
|
||||
/** 短剧名称模糊检索 */
|
||||
private String dramaTitle;
|
||||
private Long dramaId;
|
||||
private Long episodeId;
|
||||
private String source;
|
||||
private Boolean finished;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime endTime;
|
||||
}
|
||||
@@ -66,3 +66,15 @@ springdoc:
|
||||
logging:
|
||||
level:
|
||||
com.fruitshorts: debug
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: prometheus,health
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
metrics:
|
||||
tags:
|
||||
application: ${spring.application.name}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.admin.service.DashboardService;
|
||||
import com.fruitshorts.admin.support.ControllerContractSupport;
|
||||
import com.fruitshorts.admin.vo.TranscodeDashboardRespVO;
|
||||
import com.fruitshorts.media.vo.TranscodeQueueStatsVO;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
class DashboardTranscodeContractTest {
|
||||
|
||||
private DashboardService dashboardService;
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
dashboardService = mock(DashboardService.class);
|
||||
mockMvc = ControllerContractSupport.mockMvcOf(
|
||||
new DashboardAdminController(dashboardService));
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_typed_queue_and_failed_tasks() throws Exception {
|
||||
TranscodeQueueStatsVO queue = new TranscodeQueueStatsVO(
|
||||
10L, 2L, 1L, 5L, 1L, 1L, 20L);
|
||||
TranscodeDashboardRespVO vo = new TranscodeDashboardRespVO();
|
||||
vo.setQueue(queue);
|
||||
vo.setFailedTasks(List.of());
|
||||
vo.setNotes(List.of("queue total"));
|
||||
given(dashboardService.transcode()).willReturn(vo);
|
||||
|
||||
mockMvc.perform(get("/admin/dashboard/transcode"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.data.queue.total").value(10))
|
||||
.andExpect(jsonPath("$.data.queue.queued").value(2))
|
||||
.andExpect(jsonPath("$.data.queue.running").value(1))
|
||||
.andExpect(jsonPath("$.data.queue.success").value(5))
|
||||
.andExpect(jsonPath("$.data.queue.failed").value(1))
|
||||
.andExpect(jsonPath("$.data.failedTasks").isArray());
|
||||
}
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.admin.support.ControllerContractSupport;
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.content.service.DramaService;
|
||||
import com.fruitshorts.content.service.EpisodeService;
|
||||
import com.fruitshorts.content.vo.DramaPageReqVO;
|
||||
import com.fruitshorts.content.vo.DramaRespVO;
|
||||
import com.fruitshorts.interaction.service.CommentService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/** 后台短剧列表与详情的互动数量回填契约。 */
|
||||
class DramaControllerContractTest {
|
||||
|
||||
private DramaService dramaService;
|
||||
private CommentService commentService;
|
||||
private EpisodeService episodeService;
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
dramaService = mock(DramaService.class);
|
||||
commentService = mock(CommentService.class);
|
||||
episodeService = mock(EpisodeService.class);
|
||||
mockMvc = ControllerContractSupport.mockMvcOf(
|
||||
new DramaController(dramaService, commentService, episodeService));
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_fill_comment_counts_in_batch_when_page_is_requested() throws Exception {
|
||||
DramaRespVO first = drama(7L, 3200L, 1800L);
|
||||
DramaRespVO second = drama(8L, 120L, 80L);
|
||||
given(dramaService.page(any(DramaPageReqVO.class)))
|
||||
.willReturn(new PageResult<>(2L, List.of(first, second)));
|
||||
given(commentService.countByDramas(List.of(7L, 8L)))
|
||||
.willReturn(Map.of(7L, 11L));
|
||||
given(episodeService.sumLikeCountsByDramas(List.of(7L, 8L)))
|
||||
.willReturn(Map.of(7L, 3200L, 8L, 120L));
|
||||
|
||||
mockMvc.perform(get("/admin/dramas/page"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(0))
|
||||
.andExpect(jsonPath("$.data.list[0].likeCount").value("3200"))
|
||||
.andExpect(jsonPath("$.data.list[0].favoriteCount").value("1800"))
|
||||
.andExpect(jsonPath("$.data.list[0].dramaType").value("ANIME"))
|
||||
.andExpect(jsonPath("$.data.list[0].commentCount").value("11"))
|
||||
.andExpect(jsonPath("$.data.list[1].likeCount").value("120"))
|
||||
.andExpect(jsonPath("$.data.list[1].favoriteCount").value("80"))
|
||||
.andExpect(jsonPath("$.data.list[1].commentCount").value("0"));
|
||||
|
||||
verify(commentService).countByDramas(List.of(7L, 8L));
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_fill_comment_count_when_detail_is_requested() throws Exception {
|
||||
given(dramaService.get(7L)).willReturn(drama(7L, 3200L, 1800L));
|
||||
given(commentService.countByDramas(List.of(7L))).willReturn(Map.of(7L, 11L));
|
||||
given(episodeService.sumLikeCountsByDramas(List.of(7L))).willReturn(Map.of(7L, 3200L));
|
||||
|
||||
mockMvc.perform(get("/admin/dramas/7"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.data.likeCount").value("3200"))
|
||||
.andExpect(jsonPath("$.data.favoriteCount").value("1800"))
|
||||
.andExpect(jsonPath("$.data.dramaType").value("ANIME"))
|
||||
.andExpect(jsonPath("$.data.commentCount").value("11"));
|
||||
}
|
||||
|
||||
private DramaRespVO drama(Long id, Long likeCount, Long favoriteCount) {
|
||||
DramaRespVO drama = new DramaRespVO();
|
||||
drama.setId(id);
|
||||
drama.setTitle("短剧" + id);
|
||||
drama.setLikeCount(likeCount);
|
||||
drama.setFavoriteCount(favoriteCount);
|
||||
drama.setDramaType("ANIME");
|
||||
return drama;
|
||||
}
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.admin.support.ControllerContractSupport;
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.content.dal.entity.Drama;
|
||||
import com.fruitshorts.content.service.DramaService;
|
||||
import com.fruitshorts.content.service.EpisodeService;
|
||||
import com.fruitshorts.content.vo.EpisodeRespVO;
|
||||
import com.fruitshorts.interaction.service.CommentService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/** 后台剧集列表:互动数量回填 + 分页契约。 */
|
||||
class EpisodeControllerContractTest {
|
||||
|
||||
private static final long DRAMA_ID = 5L;
|
||||
private static final int DEFAULT_PAGE_SIZE = 100;
|
||||
|
||||
private EpisodeService episodeService;
|
||||
private CommentService commentService;
|
||||
private DramaService dramaService;
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
episodeService = mock(EpisodeService.class);
|
||||
commentService = mock(CommentService.class);
|
||||
dramaService = mock(DramaService.class);
|
||||
mockMvc = ControllerContractSupport.mockMvcOf(
|
||||
new EpisodeController(episodeService, commentService, dramaService));
|
||||
Drama drama = new Drama();
|
||||
drama.setFavoriteCount(88L);
|
||||
drama.setViewCount(1000L);
|
||||
given(dramaService.getExisting(DRAMA_ID)).willReturn(drama);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_episode_and_drama_interaction_counts() throws Exception {
|
||||
given(episodeService.pageByDrama(eq(DRAMA_ID), isNull(), isNull(), isNull()))
|
||||
.willReturn(new PageResult<>(2L, List.of(episode(11L, 10L), episode(12L, 20L))));
|
||||
given(commentService.countByEpisodes(List.of(11L, 12L)))
|
||||
.willReturn(Map.of(11L, 3L));
|
||||
|
||||
mockMvc.perform(get("/admin/episodes").param("dramaId", String.valueOf(DRAMA_ID)))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.data.total").value(2))
|
||||
.andExpect(jsonPath("$.data.list[0].likeCount").value("10"))
|
||||
.andExpect(jsonPath("$.data.list[0].commentCount").value("3"))
|
||||
.andExpect(jsonPath("$.data.list[0].favoriteCount").value("88"))
|
||||
.andExpect(jsonPath("$.data.list[0].heat").value("1000"))
|
||||
.andExpect(jsonPath("$.data.list[1].likeCount").value("20"))
|
||||
.andExpect(jsonPath("$.data.list[1].commentCount").value("0"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_use_default_page_size_100_when_page_size_omitted() throws Exception {
|
||||
given(episodeService.pageByDrama(eq(DRAMA_ID), isNull(), isNull(), isNull()))
|
||||
.willReturn(PageResult.empty());
|
||||
given(commentService.countByEpisodes(List.of())).willReturn(Map.of());
|
||||
|
||||
mockMvc.perform(get("/admin/episodes").param("dramaId", String.valueOf(DRAMA_ID)))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.data.total").value(0))
|
||||
.andExpect(jsonPath("$.data.list").isArray())
|
||||
.andExpect(jsonPath("$.data.list").isEmpty());
|
||||
|
||||
ArgumentCaptor<Integer> pageIndexCaptor = ArgumentCaptor.forClass(Integer.class);
|
||||
ArgumentCaptor<Integer> pageSizeCaptor = ArgumentCaptor.forClass(Integer.class);
|
||||
verify(episodeService).pageByDrama(
|
||||
eq(DRAMA_ID), isNull(), pageIndexCaptor.capture(), pageSizeCaptor.capture());
|
||||
assertThat(pageIndexCaptor.getValue()).isNull();
|
||||
assertThat(pageSizeCaptor.getValue()).isNull();
|
||||
assertThat(DEFAULT_PAGE_SIZE).isEqualTo(100);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_non_overlapping_ids_when_second_page_requested() throws Exception {
|
||||
List<EpisodeRespVO> page1 = List.of(episode(1L, 1L), episode(2L, 2L));
|
||||
List<EpisodeRespVO> page2 = List.of(episode(3L, 3L), episode(4L, 4L));
|
||||
given(episodeService.pageByDrama(DRAMA_ID, null, 1, 2))
|
||||
.willReturn(new PageResult<>(4L, page1));
|
||||
given(episodeService.pageByDrama(DRAMA_ID, null, 2, 2))
|
||||
.willReturn(new PageResult<>(4L, page2));
|
||||
given(commentService.countByEpisodes(List.of(1L, 2L))).willReturn(Map.of());
|
||||
given(commentService.countByEpisodes(List.of(3L, 4L))).willReturn(Map.of());
|
||||
|
||||
mockMvc.perform(get("/admin/episodes")
|
||||
.param("dramaId", String.valueOf(DRAMA_ID))
|
||||
.param("pageIndex", "1")
|
||||
.param("pageSize", "2"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.data.total").value(4))
|
||||
.andExpect(jsonPath("$.data.list.length()").value(2));
|
||||
|
||||
String page2Body = mockMvc.perform(get("/admin/episodes")
|
||||
.param("dramaId", String.valueOf(DRAMA_ID))
|
||||
.param("pageIndex", "2")
|
||||
.param("pageSize", "2"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.data.total").value(4))
|
||||
.andExpect(jsonPath("$.data.list[0].id").value("3"))
|
||||
.andExpect(jsonPath("$.data.list[1].id").value("4"))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
Set<Long> page1Ids = page1.stream().map(EpisodeRespVO::getId).collect(Collectors.toSet());
|
||||
Set<Long> page2Ids = page2.stream().map(EpisodeRespVO::getId).collect(Collectors.toSet());
|
||||
assertThat(page1Ids).doesNotContainAnyElementsOf(page2Ids);
|
||||
assertThat(page2Body).contains("\"id\":\"3\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_empty_list_with_correct_total_when_page_out_of_range() throws Exception {
|
||||
given(episodeService.pageByDrama(DRAMA_ID, null, 99, 100))
|
||||
.willReturn(new PageResult<>(5L, List.of()));
|
||||
given(commentService.countByEpisodes(List.of())).willReturn(Map.of());
|
||||
|
||||
mockMvc.perform(get("/admin/episodes")
|
||||
.param("dramaId", String.valueOf(DRAMA_ID))
|
||||
.param("pageIndex", "99")
|
||||
.param("pageSize", "100"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.data.total").value(5))
|
||||
.andExpect(jsonPath("$.data.list").isArray())
|
||||
.andExpect(jsonPath("$.data.list").isEmpty());
|
||||
}
|
||||
|
||||
private EpisodeRespVO episode(Long id, Long likeCount) {
|
||||
EpisodeRespVO episode = new EpisodeRespVO();
|
||||
episode.setId(id);
|
||||
episode.setDramaId(DRAMA_ID);
|
||||
episode.setLikeCount(likeCount);
|
||||
return episode;
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.admin.service.EpisodeTranscodeAdminService;
|
||||
import com.fruitshorts.admin.support.ControllerContractSupport;
|
||||
import com.fruitshorts.admin.vo.EpisodeTranscodeRespVO;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
class EpisodeTranscodeContractTest {
|
||||
|
||||
private EpisodeTranscodeAdminService service;
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
service = mock(EpisodeTranscodeAdminService.class);
|
||||
mockMvc = ControllerContractSupport.mockMvcOf(
|
||||
new EpisodeTranscodeController(service));
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_aggregated_episode_transcode_state() throws Exception {
|
||||
String episodeId = "2113150431755636737";
|
||||
String mediaAssetId = "2113150398670966786";
|
||||
String taskId = "2113150398935207938";
|
||||
EpisodeTranscodeRespVO vo = new EpisodeTranscodeRespVO();
|
||||
vo.setEpisodeId(episodeId);
|
||||
vo.setMediaAssetId(mediaAssetId);
|
||||
vo.setTaskId(taskId);
|
||||
vo.setStatus("SUCCESS");
|
||||
vo.setProgress(100);
|
||||
vo.setUpdatedAt(LocalDateTime.of(2026, 10, 22, 15, 10));
|
||||
given(service.detail(Long.parseLong(episodeId))).willReturn(vo);
|
||||
|
||||
mockMvc.perform(get("/admin/episodes/" + episodeId + "/transcode"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(0))
|
||||
.andExpect(jsonPath("$.data.episodeId").value(episodeId))
|
||||
.andExpect(jsonPath("$.data.mediaAssetId").value(mediaAssetId))
|
||||
.andExpect(jsonPath("$.data.taskId").value(taskId))
|
||||
.andExpect(jsonPath("$.data.status").value("SUCCESS"))
|
||||
.andExpect(jsonPath("$.data.progress").value(100))
|
||||
.andExpect(jsonPath("$.data.updatedAt").value("2026-10-22T15:10:00"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_explicit_empty_state_when_episode_has_no_video() throws Exception {
|
||||
EpisodeTranscodeRespVO vo = new EpisodeTranscodeRespVO();
|
||||
vo.setEpisodeId("31");
|
||||
vo.setStatus("NO_VIDEO");
|
||||
given(service.detail(31L)).willReturn(vo);
|
||||
|
||||
mockMvc.perform(get("/admin/episodes/31/transcode"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.data.status").value("NO_VIDEO"))
|
||||
.andExpect(jsonPath("$.data.renditions").isEmpty());
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.admin.support.ControllerContractSupport;
|
||||
import com.fruitshorts.common.exception.ErrorCode;
|
||||
import com.fruitshorts.common.exception.ServiceException;
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.media.service.MediaTranscodeOutputService;
|
||||
import com.fruitshorts.media.vo.MediaRenditionRespVO;
|
||||
import com.fruitshorts.media.vo.MediaThumbnailRespVO;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
class MediaTranscodeOutputContractTest {
|
||||
|
||||
private MediaTranscodeOutputService outputService;
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
outputService = mock(MediaTranscodeOutputService.class);
|
||||
mockMvc = ControllerContractSupport.mockMvcOf(
|
||||
new MediaTranscodeOutputController(outputService));
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_typed_rendition_list() throws Exception {
|
||||
MediaRenditionRespVO vo = new MediaRenditionRespVO();
|
||||
vo.setQuality("1080p");
|
||||
vo.setQualityName("1080P");
|
||||
vo.setResolution("1920x1080");
|
||||
vo.setVideoBitrateKbps(5000);
|
||||
vo.setVideoCodec("H.264");
|
||||
vo.setAudioCodec("AAC");
|
||||
vo.setContainer("HLS");
|
||||
vo.setHlsUrl("/files/master.m3u8");
|
||||
vo.setSizeBytes(4096L);
|
||||
vo.setStatus("ready");
|
||||
given(outputService.renditions(88L)).willReturn(List.of(vo));
|
||||
|
||||
mockMvc.perform(get("/admin/media/88/renditions"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(0))
|
||||
.andExpect(jsonPath("$.data[0].quality").value("1080p"))
|
||||
.andExpect(jsonPath("$.data[0].resolution").value("1920x1080"))
|
||||
.andExpect(jsonPath("$.data[0].videoBitrateKbps").value(5000))
|
||||
.andExpect(jsonPath("$.data[0].hlsUrl").value("/files/master.m3u8"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_not_found_for_missing_media() throws Exception {
|
||||
given(outputService.renditions(404L))
|
||||
.willThrow(new ServiceException(ErrorCode.DATA_NOT_FOUND, "媒资不存在"));
|
||||
|
||||
mockMvc.perform(get("/admin/media/404/renditions"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.DATA_NOT_FOUND.getCode()))
|
||||
.andExpect(jsonPath("$.message").value("媒资不存在"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_empty_thumbnail_status_without_error() throws Exception {
|
||||
MediaThumbnailRespVO vo = new MediaThumbnailRespVO();
|
||||
vo.setStatus("EMPTY");
|
||||
vo.setPageIndex(1);
|
||||
vo.setPageSize(100);
|
||||
vo.setFrames(PageResult.empty());
|
||||
given(outputService.thumbnails(88L, 1, 100)).willReturn(vo);
|
||||
|
||||
mockMvc.perform(get("/admin/media/88/thumbnails"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(0))
|
||||
.andExpect(jsonPath("$.data.status").value("EMPTY"))
|
||||
.andExpect(jsonPath("$.data.frames.total").value(0))
|
||||
.andExpect(jsonPath("$.data.frames.list").isEmpty());
|
||||
|
||||
verify(outputService).thumbnails(88L, 1, 100);
|
||||
}
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fruitshorts.admin.support.ControllerContractSupport;
|
||||
import com.fruitshorts.media.config.MediaTranscodeProfile;
|
||||
import com.fruitshorts.media.config.TranscodeProperties;
|
||||
import com.fruitshorts.media.service.MediaService;
|
||||
import com.fruitshorts.media.service.MediaTranscodeProfileService;
|
||||
import com.fruitshorts.system.service.ConfigService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* 后台转码配置接口:默认值、非法拒绝与成功落库。
|
||||
*/
|
||||
class MediaTranscodeProfileContractTest {
|
||||
|
||||
private ConfigService configService;
|
||||
private ObjectMapper objectMapper;
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
configService = mock(ConfigService.class);
|
||||
objectMapper = new ObjectMapper();
|
||||
MediaTranscodeProfileService profileService = new MediaTranscodeProfileService(
|
||||
configService, objectMapper, new TranscodeProperties());
|
||||
MediaController controller = new MediaController(mock(MediaService.class), profileService);
|
||||
mockMvc = ControllerContractSupport.mockMvcOf(controller);
|
||||
given(configService.get(eq(MediaTranscodeProfileService.CONFIG_KEY), anyString()))
|
||||
.willReturn("");
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_default_profile_when_config_is_missing() throws Exception {
|
||||
mockMvc.perform(get("/admin/media/transcode-profile"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(0))
|
||||
.andExpect(jsonPath("$.data.segmentSeconds").value(6))
|
||||
.andExpect(jsonPath("$.data.ladder.length()").value(4))
|
||||
.andExpect(jsonPath("$.data.ladder[0].quality").value("360p"))
|
||||
.andExpect(jsonPath("$.data.sprite.columns").value(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_reject_illegal_profile_without_writing_config() throws Exception {
|
||||
MediaTranscodeProfile profile = new MediaTranscodeProfile();
|
||||
profile.getLadder().get(0).setWidth(641);
|
||||
|
||||
mockMvc.perform(put("/admin/media/transcode-profile")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(objectMapper.writeValueAsString(profile)))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(400))
|
||||
.andExpect(jsonPath("$.message").value("宽高必须为正偶数"));
|
||||
|
||||
verify(configService, never()).update(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_persist_profile_when_request_is_valid() throws Exception {
|
||||
MediaTranscodeProfile profile = new MediaTranscodeProfile();
|
||||
profile.setSegmentSeconds(4);
|
||||
|
||||
mockMvc.perform(put("/admin/media/transcode-profile")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(objectMapper.writeValueAsString(profile)))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(0))
|
||||
.andExpect(jsonPath("$.data.segmentSeconds").value(4));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ArgumentCaptor<Map<String, String>> captor = ArgumentCaptor.forClass(Map.class);
|
||||
verify(configService).update(captor.capture());
|
||||
assertThat(captor.getValue().get(MediaTranscodeProfileService.CONFIG_KEY))
|
||||
.contains("\"segmentSeconds\":4");
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.controller;
|
||||
|
||||
import com.fruitshorts.admin.support.ControllerContractSupport;
|
||||
import com.fruitshorts.common.exception.ErrorCode;
|
||||
import com.fruitshorts.common.exception.ServiceException;
|
||||
import com.fruitshorts.media.service.MediaService;
|
||||
import com.fruitshorts.media.service.MediaTranscodeProfileService;
|
||||
import com.fruitshorts.media.service.TranscodeService;
|
||||
import com.fruitshorts.media.vo.TranscodeTriggerRespVO;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* 后台手动触发转码的最小契约。
|
||||
*/
|
||||
class MediaTranscodeTriggerContractTest {
|
||||
|
||||
private MediaService mediaService;
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
mediaService = mock(MediaService.class);
|
||||
MediaController controller = new MediaController(
|
||||
mediaService, mock(MediaTranscodeProfileService.class));
|
||||
mockMvc = ControllerContractSupport.mockMvcOf(controller);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_task_id_and_status_when_triggering_transcode() throws Exception {
|
||||
given(mediaService.triggerTranscode(88L))
|
||||
.willReturn(new TranscodeTriggerRespVO(100L, TranscodeService.STATUS_QUEUED));
|
||||
|
||||
mockMvc.perform(post("/admin/media/88/transcode"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(0))
|
||||
.andExpect(jsonPath("$.data.taskId").value("100"))
|
||||
.andExpect(jsonPath("$.data.status").value(TranscodeService.STATUS_QUEUED));
|
||||
|
||||
verify(mediaService).triggerTranscode(88L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_keep_not_found_semantics_when_media_does_not_exist() throws Exception {
|
||||
given(mediaService.triggerTranscode(404L))
|
||||
.willThrow(new ServiceException(ErrorCode.DATA_NOT_FOUND, "媒资不存在"));
|
||||
|
||||
mockMvc.perform(post("/admin/media/404/transcode"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.DATA_NOT_FOUND.getCode()))
|
||||
.andExpect(jsonPath("$.message").value("媒资不存在"));
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.service;
|
||||
|
||||
import com.fruitshorts.user.dal.entity.AppUserSession;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/** 观看记录匹配登录系统。 */
|
||||
class AppSessionSystemServiceTest {
|
||||
|
||||
private final AppSessionSystemService service = new AppSessionSystemService(null);
|
||||
|
||||
@Test
|
||||
void should_use_same_device_session_when_watch_history_has_device() {
|
||||
AppUserSession older = session("device-1", "ANDROID", "14", null);
|
||||
AppUserSession newer = session("device-2", "IOS", "18", null);
|
||||
|
||||
AppUserSession matched = service.match(List.of(newer, older), "device-1");
|
||||
|
||||
assertThat(matched.getPlatform()).isEqualTo("ANDROID");
|
||||
assertThat(matched.getOsVersion()).isEqualTo("14");
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_use_active_session_when_device_does_not_match() {
|
||||
AppUserSession revoked = session("device-9", "WEB", "1", LocalDateTime.now());
|
||||
AppUserSession active = session("device-2", "IOS", "18", null);
|
||||
|
||||
AppUserSession matched = service.match(List.of(revoked, active), "missing");
|
||||
|
||||
assertThat(matched.getPlatform()).isEqualTo("IOS");
|
||||
}
|
||||
|
||||
private AppUserSession session(String deviceId, String platform, String osVersion,
|
||||
LocalDateTime revokedAt) {
|
||||
AppUserSession session = new AppUserSession();
|
||||
session.setDeviceId(deviceId);
|
||||
session.setPlatform(platform);
|
||||
session.setOsVersion(osVersion);
|
||||
session.setRevokedAt(revokedAt);
|
||||
return session;
|
||||
}
|
||||
}
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.content.dal.entity.Drama;
|
||||
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
||||
import com.fruitshorts.content.service.DramaService;
|
||||
import com.fruitshorts.content.service.EpisodeService;
|
||||
import com.fruitshorts.interaction.config.InteractionProperties;
|
||||
import com.fruitshorts.interaction.dal.entity.ContentComment;
|
||||
import com.fruitshorts.interaction.dal.mapper.ContentAuditRecordMapper;
|
||||
import com.fruitshorts.interaction.dal.mapper.ContentCommentMapper;
|
||||
import com.fruitshorts.interaction.dal.mapper.ContentLikeMapper;
|
||||
import com.fruitshorts.interaction.service.AuditRecorder;
|
||||
import com.fruitshorts.interaction.service.CommentService;
|
||||
import com.fruitshorts.interaction.service.SensitiveWordService;
|
||||
import com.fruitshorts.interaction.vo.CommentQueryReqVO;
|
||||
import com.fruitshorts.interaction.vo.CommentRespVO;
|
||||
import com.fruitshorts.user.dal.entity.AppUser;
|
||||
import com.fruitshorts.user.dal.mapper.AppUserMapper;
|
||||
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/** 后台评论页批量补充短剧与分集展示字段。 */
|
||||
class CommentServiceTest {
|
||||
|
||||
private ContentCommentMapper commentMapper;
|
||||
private AppUserMapper appUserMapper;
|
||||
private DramaService dramaService;
|
||||
private EpisodeService episodeService;
|
||||
private CommentService commentService;
|
||||
|
||||
@BeforeAll
|
||||
static void initTableInfoCache() {
|
||||
TableInfoHelper.initTableInfo(
|
||||
new MapperBuilderAssistant(new MybatisConfiguration(), ""),
|
||||
ContentComment.class);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
commentMapper = mock(ContentCommentMapper.class);
|
||||
appUserMapper = mock(AppUserMapper.class);
|
||||
dramaService = mock(DramaService.class);
|
||||
episodeService = mock(EpisodeService.class);
|
||||
commentService = new CommentService(
|
||||
commentMapper,
|
||||
mock(ContentLikeMapper.class),
|
||||
mock(ContentAuditRecordMapper.class),
|
||||
appUserMapper,
|
||||
dramaService,
|
||||
episodeService,
|
||||
mock(SensitiveWordService.class),
|
||||
mock(AuditRecorder.class),
|
||||
mock(InteractionProperties.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_fill_drama_and_episode_metadata_when_admin_page_is_loaded() {
|
||||
ContentComment withEpisode = comment(1L, 5L, 11L);
|
||||
ContentComment legacy = comment(2L, 5L, 0L);
|
||||
Page<ContentComment> page = new Page<>(1, 10);
|
||||
page.setTotal(2L);
|
||||
page.setRecords(List.of(withEpisode, legacy));
|
||||
given(commentMapper.selectPage(any(), any())).willReturn(page);
|
||||
AppUser user = new AppUser();
|
||||
user.setId(7L);
|
||||
user.setUid("uid-7");
|
||||
user.setNickname("Viewer");
|
||||
given(appUserMapper.selectBatchIds(any())).willReturn(List.of(user));
|
||||
Drama drama = new Drama();
|
||||
drama.setId(5L);
|
||||
drama.setTitle("Signal");
|
||||
given(dramaService.listByIds(any())).willReturn(List.of(drama));
|
||||
DramaEpisode episode = new DramaEpisode();
|
||||
episode.setId(11L);
|
||||
episode.setEpNo(3);
|
||||
episode.setTitle("The Call");
|
||||
given(episodeService.listByIds(any())).willReturn(List.of(episode));
|
||||
|
||||
PageResult<CommentRespVO> result = commentService.adminPage(new CommentQueryReqVO());
|
||||
|
||||
assertThat(result.getList()).hasSize(2);
|
||||
assertThat(result.getList().get(0).getDramaTitle()).isEqualTo("Signal");
|
||||
assertThat(result.getList().get(0).getEpisodeNo()).isEqualTo(3);
|
||||
assertThat(result.getList().get(0).getEpisodeTitle()).isEqualTo("The Call");
|
||||
assertThat(result.getList().get(1).getDramaTitle()).isEqualTo("Signal");
|
||||
assertThat(result.getList().get(1).getEpisodeNo()).isNull();
|
||||
verify(dramaService).listByIds(List.of(5L));
|
||||
verify(episodeService).listByIds(List.of(11L));
|
||||
}
|
||||
|
||||
private ContentComment comment(Long id, Long dramaId, Long episodeId) {
|
||||
ContentComment comment = new ContentComment();
|
||||
comment.setId(id);
|
||||
comment.setDramaId(dramaId);
|
||||
comment.setEpisodeId(episodeId);
|
||||
comment.setParentId(0L);
|
||||
comment.setRootId(0L);
|
||||
comment.setUserId(7L);
|
||||
comment.setContent("comment");
|
||||
comment.setStatus("published");
|
||||
comment.setAuditReason("");
|
||||
comment.setLikeCount(0);
|
||||
comment.setReplyCount(0);
|
||||
comment.setReportCount(0);
|
||||
return comment;
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.service;
|
||||
|
||||
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
||||
import com.fruitshorts.content.dal.mapper.DramaEpisodeMapper;
|
||||
import com.fruitshorts.media.service.MediaTranscodeOutputService;
|
||||
import com.fruitshorts.media.vo.MediaThumbnailRespVO;
|
||||
import com.fruitshorts.media.vo.TranscodeTaskRespVO;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
|
||||
class EpisodeTranscodeAdminServiceTest {
|
||||
|
||||
private static final Long EPISODE_ID = 2113150431755636737L;
|
||||
private static final Long MEDIA_ASSET_ID = 2113150398670966786L;
|
||||
private static final Long TASK_ID = 2113150398935207938L;
|
||||
|
||||
private DramaEpisodeMapper episodeMapper;
|
||||
private MediaTranscodeOutputService outputService;
|
||||
private EpisodeTranscodeAdminService service;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
episodeMapper = mock(DramaEpisodeMapper.class);
|
||||
outputService = mock(MediaTranscodeOutputService.class);
|
||||
service = new EpisodeTranscodeAdminService(episodeMapper, outputService);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_episode_not_found_state_without_aggregating_media() {
|
||||
given(episodeMapper.selectById(404L)).willReturn(null);
|
||||
|
||||
var result = service.detail(404L);
|
||||
|
||||
assertThat(result.getStatus()).isEqualTo("EPISODE_NOT_FOUND");
|
||||
assertThat(result.getEpisodeId()).isEqualTo("404");
|
||||
assertThat(result.getRenditions()).isEmpty();
|
||||
verifyNoInteractions(outputService);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_no_video_state_when_episode_video_url_is_blank() {
|
||||
DramaEpisode episode = new DramaEpisode();
|
||||
episode.setId(31L);
|
||||
episode.setVideoUrl("");
|
||||
given(episodeMapper.selectById(31L)).willReturn(episode);
|
||||
|
||||
var result = service.detail(31L);
|
||||
|
||||
assertThat(result.getStatus()).isEqualTo("NO_VIDEO");
|
||||
assertThat(result.getRenditions()).isEmpty();
|
||||
verifyNoInteractions(outputService);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_exact_snowflake_media_asset_id_as_string() {
|
||||
DramaEpisode episode = episode(MEDIA_ASSET_ID);
|
||||
given(episodeMapper.selectById(EPISODE_ID)).willReturn(episode);
|
||||
given(outputService.resolveMediaAssetId(episode.getVideoUrl())).willReturn(null);
|
||||
given(outputService.mediaAssetExists(MEDIA_ASSET_ID)).willReturn(true);
|
||||
given(outputService.renditionsForMediaAssetId(MEDIA_ASSET_ID)).willReturn(List.of());
|
||||
given(outputService.thumbnailForEpisode(
|
||||
EPISODE_ID, MEDIA_ASSET_ID, 1, 100))
|
||||
.willReturn(MediaThumbnailRespVO.empty(
|
||||
MEDIA_ASSET_ID, EPISODE_ID,
|
||||
MediaThumbnailRespVO.STATUS_EMPTY, 1, 100));
|
||||
TranscodeTaskRespVO task = new TranscodeTaskRespVO();
|
||||
task.setId(TASK_ID);
|
||||
task.setMediaAssetId(MEDIA_ASSET_ID);
|
||||
task.setStatus("SUCCESS");
|
||||
task.setProgress(100);
|
||||
task.setUpdatedAt(LocalDateTime.of(2026, 10, 22, 15, 10));
|
||||
given(outputService.latestTask(MEDIA_ASSET_ID)).willReturn(task);
|
||||
|
||||
var result = service.detail(EPISODE_ID);
|
||||
|
||||
assertThat(result.getEpisodeId()).isEqualTo("2113150431755636737");
|
||||
assertThat(result.getMediaAssetId()).isEqualTo("2113150398670966786");
|
||||
assertThat(result.getTaskId()).isEqualTo("2113150398935207938");
|
||||
assertThat(result.getUpdatedAt()).isEqualTo(task.getUpdatedAt());
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_explicit_empty_state_when_episode_media_is_missing() {
|
||||
DramaEpisode episode = episode(MEDIA_ASSET_ID);
|
||||
given(episodeMapper.selectById(EPISODE_ID)).willReturn(episode);
|
||||
given(outputService.mediaAssetExists(MEDIA_ASSET_ID)).willReturn(false);
|
||||
given(outputService.resolveMediaAssetId(episode.getVideoUrl())).willReturn(null);
|
||||
|
||||
var result = service.detail(EPISODE_ID);
|
||||
|
||||
assertThat(result.getMediaAssetId()).isNull();
|
||||
assertThat(result.getStatus()).isEqualTo("NO_MEDIA_ASSET");
|
||||
assertThat(result.getErrorMsg()).isNotBlank();
|
||||
assertThat(result.getRenditions()).isEmpty();
|
||||
}
|
||||
|
||||
private DramaEpisode episode(Long videoAssetId) {
|
||||
DramaEpisode episode = new DramaEpisode();
|
||||
episode.setId(EPISODE_ID);
|
||||
episode.setDramaId(7L);
|
||||
episode.setDurationSec(120);
|
||||
episode.setVideoAssetId(videoAssetId);
|
||||
episode.setVideoUrl("/files/episode/202610/video.mp4");
|
||||
return episode;
|
||||
}
|
||||
}
|
||||
+209
@@ -0,0 +1,209 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fruitshorts.admin.vo.AdminReportRespVO;
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.content.dal.entity.Drama;
|
||||
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
||||
import com.fruitshorts.content.dal.mapper.DramaEpisodeMapper;
|
||||
import com.fruitshorts.content.dal.mapper.DramaMapper;
|
||||
import com.fruitshorts.interaction.dal.entity.ContentComment;
|
||||
import com.fruitshorts.interaction.dal.entity.ContentReport;
|
||||
import com.fruitshorts.interaction.dal.mapper.ContentCommentMapper;
|
||||
import com.fruitshorts.interaction.dal.mapper.ContentReportMapper;
|
||||
import com.fruitshorts.interaction.service.ReportService;
|
||||
import com.fruitshorts.interaction.vo.ReportQueryReqVO;
|
||||
import com.fruitshorts.user.dal.entity.AppUser;
|
||||
import com.fruitshorts.user.dal.mapper.AppUserMapper;
|
||||
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/** 后台举报工单目标摘要与批量装配。 */
|
||||
class ReportAdminServiceTest {
|
||||
|
||||
private ContentReportMapper reportMapper;
|
||||
private ContentCommentMapper commentMapper;
|
||||
private DramaMapper dramaMapper;
|
||||
private DramaEpisodeMapper episodeMapper;
|
||||
private AppUserMapper appUserMapper;
|
||||
private ReportAdminService service;
|
||||
|
||||
@BeforeAll
|
||||
static void initTableInfoCache() {
|
||||
TableInfoHelper.initTableInfo(
|
||||
new MapperBuilderAssistant(new MybatisConfiguration(), ""),
|
||||
ContentReport.class);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
reportMapper = mock(ContentReportMapper.class);
|
||||
commentMapper = mock(ContentCommentMapper.class);
|
||||
dramaMapper = mock(DramaMapper.class);
|
||||
episodeMapper = mock(DramaEpisodeMapper.class);
|
||||
appUserMapper = mock(AppUserMapper.class);
|
||||
service = new ReportAdminService(reportMapper, commentMapper, dramaMapper,
|
||||
episodeMapper, appUserMapper);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_build_summary_and_batch_relations_for_all_report_types() {
|
||||
List<ContentReport> rows = List.of(
|
||||
report(1L, 7L, ReportService.TYPE_COMMENT, 101L),
|
||||
report(2L, 8L, ReportService.TYPE_DRAMA, 5L),
|
||||
report(3L, 7L, ReportService.TYPE_USER, 9L));
|
||||
stubPage(rows);
|
||||
given(commentMapper.selectByIdsIncludingDeleted(any()))
|
||||
.willReturn(List.of(comment(101L, 5L, 11L, "bad comment", 0)));
|
||||
given(dramaMapper.selectBatchIds(any())).willReturn(List.of(drama(5L, "Signal")));
|
||||
given(episodeMapper.selectBatchIds(any())).willReturn(List.of(episode(11L, 3, "The Call")));
|
||||
given(appUserMapper.selectBatchIds(any())).willReturn(List.of(
|
||||
user(7L, "Alice", "u-7"),
|
||||
user(8L, "Bob", "u-8"),
|
||||
user(9L, "Target", "u-9")));
|
||||
|
||||
PageResult<AdminReportRespVO> result = service.page(new ReportQueryReqVO());
|
||||
|
||||
AdminReportRespVO commentReport = result.getList().get(0);
|
||||
assertThat(commentReport.getTargetSummary())
|
||||
.isEqualTo("Signal · 第 3 集 · The Call");
|
||||
assertThat(commentReport.getDramaTitle()).isEqualTo("Signal");
|
||||
assertThat(commentReport.getEpisodeNo()).isEqualTo(3);
|
||||
assertThat(commentReport.getCommentContent()).isEqualTo("bad comment");
|
||||
assertThat(commentReport.getReporterNickname()).isEqualTo("Alice");
|
||||
assertThat(commentReport.getReporterUid()).isEqualTo("u-7");
|
||||
|
||||
AdminReportRespVO dramaReport = result.getList().get(1);
|
||||
assertThat(dramaReport.getTargetSummary()).isEqualTo("Signal");
|
||||
assertThat(dramaReport.getDramaId()).isEqualTo(5L);
|
||||
|
||||
AdminReportRespVO userReport = result.getList().get(2);
|
||||
assertThat(userReport.getTargetSummary()).isEqualTo("Target(u-9)");
|
||||
assertThat(userReport.getTargetNickname()).isEqualTo("Target");
|
||||
assertThat(userReport.getTargetUid()).isEqualTo("u-9");
|
||||
verify(commentMapper, times(1)).selectByIdsIncludingDeleted(List.of(101L));
|
||||
verify(dramaMapper, times(1)).selectBatchIds(any());
|
||||
verify(episodeMapper, times(1)).selectBatchIds(any());
|
||||
verify(appUserMapper, times(1)).selectBatchIds(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_leave_all_filters_unset_when_status_and_filters_are_empty() {
|
||||
stubPage(List.of());
|
||||
|
||||
PageResult<AdminReportRespVO> result = service.page(new ReportQueryReqVO());
|
||||
|
||||
assertThat(result.getTotal()).isZero();
|
||||
assertThat(result.getList()).isEmpty();
|
||||
ArgumentCaptor<LambdaQueryWrapper<ContentReport>> captor = queryCaptor();
|
||||
verify(reportMapper).selectPage(any(), captor.capture());
|
||||
assertThat(captor.getValue().getSqlSegment())
|
||||
.doesNotContain("status")
|
||||
.doesNotContain("target_type")
|
||||
.doesNotContain("reason_code")
|
||||
.doesNotContain("reporter_id");
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_fallback_to_ids_when_targets_are_deleted_or_missing() {
|
||||
List<ContentReport> rows = List.of(
|
||||
report(1L, 7L, ReportService.TYPE_COMMENT, 101L),
|
||||
report(2L, 7L, ReportService.TYPE_DRAMA, 5L),
|
||||
report(3L, 7L, ReportService.TYPE_USER, 9L));
|
||||
stubPage(rows);
|
||||
given(commentMapper.selectByIdsIncludingDeleted(any()))
|
||||
.willReturn(List.of(comment(101L, 5L, 11L, "removed", 1)));
|
||||
given(dramaMapper.selectBatchIds(any())).willReturn(List.of());
|
||||
given(appUserMapper.selectBatchIds(any()))
|
||||
.willReturn(List.of(user(7L, "Alice", "u-7")));
|
||||
|
||||
PageResult<AdminReportRespVO> result = service.page(new ReportQueryReqVO());
|
||||
|
||||
assertThat(result.getList()).extracting(AdminReportRespVO::getTargetSummary)
|
||||
.containsExactly("评论 #101", "短剧 #5", "用户 #9");
|
||||
assertThat(result.getList().get(0).getCommentContent()).isNull();
|
||||
verify(episodeMapper, never()).selectBatchIds(any());
|
||||
}
|
||||
|
||||
private void stubPage(List<ContentReport> rows) {
|
||||
Page<ContentReport> page = new Page<>(1, 10);
|
||||
page.setTotal(rows.size());
|
||||
page.setRecords(rows);
|
||||
given(reportMapper.selectPage(any(Page.class), any())).willReturn(page);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private ArgumentCaptor<LambdaQueryWrapper<ContentReport>> queryCaptor() {
|
||||
return ArgumentCaptor.forClass(LambdaQueryWrapper.class);
|
||||
}
|
||||
|
||||
private ContentReport report(Long id, Long reporterId, String type, Long targetId) {
|
||||
ContentReport report = new ContentReport();
|
||||
report.setId(id);
|
||||
report.setReporterId(reporterId);
|
||||
report.setTargetType(type);
|
||||
report.setTargetId(targetId);
|
||||
report.setReasonCode("VIOLATION");
|
||||
report.setDescription("description");
|
||||
report.setStatus("pending");
|
||||
report.setHandleBy(0L);
|
||||
report.setHandleNote("");
|
||||
report.setCreatedAt(LocalDateTime.of(2026, 10, 21, 12, 0));
|
||||
return report;
|
||||
}
|
||||
|
||||
private ContentComment comment(Long id, Long dramaId, Long episodeId, String content,
|
||||
int deleted) {
|
||||
ContentComment comment = new ContentComment();
|
||||
comment.setId(id);
|
||||
comment.setDramaId(dramaId);
|
||||
comment.setEpisodeId(episodeId);
|
||||
comment.setUserId(9L);
|
||||
comment.setContent(content);
|
||||
comment.setStatus(deleted == 1 ? "deleted" : "published");
|
||||
comment.setDeleted(deleted);
|
||||
return comment;
|
||||
}
|
||||
|
||||
private Drama drama(Long id, String title) {
|
||||
Drama drama = new Drama();
|
||||
drama.setId(id);
|
||||
drama.setTitle(title);
|
||||
return drama;
|
||||
}
|
||||
|
||||
private DramaEpisode episode(Long id, int no, String title) {
|
||||
DramaEpisode episode = new DramaEpisode();
|
||||
episode.setId(id);
|
||||
episode.setEpNo(no);
|
||||
episode.setTitle(title);
|
||||
return episode;
|
||||
}
|
||||
|
||||
private AppUser user(Long id, String nickname, String uid) {
|
||||
AppUser user = new AppUser();
|
||||
user.setId(id);
|
||||
user.setNickname(nickname);
|
||||
user.setUid(uid);
|
||||
return user;
|
||||
}
|
||||
}
|
||||
+260
@@ -0,0 +1,260 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.admin.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fruitshorts.admin.vo.AdminWatchHistoryVO;
|
||||
import com.fruitshorts.admin.vo.WatchHistoryQueryReqVO;
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.content.dal.entity.Drama;
|
||||
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
||||
import com.fruitshorts.content.dal.mapper.DramaEpisodeMapper;
|
||||
import com.fruitshorts.content.dal.mapper.DramaMapper;
|
||||
import com.fruitshorts.playback.dal.entity.WatchHistory;
|
||||
import com.fruitshorts.playback.dal.mapper.WatchHistoryMapper;
|
||||
import com.fruitshorts.user.dal.entity.AppUser;
|
||||
import com.fruitshorts.user.dal.mapper.AppUserMapper;
|
||||
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/** 后台观看记录分页条件与批量装配。 */
|
||||
class WatchHistoryAdminServiceTest {
|
||||
|
||||
private WatchHistoryMapper watchHistoryMapper;
|
||||
private AppUserMapper appUserMapper;
|
||||
private DramaMapper dramaMapper;
|
||||
private DramaEpisodeMapper dramaEpisodeMapper;
|
||||
private WatchHistoryAdminService service;
|
||||
|
||||
@BeforeAll
|
||||
static void initTableInfoCache() {
|
||||
MybatisConfiguration configuration = new MybatisConfiguration();
|
||||
for (Class<?> type : List.of(AppUser.class, Drama.class, DramaEpisode.class,
|
||||
WatchHistory.class)) {
|
||||
TableInfoHelper.initTableInfo(new MapperBuilderAssistant(configuration, ""), type);
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
watchHistoryMapper = mock(WatchHistoryMapper.class);
|
||||
appUserMapper = mock(AppUserMapper.class);
|
||||
dramaMapper = mock(DramaMapper.class);
|
||||
dramaEpisodeMapper = mock(DramaEpisodeMapper.class);
|
||||
service = new WatchHistoryAdminService(watchHistoryMapper, appUserMapper, dramaMapper,
|
||||
dramaEpisodeMapper, mock(AppSessionSystemService.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_use_default_page_and_newest_first_when_no_filters_are_given() {
|
||||
WatchHistory row = history(100L, 7L, 5L, 11L);
|
||||
stubPage(row);
|
||||
stubBatchData();
|
||||
|
||||
PageResult<AdminWatchHistoryVO> result = service.page(new WatchHistoryQueryReqVO());
|
||||
|
||||
ArgumentCaptor<Page<WatchHistory>> pageCaptor = pageCaptor();
|
||||
ArgumentCaptor<LambdaQueryWrapper<WatchHistory>> queryCaptor = queryCaptor();
|
||||
verify(watchHistoryMapper).selectPage(pageCaptor.capture(), queryCaptor.capture());
|
||||
assertThat(pageCaptor.getValue().getCurrent()).isEqualTo(1);
|
||||
assertThat(pageCaptor.getValue().getSize()).isEqualTo(10);
|
||||
assertThat(queryCaptor.getValue().getSqlSegment())
|
||||
.contains("watched_at DESC")
|
||||
.contains("id DESC");
|
||||
assertThat(result.getTotal()).isEqualTo(1L);
|
||||
assertThat(result.getList().get(0).getUid()).isEqualTo("user-7");
|
||||
assertThat(result.getList().get(0).getDramaTitle()).isEqualTo("Signal");
|
||||
assertThat(result.getList().get(0).getEpisodeNo()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_filter_by_matched_user_ids_when_keyword_is_present() {
|
||||
WatchHistory row = history(100L, 7L, 5L, 11L);
|
||||
given(appUserMapper.selectList(any())).willReturn(List.of(user(7L, "Alice")));
|
||||
stubPage(row);
|
||||
stubBatchData();
|
||||
WatchHistoryQueryReqVO req = new WatchHistoryQueryReqVO();
|
||||
req.setKeyword("Ali");
|
||||
|
||||
service.page(req);
|
||||
|
||||
LambdaQueryWrapper<WatchHistory> query = capturedQuery();
|
||||
assertThat(query.getSqlSegment()).contains("user_id IN");
|
||||
assertThat(query.getParamNameValuePairs().containsValue(7L)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_filter_by_matched_drama_ids_when_title_is_present() {
|
||||
WatchHistory row = history(100L, 7L, 5L, 11L);
|
||||
given(dramaMapper.selectList(any())).willReturn(List.of(drama(5L, "Signal")));
|
||||
stubPage(row);
|
||||
stubBatchData();
|
||||
WatchHistoryQueryReqVO req = new WatchHistoryQueryReqVO();
|
||||
req.setDramaTitle("Sig");
|
||||
|
||||
service.page(req);
|
||||
|
||||
LambdaQueryWrapper<WatchHistory> query = capturedQuery();
|
||||
assertThat(query.getSqlSegment()).contains("drama_id IN");
|
||||
assertThat(query.getParamNameValuePairs().containsValue(5L)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_empty_page_without_querying_history_when_keyword_has_no_user() {
|
||||
given(appUserMapper.selectList(any())).willReturn(List.of());
|
||||
WatchHistoryQueryReqVO req = new WatchHistoryQueryReqVO();
|
||||
req.setKeyword("missing");
|
||||
|
||||
PageResult<AdminWatchHistoryVO> result = service.page(req);
|
||||
|
||||
assertThat(result.getTotal()).isZero();
|
||||
assertThat(result.getList()).isEmpty();
|
||||
verify(watchHistoryMapper, never()).selectPage(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_apply_true_finished_condition_in_sql() {
|
||||
WatchHistory row = history(100L, 7L, 5L, 11L);
|
||||
row.setPositionMs(59000L);
|
||||
row.setDurationMs(60000L);
|
||||
stubPage(row);
|
||||
stubBatchData();
|
||||
WatchHistoryQueryReqVO req = new WatchHistoryQueryReqVO();
|
||||
req.setFinished(true);
|
||||
|
||||
PageResult<AdminWatchHistoryVO> result = service.page(req);
|
||||
|
||||
LambdaQueryWrapper<WatchHistory> query = capturedQuery();
|
||||
assertThat(query.getSqlSegment())
|
||||
.contains("duration_ms >")
|
||||
.contains("position_ms +");
|
||||
assertThat(query.getParamNameValuePairs().containsValue(1000L)).isTrue();
|
||||
assertThat(result.getList().get(0).getFinished()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_apply_false_finished_condition_in_sql() {
|
||||
WatchHistory row = history(100L, 7L, 5L, 11L);
|
||||
row.setPositionMs(1000L);
|
||||
row.setDurationMs(60000L);
|
||||
stubPage(row);
|
||||
stubBatchData();
|
||||
WatchHistoryQueryReqVO req = new WatchHistoryQueryReqVO();
|
||||
req.setFinished(false);
|
||||
|
||||
PageResult<AdminWatchHistoryVO> result = service.page(req);
|
||||
|
||||
LambdaQueryWrapper<WatchHistory> query = capturedQuery();
|
||||
assertThat(query.getSqlSegment())
|
||||
.contains("duration_ms =")
|
||||
.contains("OR")
|
||||
.contains("position_ms +");
|
||||
assertThat(result.getList().get(0).getFinished()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_apply_closed_time_range_and_clamp_page_size() {
|
||||
WatchHistory row = history(100L, 7L, 5L, 11L);
|
||||
stubPage(row);
|
||||
stubBatchData();
|
||||
LocalDateTime start = LocalDateTime.of(2026, 10, 1, 0, 0);
|
||||
LocalDateTime end = LocalDateTime.of(2026, 10, 21, 23, 59, 59);
|
||||
WatchHistoryQueryReqVO req = new WatchHistoryQueryReqVO();
|
||||
req.setPageSize(500);
|
||||
req.setStartTime(start);
|
||||
req.setEndTime(end);
|
||||
|
||||
service.page(req);
|
||||
|
||||
ArgumentCaptor<Page<WatchHistory>> pageCaptor = pageCaptor();
|
||||
ArgumentCaptor<LambdaQueryWrapper<WatchHistory>> queryCaptor = queryCaptor();
|
||||
verify(watchHistoryMapper).selectPage(pageCaptor.capture(), queryCaptor.capture());
|
||||
assertThat(pageCaptor.getValue().getSize()).isEqualTo(100);
|
||||
assertThat(queryCaptor.getValue().getSqlSegment())
|
||||
.contains("watched_at >=")
|
||||
.contains("watched_at <=");
|
||||
}
|
||||
|
||||
private void stubPage(WatchHistory row) {
|
||||
Page<WatchHistory> page = new Page<>(1, 10);
|
||||
page.setTotal(1L);
|
||||
page.setRecords(List.of(row));
|
||||
given(watchHistoryMapper.selectPage(any(Page.class), any())).willReturn(page);
|
||||
}
|
||||
|
||||
private void stubBatchData() {
|
||||
given(appUserMapper.selectBatchIds(any())).willReturn(List.of(user(7L, "Alice")));
|
||||
given(dramaMapper.selectBatchIds(any())).willReturn(List.of(drama(5L, "Signal")));
|
||||
given(dramaEpisodeMapper.selectBatchIds(any())).willReturn(List.of(episode(11L)));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private ArgumentCaptor<Page<WatchHistory>> pageCaptor() {
|
||||
return ArgumentCaptor.forClass(Page.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private ArgumentCaptor<LambdaQueryWrapper<WatchHistory>> queryCaptor() {
|
||||
return ArgumentCaptor.forClass(LambdaQueryWrapper.class);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<WatchHistory> capturedQuery() {
|
||||
ArgumentCaptor<LambdaQueryWrapper<WatchHistory>> captor = queryCaptor();
|
||||
verify(watchHistoryMapper).selectPage(any(), captor.capture());
|
||||
return captor.getValue();
|
||||
}
|
||||
|
||||
private WatchHistory history(Long id, Long userId, Long dramaId, Long episodeId) {
|
||||
WatchHistory row = new WatchHistory();
|
||||
row.setId(id);
|
||||
row.setUserId(userId);
|
||||
row.setDramaId(dramaId);
|
||||
row.setEpisodeId(episodeId);
|
||||
row.setPositionMs(1000L);
|
||||
row.setDurationMs(60000L);
|
||||
row.setSource("HOME");
|
||||
row.setDeviceId("device-1");
|
||||
row.setWatchedAt(LocalDateTime.of(2026, 10, 21, 12, 0));
|
||||
return row;
|
||||
}
|
||||
|
||||
private AppUser user(Long id, String nickname) {
|
||||
AppUser user = new AppUser();
|
||||
user.setId(id);
|
||||
user.setUid("user-" + id);
|
||||
user.setNickname(nickname);
|
||||
return user;
|
||||
}
|
||||
|
||||
private Drama drama(Long id, String title) {
|
||||
Drama drama = new Drama();
|
||||
drama.setId(id);
|
||||
drama.setTitle(title);
|
||||
drama.setStatus("published");
|
||||
return drama;
|
||||
}
|
||||
|
||||
private DramaEpisode episode(Long id) {
|
||||
DramaEpisode episode = new DramaEpisode();
|
||||
episode.setId(id);
|
||||
episode.setEpNo(1);
|
||||
episode.setTitle("Episode 1");
|
||||
return episode;
|
||||
}
|
||||
}
|
||||
+11
-1
@@ -2,7 +2,9 @@
|
||||
|
||||
package com.fruitshorts.app.controller;
|
||||
|
||||
import com.fruitshorts.app.vo.GoogleLoginReqVO;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.framework.redis.RateLimit;
|
||||
import com.fruitshorts.framework.security.SecurityUtils;
|
||||
import com.fruitshorts.framework.web.WebUtils;
|
||||
import com.fruitshorts.user.service.AppAuthService;
|
||||
@@ -35,6 +37,7 @@ public class AppAuthController {
|
||||
|
||||
/** 发送验证码。频控在服务端,客户端不需要自己限流。 */
|
||||
@Operation(summary = "发送验证码(频控在服务端)")
|
||||
@RateLimit(limit = 20, windowSeconds = 60, key = "otp")
|
||||
@PostMapping("/otp")
|
||||
public Result<Void> sendOtp(@Valid @RequestBody OtpSendReqVO req, HttpServletRequest request) {
|
||||
otpService.send(req, WebUtils.getClientIp(request));
|
||||
@@ -49,16 +52,23 @@ public class AppAuthController {
|
||||
}
|
||||
|
||||
@Operation(summary = "登录(验证码或密码)")
|
||||
@RateLimit(limit = 10, windowSeconds = 60, key = "login")
|
||||
@PostMapping("/login")
|
||||
public Result<TokenRespVO> login(@Valid @RequestBody LoginReqVO req,
|
||||
HttpServletRequest request) {
|
||||
return Result.ok(authService.login(req, WebUtils.getClientIp(request)));
|
||||
}
|
||||
|
||||
@Operation(summary = "Google 登录(未配置 clientId 时返回明确错误)")
|
||||
@PostMapping("/google")
|
||||
public Result<TokenRespVO> google(@Valid @RequestBody GoogleLoginReqVO req) {
|
||||
return Result.ok(authService.googleLogin(req.getIdToken()));
|
||||
}
|
||||
|
||||
@Operation(summary = "刷新令牌(旧 refresh token 立即失效)")
|
||||
@PostMapping("/refresh")
|
||||
public Result<TokenRespVO> refresh(@Valid @RequestBody RefreshReqVO req) {
|
||||
return Result.ok(authService.refresh(req.getRefreshToken()));
|
||||
return Result.ok(authService.refresh(req.getRefreshToken(), req.getPlatform(), req.getOsVersion()));
|
||||
}
|
||||
|
||||
/** 登出:默认只吊销当前设备的会话,allDevices=true 时吊销全部。 */
|
||||
|
||||
+13
@@ -5,12 +5,15 @@ package com.fruitshorts.app.controller;
|
||||
import com.fruitshorts.app.service.AppCatalogService;
|
||||
import com.fruitshorts.app.vo.AppCategoryVO;
|
||||
import com.fruitshorts.app.vo.AppFeedVO;
|
||||
import com.fruitshorts.app.vo.AppDramaCardVO;
|
||||
import com.fruitshorts.common.pojo.CursorResult;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
@@ -38,6 +41,16 @@ public class AppCatalogController {
|
||||
return Result.ok(appCatalogService.discoverFeed());
|
||||
}
|
||||
|
||||
@Operation(summary = "推荐流:支持内容类型、分类过滤与游标翻页")
|
||||
@GetMapping("/feed")
|
||||
public Result<CursorResult<AppDramaCardVO>> feed(
|
||||
@RequestParam(required = false) String types,
|
||||
@RequestParam(required = false) Long categoryId,
|
||||
@RequestParam(required = false) Long cursor,
|
||||
@RequestParam(required = false) Integer size) {
|
||||
return Result.ok(appCatalogService.feed(types, categoryId, cursor, size));
|
||||
}
|
||||
|
||||
@Operation(summary = "分类列表")
|
||||
@GetMapping("/categories")
|
||||
public Result<List<AppCategoryVO>> categories() {
|
||||
|
||||
+20
@@ -3,6 +3,8 @@
|
||||
package com.fruitshorts.app.controller;
|
||||
|
||||
import com.fruitshorts.common.pojo.CursorResult;
|
||||
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
||||
import com.fruitshorts.content.service.EpisodeService;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.framework.security.SecurityUtils;
|
||||
import com.fruitshorts.framework.web.WebUtils;
|
||||
@@ -24,6 +26,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 评论。
|
||||
*
|
||||
@@ -38,6 +42,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class AppCommentController {
|
||||
|
||||
private final CommentService commentService;
|
||||
private final EpisodeService episodeService;
|
||||
|
||||
@Operation(summary = "发布评论")
|
||||
@PostMapping
|
||||
@@ -63,6 +68,21 @@ public class AppCommentController {
|
||||
return Result.ok(commentService.page(SecurityUtils.getUserIdOrNull(), query));
|
||||
}
|
||||
|
||||
@Operation(summary = "评论总数:传 episodeId 按集统计,仅 dramaId 时全剧统计(可匿名访问)")
|
||||
@GetMapping("/count")
|
||||
public Result<Long> count(@RequestParam Long dramaId,
|
||||
@RequestParam(required = false) Long episodeId) {
|
||||
if (episodeId != null) {
|
||||
DramaEpisode episode = episodeService.getPublished(episodeId);
|
||||
if (!dramaId.equals(episode.getDramaId())) {
|
||||
return Result.ok(0L);
|
||||
}
|
||||
return Result.ok(commentService.countByEpisodes(List.of(episodeId))
|
||||
.getOrDefault(episodeId, 0L));
|
||||
}
|
||||
return Result.ok(commentService.countByDrama(dramaId));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除自己的评论")
|
||||
@DeleteMapping("/{id}")
|
||||
public Result<Void> delete(@PathVariable Long id) {
|
||||
|
||||
+20
@@ -4,8 +4,10 @@ package com.fruitshorts.app.controller;
|
||||
|
||||
import com.fruitshorts.commerce.dal.entity.Orders;
|
||||
import com.fruitshorts.commerce.service.OrderService;
|
||||
import com.fruitshorts.commerce.service.ProductService;
|
||||
import com.fruitshorts.commerce.service.UnlockService;
|
||||
import com.fruitshorts.commerce.service.WalletService;
|
||||
import com.fruitshorts.commerce.vo.ProductRespVO;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.framework.security.SecurityUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -37,6 +40,7 @@ public class AppCommerceController {
|
||||
private final WalletService walletService;
|
||||
private final UnlockService unlockService;
|
||||
private final OrderService orderService;
|
||||
private final ProductService productService;
|
||||
|
||||
/** 我的钱包:余额 + 最近流水,客户端一处渲染。 */
|
||||
@Operation(summary = "我的钱包(余额 + 最近流水)")
|
||||
@@ -49,6 +53,22 @@ public class AppCommerceController {
|
||||
return Result.ok(data);
|
||||
}
|
||||
|
||||
/** 充值商品列表:只返回上架商品,type 可选(COIN_PACK/VIP)。 */
|
||||
@Operation(summary = "充值商品列表(只返回上架商品,type 可选 COIN_PACK/VIP)")
|
||||
@GetMapping("/products")
|
||||
public Result<List<ProductRespVO>> products(@RequestParam(required = false) String type) {
|
||||
return Result.ok(productService.listForApp(type));
|
||||
}
|
||||
|
||||
/** 创建充值订单:body 传 productId,返回 CREATED 状态的订单,等待后续支付。 */
|
||||
@Operation(summary = "创建充值订单(body 传 productId)")
|
||||
@PostMapping("/orders")
|
||||
public Result<Orders> createOrder(@RequestBody Map<String, Object> body) {
|
||||
Object productId = body.get("productId");
|
||||
Long pid = productId == null ? null : Long.valueOf(productId.toString());
|
||||
return Result.ok(orderService.createOrder(SecurityUtils.getAppUserId(), pid));
|
||||
}
|
||||
|
||||
/** 金币解锁分集:幂等,重复点击不会重复扣币。 */
|
||||
@Operation(summary = "金币解锁分集(幂等,重复点击不重复扣币)")
|
||||
@PostMapping("/episodes/{episodeId}/unlock")
|
||||
|
||||
+14
-2
@@ -5,14 +5,20 @@ package com.fruitshorts.app.controller;
|
||||
import com.fruitshorts.app.service.AppCatalogService;
|
||||
import com.fruitshorts.app.vo.AppDramaDetailVO;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
||||
import com.fruitshorts.content.service.EpisodeService;
|
||||
import com.fruitshorts.framework.security.SecurityUtils;
|
||||
import com.fruitshorts.framework.web.WebUtils;
|
||||
import com.fruitshorts.interaction.service.CommentService;
|
||||
import com.fruitshorts.playback.service.PlaybackService;
|
||||
import com.fruitshorts.playback.vo.PlayRespVO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -26,6 +32,8 @@ public class AppDramaController {
|
||||
|
||||
private final AppCatalogService appCatalogService;
|
||||
private final PlaybackService playbackService;
|
||||
private final EpisodeService episodeService;
|
||||
private final CommentService commentService;
|
||||
|
||||
/** 详情:包含剧集列表,客户端进详情页一次请求即可渲染 */
|
||||
@Operation(summary = "短剧详情(含剧集列表,进详情页一次请求即可渲染)")
|
||||
@@ -41,10 +49,14 @@ public class AppDramaController {
|
||||
@Operation(summary = "播放票据:判定权益后签发短时效播放地址")
|
||||
@GetMapping("/episodes/{id}/play")
|
||||
public Result<PlayRespVO> play(@PathVariable Long id, HttpServletRequest request) {
|
||||
return Result.ok(playbackService.play(
|
||||
PlayRespVO vo = playbackService.play(
|
||||
SecurityUtils.getUserIdOrNull(),
|
||||
id,
|
||||
request.getHeader("X-Device-Id"),
|
||||
WebUtils.getClientIp(request)));
|
||||
WebUtils.getClientIp(request));
|
||||
DramaEpisode episode = episodeService.getExisting(id);
|
||||
vo.setLikeCount(episode.getLikeCount() == null ? 0L : episode.getLikeCount());
|
||||
vo.setCommentCount(commentService.countByEpisodes(List.of(id)).getOrDefault(id, 0L));
|
||||
return Result.ok(vo);
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.app.controller;
|
||||
|
||||
import com.fruitshorts.app.service.AppEventService;
|
||||
import com.fruitshorts.app.vo.AppEventReqVO;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.framework.security.SecurityUtils;
|
||||
import com.fruitshorts.framework.web.WebUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/** 客户端埋点上报。 */
|
||||
@Tag(name = "埋点")
|
||||
@RestController
|
||||
@RequestMapping("/app")
|
||||
@RequiredArgsConstructor
|
||||
public class AppEventController {
|
||||
|
||||
private final AppEventService eventService;
|
||||
|
||||
@Operation(summary = "埋点事件批量上报")
|
||||
@PostMapping("/events")
|
||||
public Result<Void> report(@Valid @RequestBody AppEventReqVO req, HttpServletRequest request) {
|
||||
eventService.save(req, SecurityUtils.getUserIdOrNull(), WebUtils.getClientIp(request));
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
||||
+11
-5
@@ -4,9 +4,12 @@ package com.fruitshorts.app.controller;
|
||||
|
||||
import com.fruitshorts.app.service.AppCatalogService;
|
||||
import com.fruitshorts.app.vo.AppDramaCardVO;
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.content.dal.entity.Drama;
|
||||
import com.fruitshorts.framework.security.SecurityUtils;
|
||||
import com.fruitshorts.playback.service.FavoriteService;
|
||||
import com.fruitshorts.playback.vo.FavoriteRemoveReqVO;
|
||||
import com.fruitshorts.playback.vo.FavoriteToggleReqVO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -18,10 +21,9 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** 收藏。 */
|
||||
@Tag(name = "客户端-收藏")
|
||||
@RestController
|
||||
@@ -42,9 +44,13 @@ public class AppFavoriteController {
|
||||
/** 收藏列表,卡片结构与首页一致。 */
|
||||
@Operation(summary = "我的收藏列表")
|
||||
@GetMapping
|
||||
public Result<List<AppDramaCardVO>> list() {
|
||||
return Result.ok(appCatalogService.toCards(
|
||||
favoriteService.listDramas(SecurityUtils.getAppUserId())));
|
||||
public Result<PageResult<AppDramaCardVO>> list(
|
||||
@RequestParam(defaultValue = "1") int pageIndex,
|
||||
@RequestParam(defaultValue = "20") int pageSize) {
|
||||
PageResult<Drama> page = favoriteService.page(
|
||||
SecurityUtils.getAppUserId(), pageIndex, pageSize);
|
||||
return Result.ok(new PageResult<>(
|
||||
page.getTotal(), appCatalogService.toCards(page.getList())));
|
||||
}
|
||||
|
||||
@Operation(summary = "取消收藏")
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.app.controller;
|
||||
|
||||
import com.fruitshorts.app.service.AppSearchService;
|
||||
import com.fruitshorts.app.vo.AppDramaCardVO;
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/** 客户端搜索:按标题或简介模糊匹配已上线短剧。不需要登录。 */
|
||||
@Tag(name = "客户端-搜索")
|
||||
@RestController
|
||||
@RequestMapping("/app")
|
||||
@RequiredArgsConstructor
|
||||
public class AppSearchController {
|
||||
|
||||
private final AppSearchService appSearchService;
|
||||
|
||||
@Operation(summary = "搜索短剧(按标题/简介模糊匹配,只返回已上线)")
|
||||
@GetMapping("/search")
|
||||
public Result<PageResult<AppDramaCardVO>> search(@RequestParam String keyword,
|
||||
@RequestParam(defaultValue = "1") int pageIndex,
|
||||
@RequestParam(defaultValue = "20") int pageSize) {
|
||||
return Result.ok(appSearchService.search(keyword, pageIndex, pageSize));
|
||||
}
|
||||
}
|
||||
+8
-5
@@ -2,6 +2,7 @@
|
||||
|
||||
package com.fruitshorts.app.controller;
|
||||
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.common.pojo.Result;
|
||||
import com.fruitshorts.framework.security.SecurityUtils;
|
||||
import com.fruitshorts.playback.service.WatchProgressService;
|
||||
@@ -20,8 +21,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** 观看进度与观看记录。 */
|
||||
@Tag(name = "客户端-观看进度")
|
||||
@RestController
|
||||
@@ -45,10 +44,14 @@ public class AppWatchController {
|
||||
return Result.ok(progressService.ofDrama(SecurityUtils.getAppUserId(), dramaId));
|
||||
}
|
||||
|
||||
@Operation(summary = "最近观看列表")
|
||||
/** 最近观看分页,契约与 /app/favorites 一致:pageIndex/pageSize。 */
|
||||
@Operation(summary = "最近观看分页")
|
||||
@GetMapping("/recent")
|
||||
public Result<List<ProgressRespVO>> recent(@RequestParam(defaultValue = "20") int limit) {
|
||||
return Result.ok(progressService.recent(SecurityUtils.getAppUserId(), limit));
|
||||
public Result<PageResult<ProgressRespVO>> recent(
|
||||
@RequestParam(defaultValue = "1") int pageIndex,
|
||||
@RequestParam(defaultValue = "20") int pageSize) {
|
||||
return Result.ok(progressService.recentPage(
|
||||
SecurityUtils.getAppUserId(), pageIndex, pageSize));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除某部剧的观看记录")
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.app.controller;
|
||||
|
||||
import com.fruitshorts.system.service.LegalDocumentService;
|
||||
import com.fruitshorts.system.service.LegalPages;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 协议公开页。客户端按当前语言打开 /privacy/zh 或 /terms/en,不需要登录。
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class LegalPageController {
|
||||
|
||||
private static final MediaType HTML = MediaType.parseMediaType("text/html;charset=UTF-8");
|
||||
|
||||
private final LegalDocumentService legalDocumentService;
|
||||
|
||||
/** 隐私协议。语言只接受 zh、en、id。 */
|
||||
@GetMapping("/" + LegalPages.PATH_PRIVACY + "/{lang}")
|
||||
public ResponseEntity<String> privacy(@PathVariable String lang) {
|
||||
return page(LegalPages.PATH_PRIVACY, lang);
|
||||
}
|
||||
|
||||
/** 服务条款。语言只接受 zh、en、id。 */
|
||||
@GetMapping("/" + LegalPages.PATH_TERMS + "/{lang}")
|
||||
public ResponseEntity<String> terms(@PathVariable String lang) {
|
||||
return page(LegalPages.PATH_TERMS, lang);
|
||||
}
|
||||
|
||||
private ResponseEntity<String> page(String path, String lang) {
|
||||
String html = legalDocumentService.render(path, lang);
|
||||
if (html == null) {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
return ResponseEntity.ok().contentType(HTML).body(html);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.app.dal.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/** 埋点事件落库记录,为后续分析/漏斗预留原始数据。 */
|
||||
@Data
|
||||
@TableName("app_event_log")
|
||||
public class AppEventLog {
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
private String eventName;
|
||||
private LocalDateTime eventTime;
|
||||
private Long userId;
|
||||
private String deviceId;
|
||||
private String sessionId;
|
||||
private String page;
|
||||
private String properties;
|
||||
private String clientIp;
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@TableField(updateStrategy = FieldStrategy.NEVER)
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.app.dal.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fruitshorts.app.dal.entity.AppEventLog;
|
||||
|
||||
/** 埋点事件 Mapper。 */
|
||||
public interface AppEventLogMapper extends BaseMapper<AppEventLog> {
|
||||
}
|
||||
+63
-7
@@ -9,6 +9,7 @@ import com.fruitshorts.app.vo.AppDramaDetailVO;
|
||||
import com.fruitshorts.app.vo.AppEpisodeVO;
|
||||
import com.fruitshorts.app.vo.AppFeedVO;
|
||||
import com.fruitshorts.app.vo.AppSectionVO;
|
||||
import com.fruitshorts.common.pojo.CursorResult;
|
||||
import com.fruitshorts.content.dal.entity.ContentBanner;
|
||||
import com.fruitshorts.content.dal.entity.Drama;
|
||||
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
||||
@@ -17,7 +18,9 @@ import com.fruitshorts.content.service.BannerService;
|
||||
import com.fruitshorts.content.service.DramaCategoryService;
|
||||
import com.fruitshorts.content.service.DramaService;
|
||||
import com.fruitshorts.content.service.EpisodeService;
|
||||
import com.fruitshorts.interaction.service.CommentService;
|
||||
import com.fruitshorts.media.service.PlaybackSigner;
|
||||
import com.fruitshorts.media.service.ThumbnailUrlResolver;
|
||||
import com.fruitshorts.content.vo.DramaCategoryRespVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -26,6 +29,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* C 端目录聚合:把内容域的只读视图组装成客户端一次请求就能渲染的结构。
|
||||
@@ -38,12 +42,16 @@ public class AppCatalogService {
|
||||
private static final int HOME_SECTION_SIZE = 6;
|
||||
private static final int DISCOVER_SECTION_SIZE = 10;
|
||||
private static final int MAX_CATEGORY_SECTIONS = 4;
|
||||
private static final int DEFAULT_FEED_SIZE = 20;
|
||||
private static final int MAX_FEED_SIZE = 50;
|
||||
|
||||
private final DramaService dramaService;
|
||||
private final EpisodeService episodeService;
|
||||
private final BannerService bannerService;
|
||||
private final DramaCategoryService dramaCategoryService;
|
||||
private final PlaybackSigner playbackSigner;
|
||||
private final CommentService commentService;
|
||||
private final ThumbnailUrlResolver thumbnailUrlResolver;
|
||||
|
||||
public AppFeedVO homeFeed() {
|
||||
Map<Long, String> categoryNames = categoryNameMap();
|
||||
@@ -68,6 +76,26 @@ public class AppCatalogService {
|
||||
.toList();
|
||||
}
|
||||
|
||||
public CursorResult<AppDramaCardVO> feed(
|
||||
String types, Long categoryId, Long cursor, Integer size) {
|
||||
int pageSize = size == null ? DEFAULT_FEED_SIZE : Math.max(1, Math.min(size, MAX_FEED_SIZE));
|
||||
List<String> dramaTypes = types == null
|
||||
? List.of()
|
||||
: Arrays.stream(types.split(","))
|
||||
.map(String::trim)
|
||||
.filter(type -> !type.isEmpty())
|
||||
.toList();
|
||||
List<Drama> rows = dramaService.listPublishedFeed(
|
||||
dramaTypes, categoryId, cursor, pageSize + 1);
|
||||
if (rows.isEmpty()) {
|
||||
return CursorResult.empty();
|
||||
}
|
||||
boolean hasMore = rows.size() > pageSize;
|
||||
List<Drama> pageRows = hasMore ? rows.subList(0, pageSize) : rows;
|
||||
Long nextCursor = hasMore ? pageRows.get(pageRows.size() - 1).getId() : null;
|
||||
return new CursorResult<>(cards(pageRows, categoryNameMap()), nextCursor, hasMore);
|
||||
}
|
||||
|
||||
/**
|
||||
* 供收藏、观看记录等列表复用卡片结构:字段与首页卡片完全一致,
|
||||
* 客户端可以用同一套渲染逻辑,不用为每个列表各写一份。
|
||||
@@ -82,6 +110,10 @@ public class AppCatalogService {
|
||||
public AppDramaDetailVO dramaDetail(Long dramaId) {
|
||||
Drama drama = dramaService.getPublished(dramaId);
|
||||
List<DramaEpisode> episodes = episodeService.listPublishedByDrama(dramaId);
|
||||
Map<Long, Long> episodeCommentCounts = commentService.countByEpisodes(
|
||||
episodes.stream().map(DramaEpisode::getId).sorted().toList());
|
||||
Map<Long, String> thumbnailUrls = thumbnailUrlResolver.resolveAll(
|
||||
episodes.stream().map(DramaEpisode::getId).sorted().toList());
|
||||
String categoryName = categoryNameMap().getOrDefault(drama.getCategoryId(), "");
|
||||
|
||||
AppDramaDetailVO detail = new AppDramaDetailVO();
|
||||
@@ -96,7 +128,12 @@ public class AppCatalogService {
|
||||
detail.setUnlockCoin(drama.getUnlockCoin());
|
||||
detail.setIsHot(drama.getIsHot() != null && drama.getIsHot() == 1);
|
||||
detail.setViewCount(drama.getViewCount());
|
||||
detail.setEpisodes(episodes.stream().map(this::toEpisode).toList());
|
||||
detail.setLikeCount(drama.getLikeCount());
|
||||
detail.setFavoriteCount(drama.getFavoriteCount());
|
||||
detail.setCommentCount(commentService.countByDrama(dramaId));
|
||||
detail.setEpisodes(episodes.stream()
|
||||
.map(episode -> toEpisode(episode, episodeCommentCounts, thumbnailUrls))
|
||||
.toList());
|
||||
return detail;
|
||||
}
|
||||
|
||||
@@ -139,15 +176,22 @@ public class AppCatalogService {
|
||||
|
||||
/** 整屏卡片共用一次剧集查询,取每部剧的首个可播免费集作为预览。 */
|
||||
private List<AppDramaCardVO> cards(List<Drama> dramas, Map<Long, String> categoryNames) {
|
||||
Map<Long, DramaEpisode> previews = episodeService.firstPlayableByDramas(
|
||||
dramas.stream().map(Drama::getId).toList());
|
||||
List<Long> ids = dramas.stream().map(Drama::getId).toList();
|
||||
Map<Long, DramaEpisode> previews = episodeService.firstPlayableByDramas(ids);
|
||||
Map<Long, Long> commentCounts = commentService.countByEpisodes(
|
||||
previews.values().stream().map(DramaEpisode::getId).sorted().toList());
|
||||
Map<Long, String> thumbnailUrls = thumbnailUrlResolver.resolveAll(
|
||||
previews.values().stream().map(DramaEpisode::getId).sorted().toList());
|
||||
return dramas.stream()
|
||||
.map(drama -> toCard(drama, categoryNames, previews.get(drama.getId())))
|
||||
.map(drama -> toCard(
|
||||
drama, categoryNames, previews.get(drama.getId()), commentCounts,
|
||||
thumbnailUrls))
|
||||
.toList();
|
||||
}
|
||||
|
||||
private AppDramaCardVO toCard(Drama drama, Map<Long, String> categoryNames,
|
||||
DramaEpisode preview) {
|
||||
DramaEpisode preview, Map<Long, Long> commentCounts,
|
||||
Map<Long, String> thumbnailUrls) {
|
||||
AppDramaCardVO card = new AppDramaCardVO();
|
||||
card.setId(drama.getId());
|
||||
card.setTitle(drama.getTitle());
|
||||
@@ -158,11 +202,20 @@ public class AppCatalogService {
|
||||
card.setTotalEpisodes(drama.getTotalEpisodes());
|
||||
card.setIsHot(drama.getIsHot() != null && drama.getIsHot() == 1);
|
||||
card.setViewCount(drama.getViewCount());
|
||||
card.setPreview(preview == null ? null : toEpisode(preview));
|
||||
card.setLikeCount(preview == null || preview.getLikeCount() == null
|
||||
? 0L : preview.getLikeCount());
|
||||
card.setFavoriteCount(drama.getFavoriteCount());
|
||||
card.setCommentCount(preview == null
|
||||
? 0L : commentCounts.getOrDefault(preview.getId(), 0L));
|
||||
card.setLanguage(drama.getLanguage());
|
||||
card.setDramaType(drama.getDramaType());
|
||||
card.setPreview(preview == null
|
||||
? null : toEpisode(preview, commentCounts, thumbnailUrls));
|
||||
return card;
|
||||
}
|
||||
|
||||
private AppEpisodeVO toEpisode(DramaEpisode episode) {
|
||||
private AppEpisodeVO toEpisode(DramaEpisode episode, Map<Long, Long> commentCounts,
|
||||
Map<Long, String> thumbnailUrls) {
|
||||
AppEpisodeVO vo = new AppEpisodeVO();
|
||||
vo.setId(episode.getId());
|
||||
vo.setNumber(episode.getEpNo());
|
||||
@@ -174,6 +227,9 @@ public class AppCatalogService {
|
||||
vo.setIsFree(free);
|
||||
vo.setLocked(!free);
|
||||
vo.setUnlockCoin(episode.getUnlockCoin());
|
||||
vo.setLikeCount(episode.getLikeCount() == null ? 0L : episode.getLikeCount());
|
||||
vo.setCommentCount(commentCounts.getOrDefault(episode.getId(), 0L));
|
||||
vo.setThumbnailsUrl(thumbnailUrls.get(episode.getId()));
|
||||
if (free) {
|
||||
// 播放地址统一在这里签名:客户端拿不到可长期复用的裸地址
|
||||
vo.setPlayUrl(playbackSigner.sign(playableSource(episode)));
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.app.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fruitshorts.app.dal.entity.AppEventLog;
|
||||
import com.fruitshorts.app.dal.mapper.AppEventLogMapper;
|
||||
import com.fruitshorts.app.vo.AppEventReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/** 埋点事件接收:批量落库,事件名与属性暂不校验、透传,口径后续与运营对齐。 */
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AppEventService {
|
||||
|
||||
private final AppEventLogMapper eventLogMapper;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@SneakyThrows
|
||||
public void save(AppEventReqVO req, Long userId, String clientIp) {
|
||||
for (AppEventReqVO.EventItem item : req.getEvents()) {
|
||||
AppEventLog log = new AppEventLog();
|
||||
log.setEventName(item.getEventName());
|
||||
log.setEventTime(item.getEventTime() == null ? LocalDateTime.now() : item.getEventTime());
|
||||
log.setUserId(userId);
|
||||
log.setDeviceId(req.getDeviceId());
|
||||
log.setSessionId(req.getSessionId());
|
||||
log.setPage(item.getPage());
|
||||
log.setProperties(item.getProperties() == null ? null
|
||||
: objectMapper.writeValueAsString(item.getProperties()));
|
||||
log.setClientIp(clientIp);
|
||||
log.setCreatedAt(LocalDateTime.now());
|
||||
eventLogMapper.insert(log);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
package com.fruitshorts.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fruitshorts.app.vo.AppDramaCardVO;
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.content.dal.entity.Drama;
|
||||
import com.fruitshorts.content.dal.mapper.DramaMapper;
|
||||
import com.fruitshorts.content.enums.ContentStatus;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* 客户端搜索:只搜已上线短剧,命中标题或简介。
|
||||
* 结果复用 {@link AppCatalogService#toCards} 的卡片转换,保证与首页卡片字段一致。
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AppSearchService {
|
||||
|
||||
private static final int MAX_PAGE_SIZE = 50;
|
||||
|
||||
private final DramaMapper dramaMapper;
|
||||
private final AppCatalogService appCatalogService;
|
||||
|
||||
public PageResult<AppDramaCardVO> search(String keyword, int pageIndex, int pageSize) {
|
||||
if (!StringUtils.hasText(keyword)) {
|
||||
return PageResult.empty();
|
||||
}
|
||||
int safeIndex = Math.max(pageIndex, 1);
|
||||
int safeSize = Math.min(Math.max(pageSize, 1), MAX_PAGE_SIZE);
|
||||
Page<Drama> page = new Page<>(safeIndex, safeSize);
|
||||
Page<Drama> result = dramaMapper.selectPage(page, Wrappers.<Drama>lambdaQuery()
|
||||
.eq(Drama::getStatus, ContentStatus.PUBLISHED.getCode())
|
||||
.and(w -> w.like(Drama::getTitle, keyword.trim())
|
||||
.or().like(Drama::getSynopsis, keyword.trim()))
|
||||
.orderByDesc(Drama::getSort)
|
||||
.orderByDesc(Drama::getId));
|
||||
return new PageResult<>(result.getTotal(), appCatalogService.toCards(result.getRecords()));
|
||||
}
|
||||
}
|
||||
Loaded 100 of 264 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user