Compare commits
386
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
28d2679b83 | ||
|
|
6b5e70e554 | ||
|
|
5c93ba9131 | ||
|
|
1bf74bdd4c | ||
|
|
9267a9026f | ||
|
|
20f19b13f2 |
No files matched your search
@@ -30,6 +30,11 @@ MEDIA_ROOT_DIR=/data/uploads
|
|||||||
# false = 两个都关闭(生产若不希望暴露 UI 就设 false,机器可读契约也一并关闭)
|
# false = 两个都关闭(生产若不希望暴露 UI 就设 false,机器可读契约也一并关闭)
|
||||||
SWAGGER_ENABLED=true
|
SWAGGER_ENABLED=true
|
||||||
|
|
||||||
|
# ── 监控 ───────────────────────────────────────────────
|
||||||
|
# Grafana 管理员密码(必填):3000 端口对外开放,不允许用默认 admin/admin
|
||||||
|
GRAFANA_ADMIN_USER=admin
|
||||||
|
GRAFANA_ADMIN_PASSWORD=
|
||||||
|
|
||||||
# ── 可选:Google Play 商店票据校验(不配则保持 disabled)──
|
# ── 可选:Google Play 商店票据校验(不配则保持 disabled)──
|
||||||
STORE_VERIFIER=disabled
|
STORE_VERIFIER=disabled
|
||||||
GOOGLE_PLAY_PACKAGE_NAME=
|
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
|
env_file: .env
|
||||||
environment:
|
environment:
|
||||||
SERVER_PORT: "8080"
|
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}}
|
DB_URL: ${DB_URL:-jdbc:postgresql://db:5432/${DB_NAME:-fruitshorts}}
|
||||||
|
# 管理端仅内网,页面上直接播放/下载裸媒资地址(不签播放签名),
|
||||||
|
# 因此这里不启用 /files/episode/** 的签名校验;公开的 app-api 仍保持开启。
|
||||||
|
FRUITSHORTS_MEDIA_PROTECTED_PREFIXES: ""
|
||||||
ports:
|
ports:
|
||||||
# docs/12-上线检查清单「管理端仅内网」:只绑本机,公网不直接暴露
|
# docs/12-上线检查清单「管理端仅内网」:只对局域网开放;不在路由器做端口转发,公网访问不到
|
||||||
- "127.0.0.1:8080:8080"
|
- "8080:8080"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/uploads:/data/uploads
|
- ./data/uploads:/data/uploads
|
||||||
depends_on:
|
depends_on:
|
||||||
@@ -142,7 +148,71 @@ services:
|
|||||||
start_period: 40s
|
start_period: 40s
|
||||||
retries: 3
|
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:
|
volumes:
|
||||||
# 命名卷:跟着 compose 项目走,`docker compose down -v` 才会删
|
# 命名卷:跟着 compose 项目走,`docker compose down -v` 才会删
|
||||||
db-data:
|
db-data:
|
||||||
redis-data:
|
redis-data:
|
||||||
|
prometheus-data:
|
||||||
|
grafana-data:
|
||||||
+110
-8
@@ -165,10 +165,88 @@ app.register.max-per-device-per-day
|
|||||||
|
|
||||||
| 方法 | 路径 | 说明 |
|
| 方法 | 路径 | 说明 |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| GET | `/app/home/feed` | 首页:轮播 + 分区,卡片带 `preview` 可播预览集 |
|
| GET | `/app/home/feed` | 首页:轮播 + 分区,卡片带 `preview` 可播预览集与 `language` 语种 |
|
||||||
| GET | `/app/discover/feed` | 发现页分区 |
|
| GET | `/app/discover/feed` | 发现页分区 |
|
||||||
|
| GET | `/app/feed?types=ANIME,LIVE&categoryId=7&cursor=&size=20` | 推荐流;支持内容类型与分类叠加过滤,游标翻页 |
|
||||||
| GET | `/app/categories` | 分类列表 |
|
| GET | `/app/categories` | 分类列表 |
|
||||||
| GET | `/app/dramas/{id}` | 详情(含剧集列表,免费集带**已签名**播放地址) |
|
| 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..."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
详情里的互动数量:
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `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` 统计 |
|
||||||
|
|
||||||
|
计数是只读快照:互动操作完成后客户端重新拉取详情即可刷新;`Long` 字段一律按字符串下发,
|
||||||
|
客户端需要转成数字再展示(与 `viewCount` 相同)。
|
||||||
|
|
||||||
### 1.4 播放(已实现,链路已重做)
|
### 1.4 播放(已实现,链路已重做)
|
||||||
|
|
||||||
@@ -186,7 +264,9 @@ app.register.max-per-device-per-day
|
|||||||
"playUrl": "/files/episode/202610/xxx.mp4?e=1760000000&s=9f2c...",
|
"playUrl": "/files/episode/202610/xxx.mp4?e=1760000000&s=9f2c...",
|
||||||
"qualities": ["AUTO"],
|
"qualities": ["AUTO"],
|
||||||
"unlockCoin": 0,
|
"unlockCoin": 0,
|
||||||
"previewSeconds": 0
|
"previewSeconds": 0,
|
||||||
|
"likeCount": "45",
|
||||||
|
"commentCount": "8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -240,8 +320,9 @@ app.register.max-per-device-per-day
|
|||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| POST | `/app/comments` | 登录 | 发表评论/回复:过敏感词后按策略发布或转待审 |
|
| POST | `/app/comments` | 登录 | 发表评论/回复:过敏感词后按策略发布或转待审 |
|
||||||
| GET | `/app/comments?dramaId=&cursor=&size=` | 匿名 | 游标翻页;不传 `rootId` 返回顶层评论,传了返回该楼层回复 |
|
| GET | `/app/comments?dramaId=&cursor=&size=` | 匿名 | 游标翻页;不传 `rootId` 返回顶层评论,传了返回该楼层回复 |
|
||||||
|
| GET | `/app/comments/count?dramaId=&episodeId=` | 匿名 | 传 `episodeId` 返回该集评论数;仅传 `dramaId` 返回全剧兼容汇总 |
|
||||||
| DELETE | `/app/comments/{id}` | 登录 | 删除自己的评论(逻辑置为 `deleted`) |
|
| DELETE | `/app/comments/{id}` | 登录 | 删除自己的评论(逻辑置为 `deleted`) |
|
||||||
| POST | `/app/likes/toggle` | 登录 | 点赞/取消点赞,`targetType` 支持 `DRAMA` / `COMMENT` |
|
| POST | `/app/likes/toggle` | 登录 | 点赞/取消点赞,`targetType` 支持 `DRAMA` / `EPISODE` / `COMMENT`;新客户端点赞按集 |
|
||||||
| POST | `/app/reports` | 登录 | 举报评论/用户/短剧;同一目标只保留一条待处理工单 |
|
| POST | `/app/reports` | 登录 | 举报评论/用户/短剧;同一目标只保留一条待处理工单 |
|
||||||
|
|
||||||
**敏感词三档处置**:`BLOCK` 直接拒绝并返回原因、`REPLACE` 替换后放行、`REVIEW` 转人工待审。
|
**敏感词三档处置**:`BLOCK` 直接拒绝并返回原因、`REPLACE` 替换后放行、`REVIEW` 转人工待审。
|
||||||
@@ -257,9 +338,17 @@ app.register.max-per-device-per-day
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| GET | `/app/wallet` | 金币余额 + 最近流水 |
|
| GET | `/app/wallet` | 金币余额 + 最近流水 |
|
||||||
| POST | `/app/episodes/{id}/unlock` | 金币解锁分集;幂等键 `unlock:{userId}:{episodeId}`,重复调用不重复扣币 |
|
| POST | `/app/episodes/{id}/unlock` | 金币解锁分集;幂等键 `unlock:{userId}:{episodeId}`,重复调用不重复扣币 |
|
||||||
|
| GET | `/app/products` | 充值商品列表(只返回上架商品,`type` 可选 `COIN_PACK`/`VIP`) |
|
||||||
|
| POST | `/app/orders` | 创建充值订单(`body` 传 `productId`,返回 `CREATED` 订单,等待支付) |
|
||||||
| GET | `/app/orders` | 我的订单 |
|
| GET | `/app/orders` | 我的订单 |
|
||||||
| POST | `/app/orders/verify` | 提交 Google Play 票据:服务端校验 → 建单 → 发权益(详见下方说明) |
|
| 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` 实现提供,
|
解锁后播放入口与下载入口会同时放行 —— 权益判定由交易模块的 `EntitlementPort` 实现提供,
|
||||||
播放域与下载域都不需要改代码。金币变动一律带幂等键并写 `coin_ledger`,钱包余额与流水同事务。
|
播放域与下载域都不需要改代码。金币变动一律带幂等键并写 `coin_ledger`,钱包余额与流水同事务。
|
||||||
|
|
||||||
@@ -444,10 +533,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` | 详情 |
|
| GET | `/admin/dramas/{id}` | `drama:list` | 详情 |
|
||||||
| POST | `/admin/dramas` | `drama:create` | 新建短剧 |
|
| POST | `/admin/dramas` | `drama:create` | 新建短剧;优先接收 `dramaTypes[]` / `categoryIds[]` |
|
||||||
| PUT | `/admin/dramas/{id}` | `drama:update` | 编辑短剧 |
|
| PUT | `/admin/dramas/{id}` | `drama:update` | 编辑短剧;优先接收 `dramaTypes[]` / `categoryIds[]` |
|
||||||
| DELETE | `/admin/dramas/{id}` | `drama:delete` | 删除短剧 |
|
| DELETE | `/admin/dramas/{id}` | `drama:delete` | 删除短剧 |
|
||||||
| POST | `/admin/dramas/{id}/submit` | `drama:review` / `drama:update` | 提交审核 |
|
| POST | `/admin/dramas/{id}/submit` | `drama:review` / `drama:update` | 提交审核 |
|
||||||
| POST | `/admin/dramas/{id}/approve` | `drama:review` | 审核通过 |
|
| POST | `/admin/dramas/{id}/approve` | `drama:review` | 审核通过 |
|
||||||
@@ -456,6 +545,15 @@ GET /app/notices?pageIndex=1&pageSize=20
|
|||||||
| POST | `/admin/dramas/{id}/offline` | `drama:review` | 下线 |
|
| POST | `/admin/dramas/{id}/offline` | `drama:review` | 下线 |
|
||||||
| GET | `/admin/dramas/{id}/review-records` | `drama:list` | 审核记录 |
|
| GET | `/admin/dramas/{id}/review-records` | `drama:list` | 审核记录 |
|
||||||
|
|
||||||
|
多选字段说明:
|
||||||
|
|
||||||
|
- 保存优先使用 `dramaTypes[]` / `categoryIds[]`,去重并保持提交顺序;
|
||||||
|
`drama_type` / `category_id` 写第一个值,供旧客户端与旧接口兼容。
|
||||||
|
- 仅传 `dramaType` / `categoryId` 时保持原单值行为。
|
||||||
|
- 列表响应返回 `dramaTypes[]`、`categoryIds[]` 与按选中顺序映射的 `categoryNames[]`;
|
||||||
|
分类名缺失时回退 `genre`。
|
||||||
|
- 后台与 App 过滤均使用 `(',' || column || ',') LIKE '%,value,%'` 整词匹配。
|
||||||
|
|
||||||
**剧集**
|
**剧集**
|
||||||
|
|
||||||
| 方法 | 路径 | 权限点 | 说明 |
|
| 方法 | 路径 | 权限点 | 说明 |
|
||||||
@@ -507,6 +605,7 @@ GET /app/notices?pageIndex=1&pageSize=20
|
|||||||
| GET | `/admin/app-users/{id}` | `app-user:list` | 详情 |
|
| GET | `/admin/app-users/{id}` | `app-user:list` | 详情 |
|
||||||
| GET | `/admin/app-users/{id}/ban-records` | `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/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 |
|
| PUT | `/admin/app-users/{id}/status` | `app-user:update` | 改状态:normal/limited/banned |
|
||||||
|
|
||||||
状态处置会**立即吊销该用户全部会话**并写入封禁记录,避免"封了还能用"。
|
状态处置会**立即吊销该用户全部会话**并写入封禁记录,避免"封了还能用"。
|
||||||
@@ -524,15 +623,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` | 审核留证:机审与人审的完整链路 |
|
| GET | `/admin/comments/{id}/audit-records` | `comment:list` | 审核留证:机审与人审的完整链路 |
|
||||||
| PUT | `/admin/comments/{id}/audit` | `comment:audit` | 通过 / 驳回(带原因码与说明) |
|
| PUT | `/admin/comments/{id}/audit` | `comment:audit` | 通过 / 驳回(带原因码与说明) |
|
||||||
| DELETE | `/admin/comments/{id}` | `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` | 处理工单;结论成立会联动驳回被举报评论,可选择同时封禁被举报用户 |
|
| PUT | `/admin/reports/{id}/handle` | `report:handle` | 处理工单;结论成立会联动驳回被举报评论,可选择同时封禁被举报用户 |
|
||||||
| GET | `/admin/sensitive-words/page` | `sensitive-word:list` | 敏感词检索 |
|
| GET | `/admin/sensitive-words/page` | `sensitive-word:list` | 敏感词检索 |
|
||||||
| POST/PUT/DELETE | `/admin/sensitive-words[/{id}]` | `sensitive-word:update` | 维护词库,改动即时生效(服务端缓存失效重建) |
|
| POST/PUT/DELETE | `/admin/sensitive-words[/{id}]` | `sensitive-word:update` | 维护词库,改动即时生效(服务端缓存失效重建) |
|
||||||
|
|
||||||
|
后台评论行除 `dramaId/episodeId` 外,还返回 `dramaTitle/episodeNo/episodeTitle`;
|
||||||
|
剧或集已删除时对应展示字段留空。后台评论与举报的 `status` 空值均表示全部状态。
|
||||||
|
|
||||||
### 2.6 订单与权益(已实现)
|
### 2.6 订单与权益(已实现)
|
||||||
|
|
||||||
| 方法 | 路径 | 权限点 | 说明 |
|
| 方法 | 路径 | 权限点 | 说明 |
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
# 2026-10-19 K19 客户端账号中心
|
||||||
|
|
||||||
|
## 基线
|
||||||
|
|
||||||
|
- ReelShort `develop`: `7d68699`
|
||||||
|
- FruitServer `develop`: `5c93ba9`
|
||||||
|
- 只改 ReelShort;不改 FruitServer 业务代码、ReelShortWeb、specs、main。
|
||||||
|
|
||||||
|
## 范围
|
||||||
|
|
||||||
|
对接 `docs/api-phase1.md` §1.2 的六个个人中心接口:
|
||||||
|
|
||||||
|
| 方法 | 路径 | 客户端用途 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| GET | `/app/me` | 资料展示 |
|
||||||
|
| PUT | `/app/me` | 修改昵称、性别、生日 |
|
||||||
|
| GET | `/app/me/devices` | 只读登录设备列表 |
|
||||||
|
| GET | `/app/me/export` | 账号数据摘要与完整 JSON 复制 |
|
||||||
|
| POST | `/app/me/deactivate` | 申请注销并进入 15 天冷静期 |
|
||||||
|
| POST | `/app/me/deactivate/cancel` | 撤销待处理注销申请 |
|
||||||
|
|
||||||
|
## 接口口径
|
||||||
|
|
||||||
|
1. 资料响应仅使用:
|
||||||
|
`uid/nickname/avatarUrl/gender/countryCode/regionCode/language/timezone/currency/status/maskedTarget/createdAt/lastLoginAt/vipLevel/vipExpireAt`。
|
||||||
|
`vipLevel` 是整数;时间字段按 `LocalDateTime` 字符串解析。
|
||||||
|
2. 资料更新只发送本次变更字段:
|
||||||
|
`nickname/avatarUrl/gender/birthday/language/timezone/regionCode`。
|
||||||
|
本页只修改 `nickname/gender/birthday`;昵称 trim 后非空且不超过 30 字符,
|
||||||
|
性别取 `male/female/unknown`,生日格式 `yyyy-MM-dd`。
|
||||||
|
3. 设备数组只解析并展示
|
||||||
|
`deviceId/platform/deviceModel/firstSeenAt/lastSeenAt/status`;
|
||||||
|
`id/userId/deleted` 不展示、不打印。页面只读。
|
||||||
|
4. 导出按实际结构解析
|
||||||
|
`{profile, credentials, consents, devices}`,展示资料摘要、凭据、授权记录数和设备数;
|
||||||
|
“复制完整 JSON”只写系统剪贴板,不写本地文件。
|
||||||
|
5. 注销请求只发送 `reason`,不采集或上送密码;成功返回 `scheduledAt`。
|
||||||
|
成功后清本地会话,不调用 logout。撤销接口成功 `data=null`,失败原样透传后端文案。
|
||||||
|
6. 所有数值和 ID 使用 `jsonToId/jsonToInt`;错误由 `ApiException` 透传到逻辑层。
|
||||||
|
|
||||||
|
## 客户端改造
|
||||||
|
|
||||||
|
- `lib/core/data/remote/account_api.dart`
|
||||||
|
- `lib/core/data/models/account_profile.dart`
|
||||||
|
- `lib/core/data/models/account_device.dart`
|
||||||
|
- `lib/core/data/models/account_export.dart`
|
||||||
|
- `lib/core/data/repositories/account_repository.dart`
|
||||||
|
- `lib/pages/account/` 下四个页面及各自的 binding/logic
|
||||||
|
- `lib/pages/mine/mine_view.dart` 登录态新增“账号”卡
|
||||||
|
- `lib/core/data/services/auth_controller.dart` 新增 `applyProfile`
|
||||||
|
- `lib/app.dart` 注册 `AccountRepository` Provider
|
||||||
|
- `lib/l10n/app_{en,zh,id}.arb` 与生成文件
|
||||||
|
- 测试新增 `test/account/`、`test/support/fake_account_repository.dart`
|
||||||
|
|
||||||
|
## TDD 顺序
|
||||||
|
|
||||||
|
1. 先写 API/模型测试:六条路径、方法、请求体、字符串/数字 ID、缺字段;
|
||||||
|
运行定向测试确认红灯。
|
||||||
|
2. 实现 AccountApi、三个模型和 AccountRepository,定向测试转绿。
|
||||||
|
3. 先写 AuthController.applyProfile 测试:保留令牌、更新昵称/头像并持久化;
|
||||||
|
再实现。
|
||||||
|
4. 先写 profile/device/export/deactivate logic 测试:
|
||||||
|
资料保存回调登录态、注销成功清会话、撤销失败透传文案、导出复制内容;
|
||||||
|
再实现逻辑层。
|
||||||
|
5. 先写 widget 测试:我的页入口登录可见、资料回填与保存、设备空态、
|
||||||
|
注销二次确认、导出加载/失败/重试;再实现页面和入口。
|
||||||
|
6. 生成 l10n,跑全量门禁;最后一次全量测试与 APK 构建。
|
||||||
|
|
||||||
|
## 门禁
|
||||||
|
|
||||||
|
```text
|
||||||
|
dart analyze lib test
|
||||||
|
flutter test
|
||||||
|
flutter build apk --debug
|
||||||
|
```
|
||||||
|
|
||||||
|
Flutter 分支:`feature/flutter-k19-account`。
|
||||||
|
|
||||||
|
## 风险与待确认
|
||||||
|
|
||||||
|
- `GET /app/me` 不返回注销申请状态,UI 不猜测状态;撤销失败展示后端文案。
|
||||||
|
- 无设备下线接口,设备页只读;`TC-ACCOUNT-10` 的“单点下线”保留为缺口。
|
||||||
|
- 无头像上传接口,头像只展示;空值使用现有占位。
|
||||||
|
- 资料响应不含 `birthday`,也没有清空入口。本批生日只能设置,无法回填或清除;
|
||||||
|
不补后端字段,页面文案明确为本次设置。
|
||||||
|
- 注销成功后服务端立即吊销全部会话,本地同步清理;撤销入口在重新登录后仍可使用。
|
||||||
|
- 真机验证由用户执行,本批不提供开发机 curl 或设备侧结果作为证据。
|
||||||
@@ -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): 短剧保存时始终同步分集价格`
|
||||||
+72
-2345
File diff suppressed because it is too large.
Load diff
+20984
File diff suppressed because it is too large.
Load diff
+2
-2
@@ -35,8 +35,8 @@ public class CommentAdminController {
|
|||||||
|
|
||||||
private final CommentService commentService;
|
private final CommentService commentService;
|
||||||
|
|
||||||
/** 检索评论:默认按状态过滤,`status=pending` 即审核队列。 */
|
/** 检索评论:status 为空时返回全部状态,传 pending 即审核队列。 */
|
||||||
@Operation(summary = "评论检索(默认按状态过滤,待审队列)")
|
@Operation(summary = "评论检索(status 为空返回全部状态)")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@PreAuthorize("@ss.hasPermission('comment:list')")
|
@PreAuthorize("@ss.hasPermission('comment:list')")
|
||||||
public Result<PageResult<CommentRespVO>> page(CommentQueryReqVO req) {
|
public Result<PageResult<CommentRespVO>> page(CommentQueryReqVO req) {
|
||||||
|
|||||||
+25
-3
@@ -6,12 +6,14 @@ import com.fruitshorts.common.pojo.PageResult;
|
|||||||
import com.fruitshorts.common.pojo.Result;
|
import com.fruitshorts.common.pojo.Result;
|
||||||
import com.fruitshorts.content.dal.entity.DramaReviewRecord;
|
import com.fruitshorts.content.dal.entity.DramaReviewRecord;
|
||||||
import com.fruitshorts.content.service.DramaService;
|
import com.fruitshorts.content.service.DramaService;
|
||||||
|
import com.fruitshorts.content.service.EpisodeService;
|
||||||
import com.fruitshorts.content.vo.DramaPageReqVO;
|
import com.fruitshorts.content.vo.DramaPageReqVO;
|
||||||
import com.fruitshorts.content.vo.DramaRespVO;
|
import com.fruitshorts.content.vo.DramaRespVO;
|
||||||
import com.fruitshorts.content.vo.DramaSaveReqVO;
|
import com.fruitshorts.content.vo.DramaSaveReqVO;
|
||||||
import com.fruitshorts.content.vo.DramaStatusReqVO;
|
import com.fruitshorts.content.vo.DramaStatusReqVO;
|
||||||
import com.fruitshorts.framework.security.SecurityUtils;
|
|
||||||
import com.fruitshorts.framework.log.OperationLog;
|
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.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@@ -27,6 +29,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Tag(name = "后台-短剧管理")
|
@Tag(name = "后台-短剧管理")
|
||||||
@RestController
|
@RestController
|
||||||
@@ -35,19 +38,25 @@ import java.util.List;
|
|||||||
public class DramaController {
|
public class DramaController {
|
||||||
|
|
||||||
private final DramaService dramaService;
|
private final DramaService dramaService;
|
||||||
|
private final CommentService commentService;
|
||||||
|
private final EpisodeService episodeService;
|
||||||
|
|
||||||
@Operation(summary = "短剧分页查询")
|
@Operation(summary = "短剧分页查询")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@PreAuthorize("@ss.hasPermission('drama:list')")
|
@PreAuthorize("@ss.hasPermission('drama:list')")
|
||||||
public Result<PageResult<DramaRespVO>> page(DramaPageReqVO req) {
|
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 = "短剧详情")
|
@Operation(summary = "短剧详情")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
@PreAuthorize("@ss.hasPermission('drama:list')")
|
@PreAuthorize("@ss.hasPermission('drama:list')")
|
||||||
public Result<DramaRespVO> get(@PathVariable Long id) {
|
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 = "新建短剧")
|
@Operation(summary = "新建短剧")
|
||||||
@@ -133,4 +142,17 @@ public class DramaController {
|
|||||||
dramaService.changeStatus(id, action, req == null ? null : req.getReason(),
|
dramaService.changeStatus(id, action, req == null ? null : req.getReason(),
|
||||||
SecurityUtils.getUserId(), SecurityUtils.getUsername());
|
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));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+23
-4
@@ -2,12 +2,16 @@
|
|||||||
|
|
||||||
package com.fruitshorts.admin.controller;
|
package com.fruitshorts.admin.controller;
|
||||||
|
|
||||||
|
import com.fruitshorts.common.pojo.PageResult;
|
||||||
import com.fruitshorts.common.pojo.Result;
|
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.service.EpisodeService;
|
||||||
import com.fruitshorts.content.vo.EpisodeRespVO;
|
import com.fruitshorts.content.vo.EpisodeRespVO;
|
||||||
import com.fruitshorts.content.vo.EpisodeSaveReqVO;
|
import com.fruitshorts.content.vo.EpisodeSaveReqVO;
|
||||||
import com.fruitshorts.content.vo.EpisodeSortReqVO;
|
import com.fruitshorts.content.vo.EpisodeSortReqVO;
|
||||||
import com.fruitshorts.framework.log.OperationLog;
|
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.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@@ -24,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Tag(name = "后台-剧集管理")
|
@Tag(name = "后台-剧集管理")
|
||||||
@RestController
|
@RestController
|
||||||
@@ -32,13 +37,27 @@ import java.util.List;
|
|||||||
public class EpisodeController {
|
public class EpisodeController {
|
||||||
|
|
||||||
private final EpisodeService episodeService;
|
private final EpisodeService episodeService;
|
||||||
|
private final CommentService commentService;
|
||||||
|
private final DramaService dramaService;
|
||||||
|
|
||||||
@Operation(summary = "剧集列表")
|
@Operation(summary = "剧集列表(分页)")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("@ss.hasPermission('episode:list')")
|
@PreAuthorize("@ss.hasPermission('episode:list')")
|
||||||
public Result<List<EpisodeRespVO>> list(@RequestParam Long dramaId,
|
public Result<PageResult<EpisodeRespVO>> list(@RequestParam Long dramaId,
|
||||||
@RequestParam(required = false) String status) {
|
@RequestParam(required = false) String status,
|
||||||
return Result.ok(episodeService.listByDrama(dramaId, 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 = "新建剧集")
|
@Operation(summary = "新建剧集")
|
||||||
|
|||||||
+5
-3
@@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
package com.fruitshorts.admin.controller;
|
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.PageResult;
|
||||||
import com.fruitshorts.common.pojo.Result;
|
import com.fruitshorts.common.pojo.Result;
|
||||||
import com.fruitshorts.framework.log.OperationLog;
|
import com.fruitshorts.framework.log.OperationLog;
|
||||||
import com.fruitshorts.framework.security.SecurityUtils;
|
import com.fruitshorts.framework.security.SecurityUtils;
|
||||||
import com.fruitshorts.interaction.dal.entity.ContentReport;
|
|
||||||
import com.fruitshorts.interaction.service.ReportService;
|
import com.fruitshorts.interaction.service.ReportService;
|
||||||
import com.fruitshorts.interaction.vo.ReportHandleReqVO;
|
import com.fruitshorts.interaction.vo.ReportHandleReqVO;
|
||||||
import com.fruitshorts.interaction.vo.ReportQueryReqVO;
|
import com.fruitshorts.interaction.vo.ReportQueryReqVO;
|
||||||
@@ -28,13 +29,14 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ReportAdminController {
|
public class ReportAdminController {
|
||||||
|
|
||||||
|
private final ReportAdminService reportAdminService;
|
||||||
private final ReportService reportService;
|
private final ReportService reportService;
|
||||||
|
|
||||||
@Operation(summary = "举报工单分页查询")
|
@Operation(summary = "举报工单分页查询")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@PreAuthorize("@ss.hasPermission('report:list')")
|
@PreAuthorize("@ss.hasPermission('report:list')")
|
||||||
public Result<PageResult<ContentReport>> page(ReportQueryReqVO req) {
|
public Result<PageResult<AdminReportRespVO>> page(ReportQueryReqVO req) {
|
||||||
return Result.ok(reportService.page(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));
|
||||||
|
}
|
||||||
|
}
|
||||||
+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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+198
@@ -0,0 +1,198 @@
|
|||||||
|
// 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.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;
|
||||||
|
|
||||||
|
/** 按后台筛选条件分页查询观看记录。 */
|
||||||
|
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);
|
||||||
|
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())));
|
||||||
|
}
|
||||||
|
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) {
|
||||||
|
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());
|
||||||
|
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,33 @@
|
|||||||
|
// 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;
|
||||||
|
private LocalDateTime watchedAt;
|
||||||
|
}
|
||||||
+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:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.fruitshorts: debug
|
com.fruitshorts: debug
|
||||||
|
|
||||||
|
management:
|
||||||
|
endpoints:
|
||||||
|
web:
|
||||||
|
exposure:
|
||||||
|
include: prometheus,health
|
||||||
|
endpoint:
|
||||||
|
health:
|
||||||
|
show-details: always
|
||||||
|
metrics:
|
||||||
|
tags:
|
||||||
|
application: ${spring.application.name}
|
||||||
+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;
|
||||||
|
}
|
||||||
|
}
|
||||||
+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;
|
||||||
|
}
|
||||||
|
}
|
||||||
+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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
package com.fruitshorts.app.controller;
|
package com.fruitshorts.app.controller;
|
||||||
|
|
||||||
|
import com.fruitshorts.app.vo.GoogleLoginReqVO;
|
||||||
import com.fruitshorts.common.pojo.Result;
|
import com.fruitshorts.common.pojo.Result;
|
||||||
|
import com.fruitshorts.framework.redis.RateLimit;
|
||||||
import com.fruitshorts.framework.security.SecurityUtils;
|
import com.fruitshorts.framework.security.SecurityUtils;
|
||||||
import com.fruitshorts.framework.web.WebUtils;
|
import com.fruitshorts.framework.web.WebUtils;
|
||||||
import com.fruitshorts.user.service.AppAuthService;
|
import com.fruitshorts.user.service.AppAuthService;
|
||||||
@@ -35,6 +37,7 @@ public class AppAuthController {
|
|||||||
|
|
||||||
/** 发送验证码。频控在服务端,客户端不需要自己限流。 */
|
/** 发送验证码。频控在服务端,客户端不需要自己限流。 */
|
||||||
@Operation(summary = "发送验证码(频控在服务端)")
|
@Operation(summary = "发送验证码(频控在服务端)")
|
||||||
|
@RateLimit(limit = 20, windowSeconds = 60, key = "otp")
|
||||||
@PostMapping("/otp")
|
@PostMapping("/otp")
|
||||||
public Result<Void> sendOtp(@Valid @RequestBody OtpSendReqVO req, HttpServletRequest request) {
|
public Result<Void> sendOtp(@Valid @RequestBody OtpSendReqVO req, HttpServletRequest request) {
|
||||||
otpService.send(req, WebUtils.getClientIp(request));
|
otpService.send(req, WebUtils.getClientIp(request));
|
||||||
@@ -49,12 +52,19 @@ public class AppAuthController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "登录(验证码或密码)")
|
@Operation(summary = "登录(验证码或密码)")
|
||||||
|
@RateLimit(limit = 10, windowSeconds = 60, key = "login")
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public Result<TokenRespVO> login(@Valid @RequestBody LoginReqVO req,
|
public Result<TokenRespVO> login(@Valid @RequestBody LoginReqVO req,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
return Result.ok(authService.login(req, WebUtils.getClientIp(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 立即失效)")
|
@Operation(summary = "刷新令牌(旧 refresh token 立即失效)")
|
||||||
@PostMapping("/refresh")
|
@PostMapping("/refresh")
|
||||||
public Result<TokenRespVO> refresh(@Valid @RequestBody RefreshReqVO req) {
|
public Result<TokenRespVO> refresh(@Valid @RequestBody RefreshReqVO req) {
|
||||||
|
|||||||
+13
@@ -5,12 +5,15 @@ package com.fruitshorts.app.controller;
|
|||||||
import com.fruitshorts.app.service.AppCatalogService;
|
import com.fruitshorts.app.service.AppCatalogService;
|
||||||
import com.fruitshorts.app.vo.AppCategoryVO;
|
import com.fruitshorts.app.vo.AppCategoryVO;
|
||||||
import com.fruitshorts.app.vo.AppFeedVO;
|
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 com.fruitshorts.common.pojo.Result;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -38,6 +41,16 @@ public class AppCatalogController {
|
|||||||
return Result.ok(appCatalogService.discoverFeed());
|
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 = "分类列表")
|
@Operation(summary = "分类列表")
|
||||||
@GetMapping("/categories")
|
@GetMapping("/categories")
|
||||||
public Result<List<AppCategoryVO>> categories() {
|
public Result<List<AppCategoryVO>> categories() {
|
||||||
|
|||||||
+20
@@ -3,6 +3,8 @@
|
|||||||
package com.fruitshorts.app.controller;
|
package com.fruitshorts.app.controller;
|
||||||
|
|
||||||
import com.fruitshorts.common.pojo.CursorResult;
|
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.common.pojo.Result;
|
||||||
import com.fruitshorts.framework.security.SecurityUtils;
|
import com.fruitshorts.framework.security.SecurityUtils;
|
||||||
import com.fruitshorts.framework.web.WebUtils;
|
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.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
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 {
|
public class AppCommentController {
|
||||||
|
|
||||||
private final CommentService commentService;
|
private final CommentService commentService;
|
||||||
|
private final EpisodeService episodeService;
|
||||||
|
|
||||||
@Operation(summary = "发布评论")
|
@Operation(summary = "发布评论")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@@ -63,6 +68,21 @@ public class AppCommentController {
|
|||||||
return Result.ok(commentService.page(SecurityUtils.getUserIdOrNull(), query));
|
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 = "删除自己的评论")
|
@Operation(summary = "删除自己的评论")
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public Result<Void> delete(@PathVariable Long 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.dal.entity.Orders;
|
||||||
import com.fruitshorts.commerce.service.OrderService;
|
import com.fruitshorts.commerce.service.OrderService;
|
||||||
|
import com.fruitshorts.commerce.service.ProductService;
|
||||||
import com.fruitshorts.commerce.service.UnlockService;
|
import com.fruitshorts.commerce.service.UnlockService;
|
||||||
import com.fruitshorts.commerce.service.WalletService;
|
import com.fruitshorts.commerce.service.WalletService;
|
||||||
|
import com.fruitshorts.commerce.vo.ProductRespVO;
|
||||||
import com.fruitshorts.common.pojo.Result;
|
import com.fruitshorts.common.pojo.Result;
|
||||||
import com.fruitshorts.framework.security.SecurityUtils;
|
import com.fruitshorts.framework.security.SecurityUtils;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
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.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@@ -37,6 +40,7 @@ public class AppCommerceController {
|
|||||||
private final WalletService walletService;
|
private final WalletService walletService;
|
||||||
private final UnlockService unlockService;
|
private final UnlockService unlockService;
|
||||||
private final OrderService orderService;
|
private final OrderService orderService;
|
||||||
|
private final ProductService productService;
|
||||||
|
|
||||||
/** 我的钱包:余额 + 最近流水,客户端一处渲染。 */
|
/** 我的钱包:余额 + 最近流水,客户端一处渲染。 */
|
||||||
@Operation(summary = "我的钱包(余额 + 最近流水)")
|
@Operation(summary = "我的钱包(余额 + 最近流水)")
|
||||||
@@ -49,6 +53,22 @@ public class AppCommerceController {
|
|||||||
return Result.ok(data);
|
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 = "金币解锁分集(幂等,重复点击不重复扣币)")
|
@Operation(summary = "金币解锁分集(幂等,重复点击不重复扣币)")
|
||||||
@PostMapping("/episodes/{episodeId}/unlock")
|
@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.service.AppCatalogService;
|
||||||
import com.fruitshorts.app.vo.AppDramaDetailVO;
|
import com.fruitshorts.app.vo.AppDramaDetailVO;
|
||||||
import com.fruitshorts.common.pojo.Result;
|
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.security.SecurityUtils;
|
||||||
import com.fruitshorts.framework.web.WebUtils;
|
import com.fruitshorts.framework.web.WebUtils;
|
||||||
|
import com.fruitshorts.interaction.service.CommentService;
|
||||||
import com.fruitshorts.playback.service.PlaybackService;
|
import com.fruitshorts.playback.service.PlaybackService;
|
||||||
import com.fruitshorts.playback.vo.PlayRespVO;
|
import com.fruitshorts.playback.vo.PlayRespVO;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@@ -26,6 +32,8 @@ public class AppDramaController {
|
|||||||
|
|
||||||
private final AppCatalogService appCatalogService;
|
private final AppCatalogService appCatalogService;
|
||||||
private final PlaybackService playbackService;
|
private final PlaybackService playbackService;
|
||||||
|
private final EpisodeService episodeService;
|
||||||
|
private final CommentService commentService;
|
||||||
|
|
||||||
/** 详情:包含剧集列表,客户端进详情页一次请求即可渲染 */
|
/** 详情:包含剧集列表,客户端进详情页一次请求即可渲染 */
|
||||||
@Operation(summary = "短剧详情(含剧集列表,进详情页一次请求即可渲染)")
|
@Operation(summary = "短剧详情(含剧集列表,进详情页一次请求即可渲染)")
|
||||||
@@ -41,10 +49,14 @@ public class AppDramaController {
|
|||||||
@Operation(summary = "播放票据:判定权益后签发短时效播放地址")
|
@Operation(summary = "播放票据:判定权益后签发短时效播放地址")
|
||||||
@GetMapping("/episodes/{id}/play")
|
@GetMapping("/episodes/{id}/play")
|
||||||
public Result<PlayRespVO> play(@PathVariable Long id, HttpServletRequest request) {
|
public Result<PlayRespVO> play(@PathVariable Long id, HttpServletRequest request) {
|
||||||
return Result.ok(playbackService.play(
|
PlayRespVO vo = playbackService.play(
|
||||||
SecurityUtils.getUserIdOrNull(),
|
SecurityUtils.getUserIdOrNull(),
|
||||||
id,
|
id,
|
||||||
request.getHeader("X-Device-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();
|
||||||
|
}
|
||||||
|
}
|
||||||
+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));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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> {
|
||||||
|
}
|
||||||
+52
-7
@@ -9,6 +9,7 @@ import com.fruitshorts.app.vo.AppDramaDetailVO;
|
|||||||
import com.fruitshorts.app.vo.AppEpisodeVO;
|
import com.fruitshorts.app.vo.AppEpisodeVO;
|
||||||
import com.fruitshorts.app.vo.AppFeedVO;
|
import com.fruitshorts.app.vo.AppFeedVO;
|
||||||
import com.fruitshorts.app.vo.AppSectionVO;
|
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.ContentBanner;
|
||||||
import com.fruitshorts.content.dal.entity.Drama;
|
import com.fruitshorts.content.dal.entity.Drama;
|
||||||
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
||||||
@@ -17,6 +18,7 @@ import com.fruitshorts.content.service.BannerService;
|
|||||||
import com.fruitshorts.content.service.DramaCategoryService;
|
import com.fruitshorts.content.service.DramaCategoryService;
|
||||||
import com.fruitshorts.content.service.DramaService;
|
import com.fruitshorts.content.service.DramaService;
|
||||||
import com.fruitshorts.content.service.EpisodeService;
|
import com.fruitshorts.content.service.EpisodeService;
|
||||||
|
import com.fruitshorts.interaction.service.CommentService;
|
||||||
import com.fruitshorts.media.service.PlaybackSigner;
|
import com.fruitshorts.media.service.PlaybackSigner;
|
||||||
import com.fruitshorts.content.vo.DramaCategoryRespVO;
|
import com.fruitshorts.content.vo.DramaCategoryRespVO;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -26,6 +28,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* C 端目录聚合:把内容域的只读视图组装成客户端一次请求就能渲染的结构。
|
* C 端目录聚合:把内容域的只读视图组装成客户端一次请求就能渲染的结构。
|
||||||
@@ -38,12 +41,15 @@ public class AppCatalogService {
|
|||||||
private static final int HOME_SECTION_SIZE = 6;
|
private static final int HOME_SECTION_SIZE = 6;
|
||||||
private static final int DISCOVER_SECTION_SIZE = 10;
|
private static final int DISCOVER_SECTION_SIZE = 10;
|
||||||
private static final int MAX_CATEGORY_SECTIONS = 4;
|
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 DramaService dramaService;
|
||||||
private final EpisodeService episodeService;
|
private final EpisodeService episodeService;
|
||||||
private final BannerService bannerService;
|
private final BannerService bannerService;
|
||||||
private final DramaCategoryService dramaCategoryService;
|
private final DramaCategoryService dramaCategoryService;
|
||||||
private final PlaybackSigner playbackSigner;
|
private final PlaybackSigner playbackSigner;
|
||||||
|
private final CommentService commentService;
|
||||||
|
|
||||||
public AppFeedVO homeFeed() {
|
public AppFeedVO homeFeed() {
|
||||||
Map<Long, String> categoryNames = categoryNameMap();
|
Map<Long, String> categoryNames = categoryNameMap();
|
||||||
@@ -68,6 +74,26 @@ public class AppCatalogService {
|
|||||||
.toList();
|
.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 +108,8 @@ public class AppCatalogService {
|
|||||||
public AppDramaDetailVO dramaDetail(Long dramaId) {
|
public AppDramaDetailVO dramaDetail(Long dramaId) {
|
||||||
Drama drama = dramaService.getPublished(dramaId);
|
Drama drama = dramaService.getPublished(dramaId);
|
||||||
List<DramaEpisode> episodes = episodeService.listPublishedByDrama(dramaId);
|
List<DramaEpisode> episodes = episodeService.listPublishedByDrama(dramaId);
|
||||||
|
Map<Long, Long> episodeCommentCounts = commentService.countByEpisodes(
|
||||||
|
episodes.stream().map(DramaEpisode::getId).sorted().toList());
|
||||||
String categoryName = categoryNameMap().getOrDefault(drama.getCategoryId(), "");
|
String categoryName = categoryNameMap().getOrDefault(drama.getCategoryId(), "");
|
||||||
|
|
||||||
AppDramaDetailVO detail = new AppDramaDetailVO();
|
AppDramaDetailVO detail = new AppDramaDetailVO();
|
||||||
@@ -96,7 +124,12 @@ public class AppCatalogService {
|
|||||||
detail.setUnlockCoin(drama.getUnlockCoin());
|
detail.setUnlockCoin(drama.getUnlockCoin());
|
||||||
detail.setIsHot(drama.getIsHot() != null && drama.getIsHot() == 1);
|
detail.setIsHot(drama.getIsHot() != null && drama.getIsHot() == 1);
|
||||||
detail.setViewCount(drama.getViewCount());
|
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))
|
||||||
|
.toList());
|
||||||
return detail;
|
return detail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,15 +172,18 @@ public class AppCatalogService {
|
|||||||
|
|
||||||
/** 整屏卡片共用一次剧集查询,取每部剧的首个可播免费集作为预览。 */
|
/** 整屏卡片共用一次剧集查询,取每部剧的首个可播免费集作为预览。 */
|
||||||
private List<AppDramaCardVO> cards(List<Drama> dramas, Map<Long, String> categoryNames) {
|
private List<AppDramaCardVO> cards(List<Drama> dramas, Map<Long, String> categoryNames) {
|
||||||
Map<Long, DramaEpisode> previews = episodeService.firstPlayableByDramas(
|
List<Long> ids = dramas.stream().map(Drama::getId).toList();
|
||||||
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());
|
||||||
return dramas.stream()
|
return dramas.stream()
|
||||||
.map(drama -> toCard(drama, categoryNames, previews.get(drama.getId())))
|
.map(drama -> toCard(
|
||||||
|
drama, categoryNames, previews.get(drama.getId()), commentCounts))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private AppDramaCardVO toCard(Drama drama, Map<Long, String> categoryNames,
|
private AppDramaCardVO toCard(Drama drama, Map<Long, String> categoryNames,
|
||||||
DramaEpisode preview) {
|
DramaEpisode preview, Map<Long, Long> commentCounts) {
|
||||||
AppDramaCardVO card = new AppDramaCardVO();
|
AppDramaCardVO card = new AppDramaCardVO();
|
||||||
card.setId(drama.getId());
|
card.setId(drama.getId());
|
||||||
card.setTitle(drama.getTitle());
|
card.setTitle(drama.getTitle());
|
||||||
@@ -158,11 +194,18 @@ public class AppCatalogService {
|
|||||||
card.setTotalEpisodes(drama.getTotalEpisodes());
|
card.setTotalEpisodes(drama.getTotalEpisodes());
|
||||||
card.setIsHot(drama.getIsHot() != null && drama.getIsHot() == 1);
|
card.setIsHot(drama.getIsHot() != null && drama.getIsHot() == 1);
|
||||||
card.setViewCount(drama.getViewCount());
|
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));
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
|
|
||||||
private AppEpisodeVO toEpisode(DramaEpisode episode) {
|
private AppEpisodeVO toEpisode(DramaEpisode episode, Map<Long, Long> commentCounts) {
|
||||||
AppEpisodeVO vo = new AppEpisodeVO();
|
AppEpisodeVO vo = new AppEpisodeVO();
|
||||||
vo.setId(episode.getId());
|
vo.setId(episode.getId());
|
||||||
vo.setNumber(episode.getEpNo());
|
vo.setNumber(episode.getEpNo());
|
||||||
@@ -174,6 +217,8 @@ public class AppCatalogService {
|
|||||||
vo.setIsFree(free);
|
vo.setIsFree(free);
|
||||||
vo.setLocked(!free);
|
vo.setLocked(!free);
|
||||||
vo.setUnlockCoin(episode.getUnlockCoin());
|
vo.setUnlockCoin(episode.getUnlockCoin());
|
||||||
|
vo.setLikeCount(episode.getLikeCount() == null ? 0L : episode.getLikeCount());
|
||||||
|
vo.setCommentCount(commentCounts.getOrDefault(episode.getId(), 0L));
|
||||||
if (free) {
|
if (free) {
|
||||||
// 播放地址统一在这里签名:客户端拿不到可长期复用的裸地址
|
// 播放地址统一在这里签名:客户端拿不到可长期复用的裸地址
|
||||||
vo.setPlayUrl(playbackSigner.sign(playableSource(episode)));
|
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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
package com.fruitshorts.app.vo;
|
package com.fruitshorts.app.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/** 列表卡片,用于首页/发现页/分类分区 */
|
/** 列表卡片,用于首页/发现页/分类分区 */
|
||||||
@@ -17,6 +18,17 @@ public class AppDramaCardVO {
|
|||||||
private Integer totalEpisodes;
|
private Integer totalEpisodes;
|
||||||
private Boolean isHot;
|
private Boolean isHot;
|
||||||
private Long viewCount;
|
private Long viewCount;
|
||||||
|
/** 短剧累计点赞数:drama.like_count */
|
||||||
|
private Long likeCount;
|
||||||
|
/** 短剧累计收藏数:drama.favorite_count */
|
||||||
|
private Long favoriteCount;
|
||||||
|
/** 该剧未删除评论数:content_comment 按 drama_id 统计 */
|
||||||
|
private Long commentCount;
|
||||||
|
/** 语种,供客户端按语言筛选(如 zh-CN / id)。 */
|
||||||
|
@Schema(description = "短剧语种,如 zh-CN / id")
|
||||||
|
private String language;
|
||||||
|
/** 内容类型:ANIME=漫剧,LIVE=真人剧 */
|
||||||
|
private String dramaType;
|
||||||
/**
|
/**
|
||||||
* 首个可播免费集。首页竖屏播放需要在列表阶段就能起播,
|
* 首个可播免费集。首页竖屏播放需要在列表阶段就能起播,
|
||||||
* 带上这一集可以省掉「点开→请求详情→再请求播放地址」的往返。
|
* 带上这一集可以省掉「点开→请求详情→再请求播放地址」的往返。
|
||||||
|
|||||||
@@ -20,5 +20,11 @@ public class AppDramaDetailVO {
|
|||||||
private Integer unlockCoin;
|
private Integer unlockCoin;
|
||||||
private Boolean isHot;
|
private Boolean isHot;
|
||||||
private Long viewCount;
|
private Long viewCount;
|
||||||
|
/** 短剧累计点赞数:drama.like_count */
|
||||||
|
private Long likeCount;
|
||||||
|
/** 短剧累计收藏数:drama.favorite_count */
|
||||||
|
private Long favoriteCount;
|
||||||
|
/** 该剧未删除评论数:content_comment 按 drama_id 统计 */
|
||||||
|
private Long commentCount;
|
||||||
private List<AppEpisodeVO> episodes;
|
private List<AppEpisodeVO> episodes;
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,8 @@ public class AppEpisodeVO {
|
|||||||
/** true 表示需要解锁后才能播放 */
|
/** true 表示需要解锁后才能播放 */
|
||||||
private Boolean locked;
|
private Boolean locked;
|
||||||
private Integer unlockCoin;
|
private Integer unlockCoin;
|
||||||
|
private Long likeCount;
|
||||||
|
private Long commentCount;
|
||||||
/**
|
/**
|
||||||
* 可播放时的地址;锁定或不含片源时为空。
|
* 可播放时的地址;锁定或不含片源时为空。
|
||||||
* 详情页拿到就能直接播,不必按集再请求一次播放票据。
|
* 详情页拿到就能直接播,不必按集再请求一次播放票据。
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
package com.fruitshorts.app.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/** 埋点事件批量上报请求。 */
|
||||||
|
@Data
|
||||||
|
public class AppEventReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "设备ID")
|
||||||
|
private String deviceId;
|
||||||
|
|
||||||
|
@Schema(description = "会话ID")
|
||||||
|
private String sessionId;
|
||||||
|
|
||||||
|
@Schema(description = "事件列表")
|
||||||
|
@NotEmpty(message = "事件列表不能为空")
|
||||||
|
@Size(max = 50, message = "单次最多上报 50 条事件")
|
||||||
|
@Valid
|
||||||
|
private List<EventItem> events;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class EventItem {
|
||||||
|
|
||||||
|
@Schema(description = "事件名,如 playback_start/playback_end/pay_success")
|
||||||
|
@NotBlank(message = "事件名不能为空")
|
||||||
|
private String eventName;
|
||||||
|
|
||||||
|
@Schema(description = "事件发生时间,缺省用服务端接收时间")
|
||||||
|
private LocalDateTime eventTime;
|
||||||
|
|
||||||
|
@Schema(description = "页面/场景标识")
|
||||||
|
private String page;
|
||||||
|
|
||||||
|
@Schema(description = "事件属性(key-value)")
|
||||||
|
private Map<String, Object> properties;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
package com.fruitshorts.app.vo;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/** Google 登录请求。 */
|
||||||
|
@Data
|
||||||
|
public class GoogleLoginReqVO {
|
||||||
|
|
||||||
|
@NotBlank(message = "缺少 Google idToken")
|
||||||
|
private String idToken;
|
||||||
|
}
|
||||||
@@ -18,6 +18,10 @@ spring:
|
|||||||
jackson:
|
jackson:
|
||||||
date-format: yyyy-MM-dd HH:mm:ss
|
date-format: yyyy-MM-dd HH:mm:ss
|
||||||
time-zone: Asia/Shanghai
|
time-zone: Asia/Shanghai
|
||||||
|
data:
|
||||||
|
redis:
|
||||||
|
host: ${REDIS_HOST:127.0.0.1}
|
||||||
|
port: ${REDIS_PORT:6379}
|
||||||
|
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
configuration:
|
configuration:
|
||||||
@@ -93,3 +97,15 @@ fruitshorts:
|
|||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.fruitshorts: info
|
com.fruitshorts: info
|
||||||
|
|
||||||
|
management:
|
||||||
|
endpoints:
|
||||||
|
web:
|
||||||
|
exposure:
|
||||||
|
include: prometheus,health
|
||||||
|
endpoint:
|
||||||
|
health:
|
||||||
|
show-details: always
|
||||||
|
metrics:
|
||||||
|
tags:
|
||||||
|
application: ${spring.application.name}
|
||||||
+53
-4
@@ -5,11 +5,16 @@ import com.fruitshorts.app.service.AppCatalogService;
|
|||||||
import com.fruitshorts.app.support.ControllerContractSupport;
|
import com.fruitshorts.app.support.ControllerContractSupport;
|
||||||
import com.fruitshorts.app.vo.AppBannerVO;
|
import com.fruitshorts.app.vo.AppBannerVO;
|
||||||
import com.fruitshorts.app.vo.AppCategoryVO;
|
import com.fruitshorts.app.vo.AppCategoryVO;
|
||||||
|
import com.fruitshorts.app.vo.AppDramaCardVO;
|
||||||
import com.fruitshorts.app.vo.AppDramaDetailVO;
|
import com.fruitshorts.app.vo.AppDramaDetailVO;
|
||||||
import com.fruitshorts.app.vo.AppFeedVO;
|
import com.fruitshorts.app.vo.AppFeedVO;
|
||||||
|
import com.fruitshorts.app.vo.AppSectionVO;
|
||||||
|
import com.fruitshorts.common.pojo.CursorResult;
|
||||||
|
import com.fruitshorts.content.service.EpisodeService;
|
||||||
import com.fruitshorts.common.exception.ErrorCode;
|
import com.fruitshorts.common.exception.ErrorCode;
|
||||||
import com.fruitshorts.common.exception.ServiceException;
|
import com.fruitshorts.common.exception.ServiceException;
|
||||||
import com.fruitshorts.playback.service.PlaybackService;
|
import com.fruitshorts.playback.service.PlaybackService;
|
||||||
|
import com.fruitshorts.interaction.service.CommentService;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
@@ -40,7 +45,8 @@ class AppCatalogControllerContractTest {
|
|||||||
catalogService = mock(AppCatalogService.class);
|
catalogService = mock(AppCatalogService.class);
|
||||||
catalogMvc = ControllerContractSupport.mockMvcOf(new AppCatalogController(catalogService));
|
catalogMvc = ControllerContractSupport.mockMvcOf(new AppCatalogController(catalogService));
|
||||||
dramaMvc = ControllerContractSupport.mockMvcOf(
|
dramaMvc = ControllerContractSupport.mockMvcOf(
|
||||||
new AppDramaController(catalogService, mock(PlaybackService.class)));
|
new AppDramaController(catalogService, mock(PlaybackService.class),
|
||||||
|
mock(EpisodeService.class), mock(CommentService.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -50,7 +56,15 @@ class AppCatalogControllerContractTest {
|
|||||||
banner.setImageUrl("/files/banner/9.png");
|
banner.setImageUrl("/files/banner/9.png");
|
||||||
banner.setLinkType("DRAMA");
|
banner.setLinkType("DRAMA");
|
||||||
banner.setLinkValue("12");
|
banner.setLinkValue("12");
|
||||||
AppFeedVO feed = new AppFeedVO(List.of(banner), List.of());
|
AppDramaCardVO card = new AppDramaCardVO();
|
||||||
|
card.setId(12L);
|
||||||
|
card.setTitle("命运的相遇");
|
||||||
|
card.setViewCount(12400L);
|
||||||
|
card.setLikeCount(3200L);
|
||||||
|
card.setFavoriteCount(1800L);
|
||||||
|
card.setCommentCount(96L);
|
||||||
|
AppSectionVO section = new AppSectionVO("hot", "热门推荐", List.of(card));
|
||||||
|
AppFeedVO feed = new AppFeedVO(List.of(banner), List.of(section));
|
||||||
given(catalogService.homeFeed()).willReturn(feed);
|
given(catalogService.homeFeed()).willReturn(feed);
|
||||||
|
|
||||||
catalogMvc.perform(get("/app/home/feed"))
|
catalogMvc.perform(get("/app/home/feed"))
|
||||||
@@ -58,7 +72,11 @@ class AppCatalogControllerContractTest {
|
|||||||
.andExpect(jsonPath("$.code").value(0))
|
.andExpect(jsonPath("$.code").value(0))
|
||||||
.andExpect(jsonPath("$.data.banners[0].id").value(9))
|
.andExpect(jsonPath("$.data.banners[0].id").value(9))
|
||||||
.andExpect(jsonPath("$.data.banners[0].imageUrl").value("/files/banner/9.png"))
|
.andExpect(jsonPath("$.data.banners[0].imageUrl").value("/files/banner/9.png"))
|
||||||
.andExpect(jsonPath("$.data.banners[0].linkType").value("DRAMA"));
|
.andExpect(jsonPath("$.data.banners[0].linkType").value("DRAMA"))
|
||||||
|
.andExpect(jsonPath("$.data.sections[0].dramas[0].viewCount").value("12400"))
|
||||||
|
.andExpect(jsonPath("$.data.sections[0].dramas[0].likeCount").value("3200"))
|
||||||
|
.andExpect(jsonPath("$.data.sections[0].dramas[0].favoriteCount").value("1800"))
|
||||||
|
.andExpect(jsonPath("$.data.sections[0].dramas[0].commentCount").value("96"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -72,6 +90,29 @@ class AppCatalogControllerContractTest {
|
|||||||
.andExpect(jsonPath("$.data.sections").isArray());
|
.andExpect(jsonPath("$.data.sections").isArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_return_typed_cursor_feed() throws Exception {
|
||||||
|
AppDramaCardVO card = new AppDramaCardVO();
|
||||||
|
card.setId(12L);
|
||||||
|
card.setTitle("漫剧卡片");
|
||||||
|
card.setDramaType("ANIME");
|
||||||
|
given(catalogService.feed("ANIME", 7L, null, 20))
|
||||||
|
.willReturn(new CursorResult<>(List.of(card), 12L, true));
|
||||||
|
|
||||||
|
catalogMvc.perform(get("/app/feed")
|
||||||
|
.param("types", "ANIME")
|
||||||
|
.param("categoryId", "7")
|
||||||
|
.param("size", "20"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(0))
|
||||||
|
.andExpect(jsonPath("$.data.list[0].id").value("12"))
|
||||||
|
.andExpect(jsonPath("$.data.list[0].dramaType").value("ANIME"))
|
||||||
|
.andExpect(jsonPath("$.data.nextCursor").value("12"))
|
||||||
|
.andExpect(jsonPath("$.data.hasMore").value(true));
|
||||||
|
|
||||||
|
verify(catalogService).feed("ANIME", 7L, null, 20);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_return_category_list_when_categories_are_requested() throws Exception {
|
void should_return_category_list_when_categories_are_requested() throws Exception {
|
||||||
AppCategoryVO category = new AppCategoryVO(3L, "都市");
|
AppCategoryVO category = new AppCategoryVO(3L, "都市");
|
||||||
@@ -89,6 +130,10 @@ class AppCatalogControllerContractTest {
|
|||||||
AppDramaDetailVO detail = new AppDramaDetailVO();
|
AppDramaDetailVO detail = new AppDramaDetailVO();
|
||||||
detail.setId(42L);
|
detail.setId(42L);
|
||||||
detail.setTitle("命运的相遇");
|
detail.setTitle("命运的相遇");
|
||||||
|
detail.setViewCount(12400L);
|
||||||
|
detail.setLikeCount(3200L);
|
||||||
|
detail.setFavoriteCount(1800L);
|
||||||
|
detail.setCommentCount(96L);
|
||||||
detail.setEpisodes(List.of());
|
detail.setEpisodes(List.of());
|
||||||
given(catalogService.dramaDetail(42L)).willReturn(detail);
|
given(catalogService.dramaDetail(42L)).willReturn(detail);
|
||||||
|
|
||||||
@@ -97,7 +142,11 @@ class AppCatalogControllerContractTest {
|
|||||||
.andExpect(jsonPath("$.code").value(0))
|
.andExpect(jsonPath("$.code").value(0))
|
||||||
.andExpect(jsonPath("$.data.id").value("42"))
|
.andExpect(jsonPath("$.data.id").value("42"))
|
||||||
.andExpect(jsonPath("$.data.id").isString())
|
.andExpect(jsonPath("$.data.id").isString())
|
||||||
.andExpect(jsonPath("$.data.title").value("命运的相遇"));
|
.andExpect(jsonPath("$.data.title").value("命运的相遇"))
|
||||||
|
.andExpect(jsonPath("$.data.viewCount").value("12400"))
|
||||||
|
.andExpect(jsonPath("$.data.likeCount").value("3200"))
|
||||||
|
.andExpect(jsonPath("$.data.favoriteCount").value("1800"))
|
||||||
|
.andExpect(jsonPath("$.data.commentCount").value("96"));
|
||||||
|
|
||||||
verify(catalogService).dramaDetail(42L);
|
verify(catalogService).dramaDetail(42L);
|
||||||
}
|
}
|
||||||
|
|||||||
+67
@@ -0,0 +1,67 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
package com.fruitshorts.app.controller;
|
||||||
|
|
||||||
|
import com.fruitshorts.app.support.ControllerContractSupport;
|
||||||
|
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
||||||
|
import com.fruitshorts.content.service.EpisodeService;
|
||||||
|
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.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 AppCommentControllerContractTest {
|
||||||
|
|
||||||
|
private CommentService commentService;
|
||||||
|
private EpisodeService episodeService;
|
||||||
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
commentService = mock(CommentService.class);
|
||||||
|
episodeService = mock(EpisodeService.class);
|
||||||
|
mockMvc = ControllerContractSupport.mockMvcOf(
|
||||||
|
new AppCommentController(commentService, episodeService));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_return_comment_count_as_string_when_requested() throws Exception {
|
||||||
|
given(commentService.countByDrama(7L)).willReturn(9L);
|
||||||
|
|
||||||
|
mockMvc.perform(get("/app/comments/count").param("dramaId", "7"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(0))
|
||||||
|
.andExpect(jsonPath("$.data").value("9"))
|
||||||
|
.andExpect(jsonPath("$.data").isString());
|
||||||
|
|
||||||
|
verify(commentService).countByDrama(7L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_count_comments_by_episode_when_episode_id_is_given() throws Exception {
|
||||||
|
DramaEpisode episode = new DramaEpisode();
|
||||||
|
episode.setId(11L);
|
||||||
|
episode.setDramaId(7L);
|
||||||
|
given(episodeService.getPublished(11L)).willReturn(episode);
|
||||||
|
given(commentService.countByEpisodes(List.of(11L))).willReturn(Map.of(11L, 4L));
|
||||||
|
|
||||||
|
mockMvc.perform(get("/app/comments/count")
|
||||||
|
.param("dramaId", "7")
|
||||||
|
.param("episodeId", "11"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.data").value("4"));
|
||||||
|
|
||||||
|
verify(commentService).countByEpisodes(List.of(11L));
|
||||||
|
}
|
||||||
|
}
|
||||||
+135
@@ -0,0 +1,135 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
package com.fruitshorts.app.controller;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fruitshorts.app.service.AppCatalogService;
|
||||||
|
import com.fruitshorts.common.pojo.CursorResult;
|
||||||
|
import com.fruitshorts.content.service.EpisodeService;
|
||||||
|
import com.fruitshorts.framework.log.AccessDeniedRecorder;
|
||||||
|
import com.fruitshorts.framework.security.JwtAuthenticationFilter;
|
||||||
|
import com.fruitshorts.framework.security.JwtTokenProvider;
|
||||||
|
import com.fruitshorts.framework.security.RestAuthEntryPoint;
|
||||||
|
import com.fruitshorts.framework.security.SecurityConfig;
|
||||||
|
import com.fruitshorts.interaction.service.CommentService;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
|
import org.springframework.security.web.FilterChainProxy;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
|
import org.springframework.test.context.web.WebAppConfiguration;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||||
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/** 客户端公开只读接口的安全链契约:匿名请求必须直接进入控制器。 */
|
||||||
|
@ExtendWith(SpringExtension.class)
|
||||||
|
@WebAppConfiguration
|
||||||
|
@ContextConfiguration(classes = AppCommentCountAnonymousSecurityTest.TestConfig.class)
|
||||||
|
class AppCommentCountAnonymousSecurityTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CommentService commentService;
|
||||||
|
@Autowired
|
||||||
|
private AppCatalogService catalogService;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
given(commentService.countByDrama(7L)).willReturn(9L);
|
||||||
|
given(catalogService.feed("ANIME", null, null, 20))
|
||||||
|
.willReturn(new CursorResult<>(List.of(), null, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_allow_anonymous_count_request_through_security_chain() throws Exception {
|
||||||
|
mockMvc.perform(get("/app/comments/count").param("dramaId", "7"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(0))
|
||||||
|
.andExpect(jsonPath("$.data").value(9));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_allow_anonymous_typed_feed_request_through_security_chain() throws Exception {
|
||||||
|
mockMvc.perform(get("/app/feed")
|
||||||
|
.param("types", "ANIME")
|
||||||
|
.param("size", "20"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(0))
|
||||||
|
.andExpect(jsonPath("$.data.list").isArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableWebMvc
|
||||||
|
@EnableWebSecurity
|
||||||
|
@Import(SecurityConfig.class)
|
||||||
|
static class TestConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
CommentService commentService() {
|
||||||
|
return mock(CommentService.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
AppCommentController appCommentController(CommentService commentService) {
|
||||||
|
return new AppCommentController(commentService, mock(EpisodeService.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
AppCatalogService appCatalogService() {
|
||||||
|
return mock(AppCatalogService.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
AppCatalogController appCatalogController(AppCatalogService appCatalogService) {
|
||||||
|
return new AppCatalogController(appCatalogService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
JwtAuthenticationFilter jwtAuthenticationFilter() {
|
||||||
|
return new JwtAuthenticationFilter(
|
||||||
|
mock(JwtTokenProvider.class),
|
||||||
|
mock(ObjectProvider.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
RestAuthEntryPoint restAuthEntryPoint(ObjectMapper objectMapper) {
|
||||||
|
return new RestAuthEntryPoint(
|
||||||
|
objectMapper,
|
||||||
|
new AccessDeniedRecorder(mock(ObjectProvider.class)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
ObjectMapper objectMapper() {
|
||||||
|
return new ObjectMapper();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
MockMvc mockMvc(WebApplicationContext context) {
|
||||||
|
FilterChainProxy securityFilter =
|
||||||
|
context.getBean("springSecurityFilterChain", FilterChainProxy.class);
|
||||||
|
return MockMvcBuilders.webAppContextSetup(context)
|
||||||
|
.addFilters(securityFilter)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-2
@@ -69,7 +69,8 @@ class AppOrdersVerifyContractTest {
|
|||||||
new ProductService(productMapper), storeReceiptMapper, verifier,
|
new ProductService(productMapper), storeReceiptMapper, verifier,
|
||||||
mock(WalletService.class), mock(EntitlementService.class));
|
mock(WalletService.class), mock(EntitlementService.class));
|
||||||
mockMvc = ControllerContractSupport.mockMvcOf(new AppCommerceController(
|
mockMvc = ControllerContractSupport.mockMvcOf(new AppCommerceController(
|
||||||
mock(WalletService.class), mock(UnlockService.class), orderService));
|
mock(WalletService.class), mock(UnlockService.class), orderService,
|
||||||
|
mock(ProductService.class)));
|
||||||
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(
|
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(
|
||||||
new LoginUser(USER, "app-user", "APP_USER", List.of()), null, List.of()));
|
new LoginUser(USER, "app-user", "APP_USER", List.of()), null, List.of()));
|
||||||
}
|
}
|
||||||
@@ -136,7 +137,8 @@ class AppOrdersVerifyContractTest {
|
|||||||
new ProductService(productMapper), storeReceiptMapper, new DisabledStoreVerifier(),
|
new ProductService(productMapper), storeReceiptMapper, new DisabledStoreVerifier(),
|
||||||
mock(WalletService.class), mock(EntitlementService.class));
|
mock(WalletService.class), mock(EntitlementService.class));
|
||||||
MockMvc disabledMvc = ControllerContractSupport.mockMvcOf(new AppCommerceController(
|
MockMvc disabledMvc = ControllerContractSupport.mockMvcOf(new AppCommerceController(
|
||||||
mock(WalletService.class), mock(UnlockService.class), disabled));
|
mock(WalletService.class), mock(UnlockService.class), disabled,
|
||||||
|
mock(ProductService.class)));
|
||||||
|
|
||||||
String body = disabledMvc.perform(post("/app/orders/verify")
|
String body = disabledMvc.perform(post("/app/orders/verify")
|
||||||
.contentType(MediaType.APPLICATION_JSON).content(BODY))
|
.contentType(MediaType.APPLICATION_JSON).content(BODY))
|
||||||
|
|||||||
+17
-2
@@ -3,6 +3,9 @@ package com.fruitshorts.app.controller;
|
|||||||
|
|
||||||
import com.fruitshorts.app.service.AppCatalogService;
|
import com.fruitshorts.app.service.AppCatalogService;
|
||||||
import com.fruitshorts.app.support.ControllerContractSupport;
|
import com.fruitshorts.app.support.ControllerContractSupport;
|
||||||
|
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
||||||
|
import com.fruitshorts.content.service.EpisodeService;
|
||||||
|
import com.fruitshorts.interaction.service.CommentService;
|
||||||
import com.fruitshorts.playback.service.PlaybackService;
|
import com.fruitshorts.playback.service.PlaybackService;
|
||||||
import com.fruitshorts.playback.vo.PlayRespVO;
|
import com.fruitshorts.playback.vo.PlayRespVO;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
@@ -10,6 +13,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
@@ -30,13 +34,22 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
class AppPlaybackContractTest {
|
class AppPlaybackContractTest {
|
||||||
|
|
||||||
private PlaybackService playbackService;
|
private PlaybackService playbackService;
|
||||||
|
private EpisodeService episodeService;
|
||||||
|
private CommentService commentService;
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() {
|
void setUp() {
|
||||||
playbackService = mock(PlaybackService.class);
|
playbackService = mock(PlaybackService.class);
|
||||||
|
episodeService = mock(EpisodeService.class);
|
||||||
|
commentService = mock(CommentService.class);
|
||||||
|
DramaEpisode episode = new DramaEpisode();
|
||||||
|
episode.setLikeCount(88L);
|
||||||
|
given(episodeService.getExisting(any())).willReturn(episode);
|
||||||
|
given(commentService.countByEpisodes(any())).willReturn(Map.of());
|
||||||
mockMvc = ControllerContractSupport.mockMvcOf(
|
mockMvc = ControllerContractSupport.mockMvcOf(
|
||||||
new AppDramaController(mock(AppCatalogService.class), playbackService));
|
new AppDramaController(mock(AppCatalogService.class), playbackService,
|
||||||
|
episodeService, commentService));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -52,7 +65,9 @@ class AppPlaybackContractTest {
|
|||||||
.andExpect(jsonPath("$.data.episodeId").isString())
|
.andExpect(jsonPath("$.data.episodeId").isString())
|
||||||
.andExpect(jsonPath("$.data.accessible").value(true))
|
.andExpect(jsonPath("$.data.accessible").value(true))
|
||||||
.andExpect(jsonPath("$.data.accessType").value(PlaybackService.ACCESS_FREE))
|
.andExpect(jsonPath("$.data.accessType").value(PlaybackService.ACCESS_FREE))
|
||||||
.andExpect(jsonPath("$.data.playUrl").value("/files/ep.mp4?s=1"));
|
.andExpect(jsonPath("$.data.playUrl").value("/files/ep.mp4?s=1"))
|
||||||
|
.andExpect(jsonPath("$.data.likeCount").value("88"))
|
||||||
|
.andExpect(jsonPath("$.data.commentCount").value("0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
+45
-2
@@ -19,6 +19,8 @@ import com.fruitshorts.user.enums.AppUserStatus;
|
|||||||
import com.fruitshorts.user.service.AppAuthService;
|
import com.fruitshorts.user.service.AppAuthService;
|
||||||
import com.fruitshorts.user.service.AppOtpService;
|
import com.fruitshorts.user.service.AppOtpService;
|
||||||
import com.fruitshorts.user.service.CredentialHasher;
|
import com.fruitshorts.user.service.CredentialHasher;
|
||||||
|
import com.fruitshorts.user.service.GoogleIdTokenVerifier;
|
||||||
|
import com.fruitshorts.user.service.GoogleUser;
|
||||||
import com.fruitshorts.user.service.OtpSender;
|
import com.fruitshorts.user.service.OtpSender;
|
||||||
import com.fruitshorts.user.vo.LoginReqVO;
|
import com.fruitshorts.user.vo.LoginReqVO;
|
||||||
import com.fruitshorts.user.vo.RegisterReqVO;
|
import com.fruitshorts.user.vo.RegisterReqVO;
|
||||||
@@ -60,6 +62,7 @@ class AppAuthServiceTest {
|
|||||||
private JwtTokenProvider tokenProvider;
|
private JwtTokenProvider tokenProvider;
|
||||||
private PasswordEncoder passwordEncoder;
|
private PasswordEncoder passwordEncoder;
|
||||||
private ConfigService configService;
|
private ConfigService configService;
|
||||||
|
private GoogleIdTokenVerifier googleVerifier;
|
||||||
private AppAuthService authService;
|
private AppAuthService authService;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
@@ -74,10 +77,12 @@ class AppAuthServiceTest {
|
|||||||
tokenProvider = mock(JwtTokenProvider.class);
|
tokenProvider = mock(JwtTokenProvider.class);
|
||||||
passwordEncoder = mock(PasswordEncoder.class);
|
passwordEncoder = mock(PasswordEncoder.class);
|
||||||
configService = mock(ConfigService.class);
|
configService = mock(ConfigService.class);
|
||||||
|
googleVerifier = mock(GoogleIdTokenVerifier.class);
|
||||||
given(configService.get(anyString(), anyString()))
|
given(configService.get(anyString(), anyString()))
|
||||||
.willAnswer(invocation -> invocation.getArgument(1));
|
.willAnswer(invocation -> invocation.getArgument(1));
|
||||||
authService = new AppAuthService(userMapper, credentialMapper, sessionMapper, consentMapper,
|
authService = new AppAuthService(userMapper, credentialMapper, sessionMapper, consentMapper,
|
||||||
deviceMapper, otpService, hasher, tokenProvider, passwordEncoder, configService);
|
deviceMapper, otpService, hasher, tokenProvider, passwordEncoder, configService,
|
||||||
|
googleVerifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -282,6 +287,43 @@ class AppAuthServiceTest {
|
|||||||
.isEqualTo(ErrorCode.ACCOUNT_DISABLED.getCode()));
|
.isEqualTo(ErrorCode.ACCOUNT_DISABLED.getCode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_auto_register_and_issue_tokens_when_google_login_first_time() {
|
||||||
|
given(googleVerifier.verify(anyString()))
|
||||||
|
.willReturn(new GoogleUser("sub-1", "Alice@Example.com", "Alice", "http://pic/a.png"));
|
||||||
|
given(credentialMapper.selectOne(any())).willReturn(null);
|
||||||
|
given(hasher.newUid()).willReturn("UAB12CD");
|
||||||
|
given(hasher.newRefreshToken()).willReturn("refresh-1");
|
||||||
|
given(hasher.sha256(anyString())).willReturn("hash-1");
|
||||||
|
given(tokenProvider.createAppToken(any(), anyString(), any())).willReturn("access-1");
|
||||||
|
given(tokenProvider.accessTtlSeconds()).willReturn(7200L);
|
||||||
|
given(tokenProvider.appRefreshTtl()).willReturn(Duration.ofDays(30));
|
||||||
|
AtomicReference<AppUser> inserted = new AtomicReference<>();
|
||||||
|
given(userMapper.insert(any(AppUser.class))).willAnswer(invocation -> {
|
||||||
|
AppUser saved = invocation.getArgument(0);
|
||||||
|
saved.setId(1001L);
|
||||||
|
inserted.set(saved);
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
given(userMapper.selectById(any())).willAnswer(invocation -> inserted.get());
|
||||||
|
|
||||||
|
TokenRespVO resp = authService.googleLogin("google-id-token");
|
||||||
|
|
||||||
|
assertThat(resp.getAccessToken()).isEqualTo("access-1");
|
||||||
|
assertThat(resp.isNewUser()).isTrue();
|
||||||
|
verify(sessionMapper).insert(any(AppUserSession.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_reject_google_login_when_email_is_missing() {
|
||||||
|
given(googleVerifier.verify(anyString()))
|
||||||
|
.willReturn(new GoogleUser("sub-1", "", "Alice", ""));
|
||||||
|
|
||||||
|
assertThatThrownBy(() -> authService.googleLogin("google-id-token"))
|
||||||
|
.isInstanceOf(ServiceException.class)
|
||||||
|
.hasMessage("Google 账号未返回邮箱,无法登录");
|
||||||
|
}
|
||||||
|
|
||||||
private void stubHappyRegister() {
|
private void stubHappyRegister() {
|
||||||
given(userMapper.selectCount(any())).willReturn(0L);
|
given(userMapper.selectCount(any())).willReturn(0L);
|
||||||
given(credentialMapper.selectOne(any())).willReturn(null);
|
given(credentialMapper.selectOne(any())).willReturn(null);
|
||||||
@@ -328,7 +370,8 @@ class AppAuthServiceTest {
|
|||||||
given(otpHasher.hashOtp(any())).willReturn("hash-of-something-else");
|
given(otpHasher.hashOtp(any())).willReturn("hash-of-something-else");
|
||||||
AppOtpService realOtpService = new AppOtpService(otpMapper, mock(OtpSender.class), otpHasher);
|
AppOtpService realOtpService = new AppOtpService(otpMapper, mock(OtpSender.class), otpHasher);
|
||||||
return new AppAuthService(userMapper, credentialMapper, sessionMapper, consentMapper,
|
return new AppAuthService(userMapper, credentialMapper, sessionMapper, consentMapper,
|
||||||
deviceMapper, realOtpService, hasher, tokenProvider, passwordEncoder, configService);
|
deviceMapper, realOtpService, hasher, tokenProvider, passwordEncoder, configService,
|
||||||
|
googleVerifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRegisterLimits(int perIp, int perDevice) {
|
private void setRegisterLimits(int perIp, int perDevice) {
|
||||||
|
|||||||
+206
@@ -0,0 +1,206 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
package com.fruitshorts.app.service;
|
||||||
|
|
||||||
|
import com.fruitshorts.app.vo.AppDramaCardVO;
|
||||||
|
import com.fruitshorts.app.vo.AppDramaDetailVO;
|
||||||
|
import com.fruitshorts.common.pojo.CursorResult;
|
||||||
|
import com.fruitshorts.content.dal.entity.Drama;
|
||||||
|
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
||||||
|
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 org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 目录聚合的互动数量装配:详情 VO 的点赞/收藏取短剧计数,评论数取互动域统计。
|
||||||
|
*/
|
||||||
|
class AppCatalogServiceTest {
|
||||||
|
|
||||||
|
private DramaService dramaService;
|
||||||
|
private EpisodeService episodeService;
|
||||||
|
private DramaCategoryService dramaCategoryService;
|
||||||
|
private CommentService commentService;
|
||||||
|
private AppCatalogService catalogService;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
dramaService = mock(DramaService.class);
|
||||||
|
episodeService = mock(EpisodeService.class);
|
||||||
|
BannerService bannerService = mock(BannerService.class);
|
||||||
|
dramaCategoryService = mock(DramaCategoryService.class);
|
||||||
|
PlaybackSigner playbackSigner = mock(PlaybackSigner.class);
|
||||||
|
commentService = mock(CommentService.class);
|
||||||
|
catalogService = new AppCatalogService(dramaService, episodeService, bannerService,
|
||||||
|
dramaCategoryService, playbackSigner, commentService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_fill_interaction_counts_when_drama_detail_is_built() {
|
||||||
|
Drama drama = new Drama();
|
||||||
|
drama.setId(42L);
|
||||||
|
drama.setTitle("命运的相遇");
|
||||||
|
drama.setLikeCount(3200L);
|
||||||
|
drama.setFavoriteCount(1800L);
|
||||||
|
drama.setViewCount(12400L);
|
||||||
|
DramaEpisode firstEpisode = episode(11L, 42L, 55L);
|
||||||
|
DramaEpisode secondEpisode = episode(22L, 42L, 66L);
|
||||||
|
given(dramaService.getPublished(42L)).willReturn(drama);
|
||||||
|
given(episodeService.listPublishedByDrama(42L))
|
||||||
|
.willReturn(List.of(secondEpisode, firstEpisode));
|
||||||
|
given(dramaCategoryService.listBasic()).willReturn(List.of());
|
||||||
|
given(commentService.countByDrama(42L)).willReturn(96L);
|
||||||
|
given(commentService.countByEpisodes(List.of(11L, 22L)))
|
||||||
|
.willReturn(Map.of(11L, 2L, 22L, 4L));
|
||||||
|
|
||||||
|
AppDramaDetailVO detail = catalogService.dramaDetail(42L);
|
||||||
|
|
||||||
|
assertThat(detail.getViewCount()).isEqualTo(12400L);
|
||||||
|
assertThat(detail.getLikeCount()).isEqualTo(3200L);
|
||||||
|
assertThat(detail.getFavoriteCount()).isEqualTo(1800L);
|
||||||
|
assertThat(detail.getCommentCount()).isEqualTo(96L);
|
||||||
|
assertThat(detail.getEpisodes().get(0).getLikeCount()).isEqualTo(66L);
|
||||||
|
assertThat(detail.getEpisodes().get(0).getCommentCount()).isEqualTo(4L);
|
||||||
|
verify(commentService).countByDrama(42L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_fill_card_counts_with_one_batch_comment_query() {
|
||||||
|
Drama first = new Drama();
|
||||||
|
first.setId(1L);
|
||||||
|
first.setTitle("第一部");
|
||||||
|
first.setViewCount(1200L);
|
||||||
|
first.setLikeCount(320L);
|
||||||
|
first.setFavoriteCount(180L);
|
||||||
|
Drama second = new Drama();
|
||||||
|
second.setId(2L);
|
||||||
|
second.setTitle("第二部");
|
||||||
|
second.setViewCount(800L);
|
||||||
|
second.setLikeCount(120L);
|
||||||
|
second.setFavoriteCount(80L);
|
||||||
|
DramaEpisode firstEpisode = episode(11L, 1L, 320L);
|
||||||
|
DramaEpisode secondEpisode = episode(22L, 2L, 120L);
|
||||||
|
Map<Long, DramaEpisode> previews = new LinkedHashMap<>();
|
||||||
|
previews.put(2L, secondEpisode);
|
||||||
|
previews.put(1L, firstEpisode);
|
||||||
|
given(episodeService.firstPlayableByDramas(List.of(1L, 2L))).willReturn(previews);
|
||||||
|
given(dramaCategoryService.listBasic()).willReturn(List.of());
|
||||||
|
given(commentService.countByEpisodes(List.of(11L, 22L)))
|
||||||
|
.willReturn(Map.of(11L, 9L));
|
||||||
|
|
||||||
|
List<AppDramaCardVO> cards = catalogService.toCards(List.of(first, second));
|
||||||
|
|
||||||
|
assertThat(cards).hasSize(2);
|
||||||
|
assertThat(cards.get(0).getLikeCount()).isEqualTo(320L);
|
||||||
|
assertThat(cards.get(0).getFavoriteCount()).isEqualTo(180L);
|
||||||
|
assertThat(cards.get(0).getCommentCount()).isEqualTo(9L);
|
||||||
|
assertThat(cards.get(1).getLikeCount()).isEqualTo(120L);
|
||||||
|
assertThat(cards.get(1).getFavoriteCount()).isEqualTo(80L);
|
||||||
|
assertThat(cards.get(1).getCommentCount()).isZero();
|
||||||
|
verify(commentService).countByEpisodes(List.of(11L, 22L));
|
||||||
|
verify(commentService, never()).countByDrama(any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_filter_feed_by_drama_type_and_expose_it_on_card() {
|
||||||
|
Drama anime = drama(1L, "ANIME");
|
||||||
|
given(dramaService.listPublishedFeed(List.of("ANIME"), null, null, 21))
|
||||||
|
.willReturn(List.of(anime));
|
||||||
|
given(dramaCategoryService.listBasic()).willReturn(List.of());
|
||||||
|
DramaEpisode preview = episode(11L, 1L, 45L);
|
||||||
|
given(episodeService.firstPlayableByDramas(List.of(1L)))
|
||||||
|
.willReturn(Map.of(1L, preview));
|
||||||
|
given(commentService.countByEpisodes(List.of(11L))).willReturn(Map.of(11L, 3L));
|
||||||
|
|
||||||
|
CursorResult<AppDramaCardVO> result = catalogService.feed(
|
||||||
|
"ANIME", null, null, null);
|
||||||
|
|
||||||
|
assertThat(result.getList()).hasSize(1);
|
||||||
|
assertThat(result.getList().get(0).getDramaType()).isEqualTo("ANIME");
|
||||||
|
assertThat(result.getList().get(0).getCommentCount()).isEqualTo(3L);
|
||||||
|
assertThat(result.getList().get(0).getLikeCount()).isEqualTo(45L);
|
||||||
|
assertThat(result.isHasMore()).isFalse();
|
||||||
|
verify(dramaService).listPublishedFeed(List.of("ANIME"), null, null, 21);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_parse_multiple_feed_types() {
|
||||||
|
given(dramaService.listPublishedFeed(
|
||||||
|
List.of("ANIME", "LIVE"), null, null, 11))
|
||||||
|
.willReturn(List.of());
|
||||||
|
|
||||||
|
CursorResult<AppDramaCardVO> result = catalogService.feed(
|
||||||
|
"ANIME,LIVE", null, null, 10);
|
||||||
|
|
||||||
|
assertThat(result.getList()).isEmpty();
|
||||||
|
verify(dramaService).listPublishedFeed(
|
||||||
|
List.of("ANIME", "LIVE"), null, null, 11);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_filter_feed_by_category_id_only() {
|
||||||
|
given(dramaService.listPublishedFeed(List.of(), 7L, null, 21))
|
||||||
|
.willReturn(List.of());
|
||||||
|
|
||||||
|
CursorResult<AppDramaCardVO> result = catalogService.feed(
|
||||||
|
null, 7L, null, null);
|
||||||
|
|
||||||
|
assertThat(result.getList()).isEmpty();
|
||||||
|
verify(dramaService).listPublishedFeed(List.of(), 7L, null, 21);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_page_feed_with_cursor_without_duplicates() {
|
||||||
|
Drama first = drama(1L, "ANIME");
|
||||||
|
Drama second = drama(2L, "LIVE");
|
||||||
|
given(dramaService.listPublishedFeed(List.of(), null, null, 2))
|
||||||
|
.willReturn(List.of(first, second));
|
||||||
|
given(dramaService.listPublishedFeed(List.of(), null, 1L, 2))
|
||||||
|
.willReturn(List.of(second));
|
||||||
|
given(dramaCategoryService.listBasic()).willReturn(List.of());
|
||||||
|
given(episodeService.firstPlayableByDramas(any())).willReturn(Map.of());
|
||||||
|
given(commentService.countByEpisodes(any())).willReturn(Map.of());
|
||||||
|
|
||||||
|
CursorResult<AppDramaCardVO> firstPage = catalogService.feed(
|
||||||
|
null, null, null, 1);
|
||||||
|
CursorResult<AppDramaCardVO> secondPage = catalogService.feed(
|
||||||
|
null, null, firstPage.getNextCursor(), 1);
|
||||||
|
|
||||||
|
assertThat(firstPage.getList()).extracting(AppDramaCardVO::getId).containsExactly(1L);
|
||||||
|
assertThat(firstPage.getNextCursor()).isEqualTo(1L);
|
||||||
|
assertThat(firstPage.isHasMore()).isTrue();
|
||||||
|
assertThat(secondPage.getList()).extracting(AppDramaCardVO::getId).containsExactly(2L);
|
||||||
|
assertThat(secondPage.getNextCursor()).isNull();
|
||||||
|
assertThat(secondPage.isHasMore()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Drama drama(Long id, String dramaType) {
|
||||||
|
Drama drama = new Drama();
|
||||||
|
drama.setId(id);
|
||||||
|
drama.setTitle("短剧" + id);
|
||||||
|
drama.setDramaType(dramaType);
|
||||||
|
return drama;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DramaEpisode episode(Long id, Long dramaId, Long likeCount) {
|
||||||
|
DramaEpisode episode = new DramaEpisode();
|
||||||
|
episode.setId(id);
|
||||||
|
episode.setDramaId(dramaId);
|
||||||
|
episode.setLikeCount(likeCount);
|
||||||
|
return episode;
|
||||||
|
}
|
||||||
|
}
|
||||||
+131
@@ -0,0 +1,131 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
package com.fruitshorts.app.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.AbstractWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||||
|
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.user.dal.mapper.AppUserMapper;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
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 CommentServiceCountTest {
|
||||||
|
|
||||||
|
private ContentCommentMapper commentMapper;
|
||||||
|
private CommentService commentService;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void initTableInfo() {
|
||||||
|
TableInfoHelper.initTableInfo(
|
||||||
|
new MapperBuilderAssistant(new MybatisConfiguration(), ""), ContentComment.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
commentMapper = mock(ContentCommentMapper.class);
|
||||||
|
commentService = new CommentService(
|
||||||
|
commentMapper,
|
||||||
|
mock(ContentLikeMapper.class),
|
||||||
|
mock(ContentAuditRecordMapper.class),
|
||||||
|
mock(AppUserMapper.class),
|
||||||
|
mock(DramaService.class),
|
||||||
|
mock(EpisodeService.class),
|
||||||
|
mock(SensitiveWordService.class),
|
||||||
|
mock(AuditRecorder.class),
|
||||||
|
mock(InteractionProperties.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_count_comments_of_drama_and_exclude_deleted() {
|
||||||
|
ArgumentCaptor<Wrapper<ContentComment>> captor = ArgumentCaptor.forClass(Wrapper.class);
|
||||||
|
given(commentMapper.selectCount(captor.capture())).willReturn(5L);
|
||||||
|
|
||||||
|
long count = commentService.countByDrama(7L);
|
||||||
|
|
||||||
|
assertThat(count).isEqualTo(5L);
|
||||||
|
Wrapper<ContentComment> wrapper = captor.getValue();
|
||||||
|
assertThat(wrapper.getSqlSegment()).contains("drama_id").contains("status");
|
||||||
|
AbstractWrapper<ContentComment, ?, ?> lambda = (AbstractWrapper<ContentComment, ?, ?>) wrapper;
|
||||||
|
assertThat(lambda.getParamNameValuePairs().values()).contains(7L, "deleted");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_return_zero_without_query_when_drama_id_is_missing() {
|
||||||
|
assertThat(commentService.countByDrama(null)).isZero();
|
||||||
|
verify(commentMapper, never()).selectCount(any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_return_empty_map_without_query_when_drama_ids_are_empty() {
|
||||||
|
assertThat(commentService.countByDramas(List.of())).isEmpty();
|
||||||
|
verify(commentMapper, never()).selectMaps(any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_group_comment_counts_when_multiple_dramas_are_requested() {
|
||||||
|
ArgumentCaptor<Wrapper<ContentComment>> captor = ArgumentCaptor.forClass(Wrapper.class);
|
||||||
|
given(commentMapper.selectMaps(captor.capture())).willReturn(List.of(
|
||||||
|
Map.of("drama_id", 7L, "comment_count", 5L),
|
||||||
|
Map.of("drama_id", 8L, "comment_count", 2L)));
|
||||||
|
|
||||||
|
Map<Long, Long> counts = commentService.countByDramas(
|
||||||
|
Arrays.asList(7L, 8L, 8L, null));
|
||||||
|
|
||||||
|
assertThat(counts).containsEntry(7L, 5L).containsEntry(8L, 2L);
|
||||||
|
Wrapper<ContentComment> wrapper = captor.getValue();
|
||||||
|
assertThat(wrapper.getSqlSegment())
|
||||||
|
.contains("drama_id")
|
||||||
|
.contains("status")
|
||||||
|
.contains("deleted")
|
||||||
|
.contains("GROUP BY");
|
||||||
|
AbstractWrapper<ContentComment, ?, ?> lambda = (AbstractWrapper<ContentComment, ?, ?>) wrapper;
|
||||||
|
assertThat(lambda.getParamNameValuePairs().values())
|
||||||
|
.contains(7L, 8L, "deleted");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_group_comment_counts_by_episode() {
|
||||||
|
ArgumentCaptor<Wrapper<ContentComment>> captor = ArgumentCaptor.forClass(Wrapper.class);
|
||||||
|
given(commentMapper.selectMaps(captor.capture())).willReturn(List.of(
|
||||||
|
Map.of("episode_id", 11L, "comment_count", 4L),
|
||||||
|
Map.of("episode_id", 12L, "comment_count", 2L)));
|
||||||
|
|
||||||
|
Map<Long, Long> counts = commentService.countByEpisodes(
|
||||||
|
Arrays.asList(11L, 12L, 12L, null));
|
||||||
|
|
||||||
|
assertThat(counts).containsEntry(11L, 4L).containsEntry(12L, 2L);
|
||||||
|
Wrapper<ContentComment> wrapper = captor.getValue();
|
||||||
|
assertThat(wrapper.getSqlSegment())
|
||||||
|
.contains("episode_id")
|
||||||
|
.contains("status")
|
||||||
|
.contains("deleted")
|
||||||
|
.contains("GROUP BY");
|
||||||
|
}
|
||||||
|
}
|
||||||
+57
@@ -0,0 +1,57 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
package com.fruitshorts.app.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||||
|
import com.fruitshorts.content.dal.entity.Drama;
|
||||||
|
import com.fruitshorts.content.dal.mapper.DramaEpisodeMapper;
|
||||||
|
import com.fruitshorts.content.dal.mapper.DramaMapper;
|
||||||
|
import com.fruitshorts.content.dal.mapper.DramaReviewRecordMapper;
|
||||||
|
import com.fruitshorts.content.service.DramaCategoryService;
|
||||||
|
import com.fruitshorts.content.service.DramaService;
|
||||||
|
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.isNull;
|
||||||
|
import static org.mockito.BDDMockito.given;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
|
/** 收藏数减操作必须使用不低于 0 的原子 SQL。 */
|
||||||
|
class DramaServiceFavoriteCountTest {
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void initTableInfo() {
|
||||||
|
TableInfoHelper.initTableInfo(
|
||||||
|
new MapperBuilderAssistant(new MybatisConfiguration(), ""), Drama.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
void should_use_greatest_zero_when_favorite_count_decrements() {
|
||||||
|
DramaMapper dramaMapper = mock(DramaMapper.class);
|
||||||
|
DramaService dramaService = new DramaService(
|
||||||
|
dramaMapper,
|
||||||
|
mock(DramaEpisodeMapper.class),
|
||||||
|
mock(DramaReviewRecordMapper.class),
|
||||||
|
mock(DramaCategoryService.class));
|
||||||
|
given(dramaMapper.update(isNull(), any())).willReturn(1);
|
||||||
|
ArgumentCaptor<Wrapper<Drama>> captor = ArgumentCaptor.forClass(Wrapper.class);
|
||||||
|
|
||||||
|
dramaService.adjustFavoriteCount(7L, -1);
|
||||||
|
|
||||||
|
verify(dramaMapper).update(isNull(), captor.capture());
|
||||||
|
Wrapper<Drama> wrapper = captor.getValue();
|
||||||
|
LambdaUpdateWrapper<Drama> update = (LambdaUpdateWrapper<Drama>) wrapper;
|
||||||
|
assertThat(update.getSqlSet())
|
||||||
|
.contains("GREATEST(favorite_count - 1, 0)");
|
||||||
|
assertThat(update.getSqlSegment()).contains("id");
|
||||||
|
}
|
||||||
|
}
|
||||||
+159
@@ -0,0 +1,159 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
package com.fruitshorts.app.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||||
|
import com.fruitshorts.content.dal.entity.Drama;
|
||||||
|
import com.fruitshorts.content.dal.mapper.DramaEpisodeMapper;
|
||||||
|
import com.fruitshorts.content.dal.mapper.DramaMapper;
|
||||||
|
import com.fruitshorts.content.dal.mapper.DramaReviewRecordMapper;
|
||||||
|
import com.fruitshorts.content.service.DramaCategoryService;
|
||||||
|
import com.fruitshorts.content.service.DramaService;
|
||||||
|
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.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;
|
||||||
|
|
||||||
|
/** K88 App 推荐流的类型过滤与三字段 keyset 游标。 */
|
||||||
|
class DramaServiceFeedTest {
|
||||||
|
|
||||||
|
private DramaMapper dramaMapper;
|
||||||
|
private DramaService dramaService;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void initTableInfo() {
|
||||||
|
TableInfoHelper.initTableInfo(
|
||||||
|
new MapperBuilderAssistant(new MybatisConfiguration(), ""), Drama.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
dramaMapper = mock(DramaMapper.class);
|
||||||
|
dramaService = new DramaService(
|
||||||
|
dramaMapper,
|
||||||
|
mock(DramaEpisodeMapper.class),
|
||||||
|
mock(DramaReviewRecordMapper.class),
|
||||||
|
mock(DramaCategoryService.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
void should_filter_types_and_apply_recommendation_cursor() {
|
||||||
|
Drama marker = new Drama();
|
||||||
|
marker.setId(9L);
|
||||||
|
marker.setStatus("published");
|
||||||
|
marker.setDramaType("ANIME");
|
||||||
|
marker.setRecommendWeight(30);
|
||||||
|
marker.setViewCount(1200L);
|
||||||
|
given(dramaMapper.selectById(9L)).willReturn(marker);
|
||||||
|
given(dramaMapper.selectList(any())).willReturn(List.of());
|
||||||
|
ArgumentCaptor<QueryWrapper<Drama>> captor = ArgumentCaptor.forClass(QueryWrapper.class);
|
||||||
|
|
||||||
|
dramaService.listPublishedFeed(List.of("ANIME"), null, 9L, 5);
|
||||||
|
|
||||||
|
verify(dramaMapper).selectList(captor.capture());
|
||||||
|
QueryWrapper<Drama> query = captor.getValue();
|
||||||
|
assertThat(query.getSqlSegment())
|
||||||
|
.contains("status")
|
||||||
|
.contains("drama_type")
|
||||||
|
.contains("recommend_weight")
|
||||||
|
.contains("view_count")
|
||||||
|
.contains("id");
|
||||||
|
assertThat(query.getParamNameValuePairs().values())
|
||||||
|
.contains("published", "%,ANIME,%", 30, 1200L, 9L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
void should_handle_null_recommend_weight_in_cursor() {
|
||||||
|
Drama marker = new Drama();
|
||||||
|
marker.setId(9L);
|
||||||
|
marker.setStatus("published");
|
||||||
|
marker.setDramaType("LIVE");
|
||||||
|
marker.setViewCount(1200L);
|
||||||
|
given(dramaMapper.selectById(9L)).willReturn(marker);
|
||||||
|
given(dramaMapper.selectList(any())).willReturn(List.of());
|
||||||
|
ArgumentCaptor<QueryWrapper<Drama>> captor = ArgumentCaptor.forClass(QueryWrapper.class);
|
||||||
|
|
||||||
|
dramaService.listPublishedFeed(List.of("LIVE"), null, 9L, 5);
|
||||||
|
|
||||||
|
verify(dramaMapper).selectList(captor.capture());
|
||||||
|
assertThat(captor.getValue().getSqlSegment())
|
||||||
|
.contains("recommend_weight IS NULL")
|
||||||
|
.contains("view_count")
|
||||||
|
.contains("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
void should_apply_category_and_type_tokens_together() {
|
||||||
|
given(dramaMapper.selectList(any())).willReturn(List.of());
|
||||||
|
ArgumentCaptor<QueryWrapper<Drama>> captor = ArgumentCaptor.forClass(QueryWrapper.class);
|
||||||
|
|
||||||
|
dramaService.listPublishedFeed(List.of("ANIME"), 7L, null, 5);
|
||||||
|
|
||||||
|
verify(dramaMapper).selectList(captor.capture());
|
||||||
|
QueryWrapper<Drama> query = captor.getValue();
|
||||||
|
assertThat(query.getSqlSegment())
|
||||||
|
.contains("drama_types")
|
||||||
|
.contains("category_ids")
|
||||||
|
.contains("recommend_weight");
|
||||||
|
assertThat(query.getParamNameValuePairs().values())
|
||||||
|
.contains("%,ANIME,%", "%,7,%");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
void should_apply_category_cursor_for_matching_marker() {
|
||||||
|
Drama marker = new Drama();
|
||||||
|
marker.setId(9L);
|
||||||
|
marker.setStatus("published");
|
||||||
|
marker.setDramaType("ANIME");
|
||||||
|
marker.setCategoryId(7L);
|
||||||
|
marker.setCategoryIds("7,8");
|
||||||
|
marker.setRecommendWeight(30);
|
||||||
|
marker.setViewCount(1200L);
|
||||||
|
given(dramaMapper.selectById(9L)).willReturn(marker);
|
||||||
|
given(dramaMapper.selectList(any())).willReturn(List.of());
|
||||||
|
ArgumentCaptor<QueryWrapper<Drama>> captor = ArgumentCaptor.forClass(QueryWrapper.class);
|
||||||
|
|
||||||
|
dramaService.listPublishedFeed(List.of(), 7L, 9L, 5);
|
||||||
|
|
||||||
|
verify(dramaMapper).selectList(captor.capture());
|
||||||
|
QueryWrapper<Drama> query = captor.getValue();
|
||||||
|
assertThat(query.getSqlSegment())
|
||||||
|
.contains("category_ids")
|
||||||
|
.contains("recommend_weight")
|
||||||
|
.contains("id");
|
||||||
|
assertThat(query.getParamNameValuePairs().values())
|
||||||
|
.contains("%,7,%", 30, 1200L, 9L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_return_empty_when_cursor_marker_does_not_match_category() {
|
||||||
|
Drama marker = new Drama();
|
||||||
|
marker.setId(9L);
|
||||||
|
marker.setStatus("published");
|
||||||
|
marker.setDramaType("ANIME");
|
||||||
|
marker.setCategoryId(8L);
|
||||||
|
marker.setCategoryIds("8");
|
||||||
|
given(dramaMapper.selectById(9L)).willReturn(marker);
|
||||||
|
|
||||||
|
List<Drama> rows = dramaService.listPublishedFeed(List.of("ANIME"), 7L, 9L, 5);
|
||||||
|
|
||||||
|
assertThat(rows).isEmpty();
|
||||||
|
verify(dramaMapper, never()).selectList(any());
|
||||||
|
}
|
||||||
|
}
|
||||||
+127
@@ -0,0 +1,127 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
package com.fruitshorts.app.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||||
|
import com.fruitshorts.common.exception.ErrorCode;
|
||||||
|
import com.fruitshorts.common.exception.ServiceException;
|
||||||
|
import com.fruitshorts.content.dal.entity.Drama;
|
||||||
|
import com.fruitshorts.content.dal.mapper.DramaEpisodeMapper;
|
||||||
|
import com.fruitshorts.content.dal.mapper.DramaMapper;
|
||||||
|
import com.fruitshorts.content.dal.mapper.DramaReviewRecordMapper;
|
||||||
|
import com.fruitshorts.content.service.DramaCategoryService;
|
||||||
|
import com.fruitshorts.content.service.DramaService;
|
||||||
|
import com.fruitshorts.content.vo.DramaSaveReqVO;
|
||||||
|
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 static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/** K88 后台短剧内容类型与互动数据编辑规则。 */
|
||||||
|
class DramaServiceK88Test {
|
||||||
|
|
||||||
|
private DramaMapper dramaMapper;
|
||||||
|
private DramaService dramaService;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void initTableInfo() {
|
||||||
|
TableInfoHelper.initTableInfo(
|
||||||
|
new MapperBuilderAssistant(new MybatisConfiguration(), ""), Drama.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
dramaMapper = mock(DramaMapper.class);
|
||||||
|
dramaService = new DramaService(
|
||||||
|
dramaMapper,
|
||||||
|
mock(DramaEpisodeMapper.class),
|
||||||
|
mock(DramaReviewRecordMapper.class),
|
||||||
|
mock(DramaCategoryService.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_update_only_requested_counts_and_preserve_drama_type() {
|
||||||
|
Drama existing = drama();
|
||||||
|
given(dramaMapper.selectById(7L)).willReturn(existing);
|
||||||
|
DramaSaveReqVO req = new DramaSaveReqVO();
|
||||||
|
req.setTitle("更新后的标题");
|
||||||
|
req.setFavoriteCount(99L);
|
||||||
|
req.setHeat(500L);
|
||||||
|
|
||||||
|
dramaService.update(7L, req);
|
||||||
|
|
||||||
|
ArgumentCaptor<Drama> captor = ArgumentCaptor.forClass(Drama.class);
|
||||||
|
verify(dramaMapper).updateById(captor.capture());
|
||||||
|
Drama updated = captor.getValue();
|
||||||
|
assertThat(updated.getFavoriteCount()).isEqualTo(99L);
|
||||||
|
assertThat(updated.getLikeCount()).isEqualTo(20L);
|
||||||
|
assertThat(updated.getViewCount()).isEqualTo(500L);
|
||||||
|
assertThat(updated.getDramaType()).isEqualTo("ANIME");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_reject_negative_interaction_count() {
|
||||||
|
given(dramaMapper.selectById(7L)).willReturn(drama());
|
||||||
|
DramaSaveReqVO req = new DramaSaveReqVO();
|
||||||
|
req.setTitle("更新后的标题");
|
||||||
|
req.setFavoriteCount(-1L);
|
||||||
|
|
||||||
|
assertThatThrownBy(() -> dramaService.update(7L, req))
|
||||||
|
.isInstanceOf(ServiceException.class)
|
||||||
|
.satisfies(error -> assertThat(((ServiceException) error).getCode())
|
||||||
|
.isEqualTo(ErrorCode.BAD_REQUEST.getCode()));
|
||||||
|
verify(dramaMapper, never()).updateById(any(Drama.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_reject_invalid_drama_type() {
|
||||||
|
given(dramaMapper.selectById(7L)).willReturn(drama());
|
||||||
|
DramaSaveReqVO req = new DramaSaveReqVO();
|
||||||
|
req.setTitle("更新后的标题");
|
||||||
|
req.setDramaType("MOVIE");
|
||||||
|
|
||||||
|
assertThatThrownBy(() -> dramaService.update(7L, req))
|
||||||
|
.isInstanceOf(ServiceException.class)
|
||||||
|
.satisfies(error -> assertThat(((ServiceException) error).getCode())
|
||||||
|
.isEqualTo(ErrorCode.BAD_REQUEST.getCode()));
|
||||||
|
verify(dramaMapper, never()).updateById(any(Drama.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_default_new_drama_to_live_and_zero_counts() {
|
||||||
|
DramaSaveReqVO req = new DramaSaveReqVO();
|
||||||
|
req.setTitle("新短剧");
|
||||||
|
|
||||||
|
dramaService.create(req, 1L);
|
||||||
|
|
||||||
|
ArgumentCaptor<Drama> captor = ArgumentCaptor.forClass(Drama.class);
|
||||||
|
verify(dramaMapper).insert(captor.capture());
|
||||||
|
Drama created = captor.getValue();
|
||||||
|
assertThat(created.getDramaType()).isEqualTo("LIVE");
|
||||||
|
assertThat(created.getFavoriteCount()).isZero();
|
||||||
|
assertThat(created.getLikeCount()).isZero();
|
||||||
|
assertThat(created.getViewCount()).isZero();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Drama drama() {
|
||||||
|
Drama drama = new Drama();
|
||||||
|
drama.setId(7L);
|
||||||
|
drama.setTitle("原标题");
|
||||||
|
drama.setStatus("published");
|
||||||
|
drama.setDramaType("ANIME");
|
||||||
|
drama.setFavoriteCount(10L);
|
||||||
|
drama.setLikeCount(20L);
|
||||||
|
drama.setViewCount(30L);
|
||||||
|
return drama;
|
||||||
|
}
|
||||||
|
}
|
||||||
+192
@@ -0,0 +1,192 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
package com.fruitshorts.app.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.fruitshorts.content.dal.entity.Drama;
|
||||||
|
import com.fruitshorts.content.dal.mapper.DramaEpisodeMapper;
|
||||||
|
import com.fruitshorts.content.dal.mapper.DramaMapper;
|
||||||
|
import com.fruitshorts.content.dal.mapper.DramaReviewRecordMapper;
|
||||||
|
import com.fruitshorts.content.service.DramaCategoryService;
|
||||||
|
import com.fruitshorts.content.service.DramaService;
|
||||||
|
import com.fruitshorts.content.vo.DramaPageReqVO;
|
||||||
|
import com.fruitshorts.content.vo.DramaRespVO;
|
||||||
|
import com.fruitshorts.content.vo.DramaSaveReqVO;
|
||||||
|
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.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
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.times;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
|
/** K93 短剧分类与内容类型多选。 */
|
||||||
|
class DramaServiceMultiTagTest {
|
||||||
|
|
||||||
|
private DramaMapper dramaMapper;
|
||||||
|
private DramaCategoryService categoryService;
|
||||||
|
private DramaService dramaService;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void initTableInfo() {
|
||||||
|
TableInfoHelper.initTableInfo(
|
||||||
|
new MapperBuilderAssistant(new MybatisConfiguration(), ""), Drama.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
dramaMapper = mock(DramaMapper.class);
|
||||||
|
categoryService = mock(DramaCategoryService.class);
|
||||||
|
dramaService = new DramaService(
|
||||||
|
dramaMapper,
|
||||||
|
mock(DramaEpisodeMapper.class),
|
||||||
|
mock(DramaReviewRecordMapper.class),
|
||||||
|
categoryService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_save_distinct_multi_tags_and_write_first_value_as_primary() {
|
||||||
|
DramaSaveReqVO req = new DramaSaveReqVO();
|
||||||
|
req.setTitle("多标签短剧");
|
||||||
|
req.setDramaTypes(List.of("live", "ANIME", "LIVE", " anime "));
|
||||||
|
req.setCategoryIds(Arrays.asList(3L, 1L, 3L, 0L, null));
|
||||||
|
req.setGenre("类型三 / 类型一");
|
||||||
|
|
||||||
|
dramaService.create(req, 1L);
|
||||||
|
|
||||||
|
ArgumentCaptor<Drama> captor = ArgumentCaptor.forClass(Drama.class);
|
||||||
|
verify(dramaMapper).insert(captor.capture());
|
||||||
|
Drama created = captor.getValue();
|
||||||
|
assertThat(created.getDramaType()).isEqualTo("LIVE");
|
||||||
|
assertThat(created.getDramaTypes()).isEqualTo("LIVE,ANIME");
|
||||||
|
assertThat(created.getCategoryId()).isEqualTo(3L);
|
||||||
|
assertThat(created.getCategoryIds()).isEqualTo("3,1");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_keep_single_value_behavior_when_lists_are_absent() {
|
||||||
|
Drama existing = drama(7L);
|
||||||
|
existing.setDramaType("ANIME");
|
||||||
|
existing.setDramaTypes("ANIME");
|
||||||
|
existing.setCategoryId(2L);
|
||||||
|
existing.setCategoryIds("2");
|
||||||
|
given(dramaMapper.selectById(7L)).willReturn(existing);
|
||||||
|
DramaSaveReqVO req = new DramaSaveReqVO();
|
||||||
|
req.setTitle("单值更新");
|
||||||
|
req.setDramaType("live");
|
||||||
|
req.setCategoryId(4L);
|
||||||
|
|
||||||
|
dramaService.update(7L, req);
|
||||||
|
|
||||||
|
ArgumentCaptor<Drama> captor = ArgumentCaptor.forClass(Drama.class);
|
||||||
|
verify(dramaMapper).updateById(captor.capture());
|
||||||
|
assertThat(captor.getValue().getDramaType()).isEqualTo("LIVE");
|
||||||
|
assertThat(captor.getValue().getDramaTypes()).isEqualTo("LIVE");
|
||||||
|
assertThat(captor.getValue().getCategoryId()).isEqualTo(4L);
|
||||||
|
assertThat(captor.getValue().getCategoryIds()).isEqualTo("4");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
void should_apply_token_filters_for_admin_page_multi_tags() {
|
||||||
|
Page<Drama> page = new Page<>(1, 10);
|
||||||
|
page.setRecords(List.of());
|
||||||
|
given(dramaMapper.selectPage(any(Page.class), any())).willReturn(page);
|
||||||
|
DramaPageReqVO req = new DramaPageReqVO();
|
||||||
|
req.setDramaTypes(List.of("ANIME", "LIVE"));
|
||||||
|
req.setCategoryIds(List.of(2L, 3L));
|
||||||
|
ArgumentCaptor<LambdaQueryWrapper<Drama>> captor =
|
||||||
|
ArgumentCaptor.forClass(LambdaQueryWrapper.class);
|
||||||
|
|
||||||
|
dramaService.page(req);
|
||||||
|
|
||||||
|
verify(dramaMapper).selectPage(any(), captor.capture());
|
||||||
|
assertThat(captor.getValue().getSqlSegment())
|
||||||
|
.contains("drama_types")
|
||||||
|
.contains("category_ids")
|
||||||
|
.contains("LIKE");
|
||||||
|
assertThat(captor.getValue().getParamNameValuePairs().values())
|
||||||
|
.contains("%,ANIME,%", "%,LIVE,%", "%,2,%", "%,3,%");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
void should_allow_multi_tag_cursor_marker_for_each_filter_type() {
|
||||||
|
Drama marker = drama(9L);
|
||||||
|
marker.setDramaType("ANIME");
|
||||||
|
marker.setDramaTypes("ANIME,LIVE");
|
||||||
|
marker.setRecommendWeight(30);
|
||||||
|
marker.setViewCount(1200L);
|
||||||
|
given(dramaMapper.selectById(9L)).willReturn(marker);
|
||||||
|
given(dramaMapper.selectList(any())).willReturn(List.of());
|
||||||
|
ArgumentCaptor<QueryWrapper<Drama>> captor = ArgumentCaptor.forClass(QueryWrapper.class);
|
||||||
|
|
||||||
|
dramaService.listPublishedFeed(List.of("ANIME"), null, 9L, 5);
|
||||||
|
dramaService.listPublishedFeed(List.of("LIVE"), null, 9L, 5);
|
||||||
|
|
||||||
|
verify(dramaMapper, times(2)).selectList(captor.capture());
|
||||||
|
assertThat(captor.getAllValues()).allSatisfy(query ->
|
||||||
|
assertThat(query.getSqlSegment())
|
||||||
|
.contains("drama_types")
|
||||||
|
.contains("LIKE"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
void should_match_multi_category_when_loading_app_category_section() {
|
||||||
|
Page<Drama> page = new Page<>(1, 10);
|
||||||
|
page.setRecords(List.of());
|
||||||
|
given(dramaMapper.selectPage(any(Page.class), any())).willReturn(page);
|
||||||
|
ArgumentCaptor<LambdaQueryWrapper<Drama>> captor =
|
||||||
|
ArgumentCaptor.forClass(LambdaQueryWrapper.class);
|
||||||
|
|
||||||
|
dramaService.listPublished(3L, 10);
|
||||||
|
|
||||||
|
verify(dramaMapper).selectPage(any(), captor.capture());
|
||||||
|
assertThat(captor.getValue().getSqlSegment())
|
||||||
|
.contains("category_ids")
|
||||||
|
.contains("LIKE");
|
||||||
|
assertThat(captor.getValue().getParamNameValuePairs().values()).contains("%,3,%");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_parse_multi_values_and_keep_category_name_order_in_response() {
|
||||||
|
Drama drama = drama(7L);
|
||||||
|
drama.setDramaType("LIVE");
|
||||||
|
drama.setDramaTypes("LIVE,ANIME");
|
||||||
|
drama.setCategoryId(3L);
|
||||||
|
drama.setCategoryIds("3,1");
|
||||||
|
drama.setGenre("Fallback Genre");
|
||||||
|
given(dramaMapper.selectById(7L)).willReturn(drama);
|
||||||
|
given(categoryService.nameMap()).willReturn(Map.of(1L, "Type A", 3L, "Type B"));
|
||||||
|
|
||||||
|
DramaRespVO vo = dramaService.get(7L);
|
||||||
|
|
||||||
|
assertThat(vo.getDramaTypes()).containsExactly("LIVE", "ANIME");
|
||||||
|
assertThat(vo.getCategoryIds()).containsExactly(3L, 1L);
|
||||||
|
assertThat(vo.getCategoryNames()).containsExactly("Type B", "Type A");
|
||||||
|
assertThat(vo.getDramaType()).isEqualTo("LIVE");
|
||||||
|
assertThat(vo.getCategoryId()).isEqualTo(3L);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Drama drama(Long id) {
|
||||||
|
Drama drama = new Drama();
|
||||||
|
drama.setId(id);
|
||||||
|
drama.setStatus("published");
|
||||||
|
drama.setViewCount(0L);
|
||||||
|
return drama;
|
||||||
|
}
|
||||||
|
}
|
||||||
+113
@@ -0,0 +1,113 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
package com.fruitshorts.app.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||||
|
import com.fruitshorts.common.exception.ErrorCode;
|
||||||
|
import com.fruitshorts.common.exception.ServiceException;
|
||||||
|
import com.fruitshorts.content.dal.entity.DramaEpisode;
|
||||||
|
import com.fruitshorts.content.dal.mapper.DramaEpisodeMapper;
|
||||||
|
import com.fruitshorts.content.service.DramaService;
|
||||||
|
import com.fruitshorts.content.service.EpisodeService;
|
||||||
|
import com.fruitshorts.content.vo.EpisodeSaveReqVO;
|
||||||
|
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.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.isNull;
|
||||||
|
import static org.mockito.BDDMockito.given;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
|
/** K89:剧集点赞编辑、原子增减与剧级批量汇总。 */
|
||||||
|
class EpisodeServiceK89Test {
|
||||||
|
|
||||||
|
private DramaEpisodeMapper episodeMapper;
|
||||||
|
private EpisodeService episodeService;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void initTableInfo() {
|
||||||
|
TableInfoHelper.initTableInfo(
|
||||||
|
new MapperBuilderAssistant(new MybatisConfiguration(), ""), DramaEpisode.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
episodeMapper = mock(DramaEpisodeMapper.class);
|
||||||
|
episodeService = new EpisodeService(episodeMapper, mock(DramaService.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
void should_use_greatest_zero_when_episode_like_decrements() {
|
||||||
|
given(episodeMapper.update(isNull(), any())).willReturn(1);
|
||||||
|
ArgumentCaptor<Wrapper<DramaEpisode>> captor = ArgumentCaptor.forClass(Wrapper.class);
|
||||||
|
|
||||||
|
episodeService.adjustLikeCount(11L, -1);
|
||||||
|
|
||||||
|
verify(episodeMapper).update(isNull(), captor.capture());
|
||||||
|
LambdaUpdateWrapper<DramaEpisode> update =
|
||||||
|
(LambdaUpdateWrapper<DramaEpisode>) captor.getValue();
|
||||||
|
assertThat(update.getSqlSet()).contains("GREATEST(like_count - 1, 0)");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_update_episode_like_count_without_overwriting_when_null() {
|
||||||
|
DramaEpisode episode = new DramaEpisode();
|
||||||
|
episode.setId(11L);
|
||||||
|
episode.setDramaId(5L);
|
||||||
|
episode.setEpNo(1);
|
||||||
|
episode.setLikeCount(8L);
|
||||||
|
given(episodeMapper.selectById(11L)).willReturn(episode);
|
||||||
|
EpisodeSaveReqVO req = new EpisodeSaveReqVO();
|
||||||
|
req.setDramaId(5L);
|
||||||
|
req.setNumber(1);
|
||||||
|
req.setLikeCount(20L);
|
||||||
|
|
||||||
|
episodeService.update(11L, req);
|
||||||
|
|
||||||
|
assertThat(episode.getLikeCount()).isEqualTo(20L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_reject_negative_episode_like_count() {
|
||||||
|
DramaEpisode episode = new DramaEpisode();
|
||||||
|
episode.setId(11L);
|
||||||
|
episode.setDramaId(5L);
|
||||||
|
episode.setEpNo(1);
|
||||||
|
given(episodeMapper.selectById(11L)).willReturn(episode);
|
||||||
|
EpisodeSaveReqVO req = new EpisodeSaveReqVO();
|
||||||
|
req.setDramaId(5L);
|
||||||
|
req.setNumber(1);
|
||||||
|
req.setLikeCount(-1L);
|
||||||
|
|
||||||
|
assertThatThrownBy(() -> episodeService.update(11L, req))
|
||||||
|
.isInstanceOf(ServiceException.class)
|
||||||
|
.satisfies(error -> assertThat(((ServiceException) error).getCode())
|
||||||
|
.isEqualTo(ErrorCode.BAD_REQUEST.getCode()));
|
||||||
|
verify(episodeMapper, never()).updateById(any(DramaEpisode.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_sum_episode_likes_by_drama() {
|
||||||
|
given(episodeMapper.selectMaps(any())).willReturn(List.of(
|
||||||
|
Map.of("drama_id", 5L, "like_count", 120L),
|
||||||
|
Map.of("drama_id", 6L, "like_count", 30L)));
|
||||||
|
|
||||||
|
Map<Long, Long> sums = episodeService.sumLikeCountsByDramas(List.of(5L, 6L));
|
||||||
|
|
||||||
|
assertThat(sums).containsEntry(5L, 120L).containsEntry(6L, 30L);
|
||||||
|
}
|
||||||
|
}
|
||||||
+112
@@ -0,0 +1,112 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
package com.fruitshorts.interaction.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||||
|
import com.fruitshorts.common.exception.ErrorCode;
|
||||||
|
import com.fruitshorts.common.exception.ServiceException;
|
||||||
|
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.dal.entity.ContentLike;
|
||||||
|
import com.fruitshorts.interaction.dal.mapper.ContentCommentMapper;
|
||||||
|
import com.fruitshorts.interaction.dal.mapper.ContentLikeMapper;
|
||||||
|
import com.fruitshorts.interaction.vo.LikeToggleReqVO;
|
||||||
|
import com.fruitshorts.interaction.vo.LikeToggleRespVO;
|
||||||
|
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 static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/** K89:点赞目标支持已上线的分集。 */
|
||||||
|
class LikeServiceEpisodeTest {
|
||||||
|
|
||||||
|
private ContentLikeMapper likeMapper;
|
||||||
|
private EpisodeService episodeService;
|
||||||
|
private DramaService dramaService;
|
||||||
|
private LikeService likeService;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void initTableInfo() {
|
||||||
|
TableInfoHelper.initTableInfo(
|
||||||
|
new MapperBuilderAssistant(new MybatisConfiguration(), ""), ContentLike.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
likeMapper = mock(ContentLikeMapper.class);
|
||||||
|
episodeService = mock(EpisodeService.class);
|
||||||
|
dramaService = mock(DramaService.class);
|
||||||
|
likeService = new LikeService(
|
||||||
|
likeMapper,
|
||||||
|
mock(ContentCommentMapper.class),
|
||||||
|
dramaService,
|
||||||
|
episodeService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_increment_episode_like_and_return_latest_count() {
|
||||||
|
DramaEpisode published = episode(6L);
|
||||||
|
given(episodeService.getPublished(11L)).willReturn(published);
|
||||||
|
given(dramaService.getPublished(5L)).willReturn(new Drama());
|
||||||
|
given(likeMapper.selectOne(any())).willReturn(null);
|
||||||
|
given(episodeService.getExisting(11L)).willReturn(published);
|
||||||
|
|
||||||
|
LikeToggleRespVO result = likeService.toggle(9L, request(11L));
|
||||||
|
|
||||||
|
assertThat(result.getLiked()).isTrue();
|
||||||
|
assertThat(result.getCount()).isEqualTo(6L);
|
||||||
|
verify(episodeService).adjustLikeCount(11L, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_decrement_episode_like_when_cancelled() {
|
||||||
|
DramaEpisode published = episode(5L);
|
||||||
|
given(episodeService.getPublished(11L)).willReturn(published);
|
||||||
|
given(dramaService.getPublished(5L)).willReturn(new Drama());
|
||||||
|
given(likeMapper.selectOne(any())).willReturn(new ContentLike());
|
||||||
|
given(episodeService.getExisting(11L)).willReturn(published);
|
||||||
|
|
||||||
|
LikeToggleRespVO result = likeService.toggle(9L, request(11L));
|
||||||
|
|
||||||
|
assertThat(result.getLiked()).isFalse();
|
||||||
|
assertThat(result.getCount()).isEqualTo(5L);
|
||||||
|
verify(likeMapper).physicalDelete(9L, LikeService.TYPE_EPISODE, 11L);
|
||||||
|
verify(episodeService).adjustLikeCount(11L, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_reject_missing_or_unpublished_episode() {
|
||||||
|
given(episodeService.getPublished(11L))
|
||||||
|
.willThrow(new ServiceException(ErrorCode.DATA_NOT_FOUND, "剧集不存在或未上线"));
|
||||||
|
|
||||||
|
assertThatThrownBy(() -> likeService.toggle(9L, request(11L)))
|
||||||
|
.isInstanceOf(ServiceException.class);
|
||||||
|
verify(likeMapper, never()).insert(any(ContentLike.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
private DramaEpisode episode(Long likeCount) {
|
||||||
|
DramaEpisode episode = new DramaEpisode();
|
||||||
|
episode.setId(11L);
|
||||||
|
episode.setDramaId(5L);
|
||||||
|
episode.setLikeCount(likeCount);
|
||||||
|
return episode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private LikeToggleReqVO request(Long episodeId) {
|
||||||
|
LikeToggleReqVO req = new LikeToggleReqVO();
|
||||||
|
req.setTargetType(LikeService.TYPE_EPISODE);
|
||||||
|
req.setTargetId(episodeId);
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
}
|
||||||
+80
@@ -0,0 +1,80 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
package com.fruitshorts.playback.service;
|
||||||
|
|
||||||
|
import com.fruitshorts.content.service.DramaService;
|
||||||
|
import com.fruitshorts.playback.dal.entity.UserFavorite;
|
||||||
|
import com.fruitshorts.playback.dal.mapper.UserFavoriteMapper;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
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 FavoriteServiceTest {
|
||||||
|
|
||||||
|
private UserFavoriteMapper favoriteMapper;
|
||||||
|
private DramaService dramaService;
|
||||||
|
private FavoriteService favoriteService;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
favoriteMapper = mock(UserFavoriteMapper.class);
|
||||||
|
dramaService = mock(DramaService.class);
|
||||||
|
favoriteService = new FavoriteService(favoriteMapper, dramaService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_increment_favorite_count_when_new_favorite_is_created() {
|
||||||
|
given(favoriteMapper.selectOne(any())).willReturn(null);
|
||||||
|
given(favoriteMapper.insert(any(UserFavorite.class))).willReturn(1);
|
||||||
|
|
||||||
|
boolean favorite = favoriteService.toggle(1L, 7L);
|
||||||
|
|
||||||
|
assertThat(favorite).isTrue();
|
||||||
|
verify(dramaService).adjustFavoriteCount(7L, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_decrement_favorite_count_when_toggle_removes_relation() {
|
||||||
|
given(favoriteMapper.selectOne(any())).willReturn(new UserFavorite());
|
||||||
|
given(favoriteMapper.physicalDelete(1L, 7L)).willReturn(1);
|
||||||
|
|
||||||
|
boolean favorite = favoriteService.toggle(1L, 7L);
|
||||||
|
|
||||||
|
assertThat(favorite).isFalse();
|
||||||
|
verify(dramaService).adjustFavoriteCount(7L, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_only_decrement_when_remove_actually_deletes_relation() {
|
||||||
|
given(favoriteMapper.physicalDelete(1L, 7L)).willReturn(1);
|
||||||
|
given(favoriteMapper.physicalDelete(1L, 8L)).willReturn(0);
|
||||||
|
|
||||||
|
favoriteService.remove(1L, 7L);
|
||||||
|
favoriteService.remove(1L, 8L);
|
||||||
|
|
||||||
|
verify(dramaService).adjustFavoriteCount(7L, -1);
|
||||||
|
verify(dramaService, never()).adjustFavoriteCount(8L, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_decrement_each_deleted_drama_when_batch_remove_is_called() {
|
||||||
|
given(favoriteMapper.physicalDelete(1L, 7L)).willReturn(1);
|
||||||
|
given(favoriteMapper.physicalDelete(1L, 8L)).willReturn(0);
|
||||||
|
given(favoriteMapper.physicalDelete(1L, 9L)).willReturn(1);
|
||||||
|
|
||||||
|
favoriteService.removeBatch(1L, Arrays.asList(7L, 8L, 9L, null));
|
||||||
|
|
||||||
|
verify(dramaService).adjustFavoriteCount(7L, -1);
|
||||||
|
verify(dramaService, never()).adjustFavoriteCount(8L, -1);
|
||||||
|
verify(dramaService).adjustFavoriteCount(9L, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -66,5 +66,19 @@
|
|||||||
<groupId>org.springdoc</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 监控:暴露 actuator 指标供 Prometheus 抓取 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.micrometer</groupId>
|
||||||
|
<artifactId>micrometer-registry-prometheus</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
package com.fruitshorts.framework.redis;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接口级固定窗口限流。基于 Redis INCR,key 按客户端 IP 维度隔离。
|
||||||
|
*/
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface RateLimit {
|
||||||
|
|
||||||
|
/** 窗口内允许的最大请求次数。 */
|
||||||
|
int limit() default 10;
|
||||||
|
|
||||||
|
/** 窗口时长(秒)。 */
|
||||||
|
int windowSeconds() default 60;
|
||||||
|
|
||||||
|
/** 限流维度前缀,默认取方法名。 */
|
||||||
|
String key() default "";
|
||||||
|
}
|
||||||
+54
@@ -0,0 +1,54 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
package com.fruitshorts.framework.redis;
|
||||||
|
|
||||||
|
import com.fruitshorts.common.exception.ErrorCode;
|
||||||
|
import com.fruitshorts.common.exception.ServiceException;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.annotation.Before;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 固定窗口限流切面:每次命中注解先 INCR,超阈值即拒绝。
|
||||||
|
*/
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RateLimitAspect {
|
||||||
|
|
||||||
|
private final RedisService redisService;
|
||||||
|
|
||||||
|
@Before("@annotation(rateLimit)")
|
||||||
|
public void check(RateLimit rateLimit) {
|
||||||
|
long count = redisService.increment(
|
||||||
|
buildKey(rateLimit), Duration.ofSeconds(rateLimit.windowSeconds()));
|
||||||
|
if (count > rateLimit.limit()) {
|
||||||
|
throw new ServiceException(ErrorCode.TOO_MANY_REQUESTS, "请求过于频繁,请稍后再试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildKey(RateLimit rateLimit) {
|
||||||
|
String scope = rateLimit.key().isBlank() ? "default" : rateLimit.key();
|
||||||
|
return "rate:" + scope + ":" + clientIp();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String clientIp() {
|
||||||
|
ServletRequestAttributes attrs =
|
||||||
|
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
if (attrs == null) {
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
HttpServletRequest request = attrs.getRequest();
|
||||||
|
String forwarded = request.getHeader("X-Forwarded-For");
|
||||||
|
if (forwarded != null && !forwarded.isBlank()) {
|
||||||
|
return forwarded.split(",")[0].trim();
|
||||||
|
}
|
||||||
|
return request.getRemoteAddr();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
package com.fruitshorts.framework.redis;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redis 字符串操作封装,供缓存与限流复用。
|
||||||
|
* 统一在这里兜底过期策略,业务侧不直接接触 RedisTemplate。
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RedisService {
|
||||||
|
|
||||||
|
private final StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
public void set(String key, String value, Duration ttl) {
|
||||||
|
redisTemplate.opsForValue().set(key, value, ttl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get(String key) {
|
||||||
|
return redisTemplate.opsForValue().get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(String key) {
|
||||||
|
redisTemplate.delete(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 固定窗口计数:自增并保证首次写入时设置过期时间。
|
||||||
|
* 用于接口限流,返回当前窗口内的累计次数。
|
||||||
|
*/
|
||||||
|
public long increment(String key, Duration window) {
|
||||||
|
Long count = redisTemplate.opsForValue().increment(key);
|
||||||
|
long value = count == null ? 1 : count;
|
||||||
|
if (value == 1) {
|
||||||
|
redisTemplate.expire(key, window);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-2
@@ -36,6 +36,7 @@ public class SecurityConfig {
|
|||||||
"/app/auth/**",
|
"/app/auth/**",
|
||||||
"/app/home/**",
|
"/app/home/**",
|
||||||
"/app/discover/**",
|
"/app/discover/**",
|
||||||
|
"/app/feed",
|
||||||
"/app/categories/**",
|
"/app/categories/**",
|
||||||
"/app/banners/**",
|
"/app/banners/**",
|
||||||
"/app/dramas/**",
|
"/app/dramas/**",
|
||||||
@@ -44,6 +45,8 @@ public class SecurityConfig {
|
|||||||
/* 启动配置与公告:客户端登录前就要拿(POST /app/creator/apply 等仍要登录) */
|
/* 启动配置与公告:客户端登录前就要拿(POST /app/creator/apply 等仍要登录) */
|
||||||
"/app/config",
|
"/app/config",
|
||||||
"/app/notices",
|
"/app/notices",
|
||||||
|
/* 埋点上报:游客浏览也要记录,匿名可访问 */
|
||||||
|
"/app/events",
|
||||||
/* 媒资:封面与视频用 <img>/<video> 直接访问,无法带请求头。
|
/* 媒资:封面与视频用 <img>/<video> 直接访问,无法带请求头。
|
||||||
片源的防盗链由 fruitshorts.media.signature-required 控制。 */
|
片源的防盗链由 fruitshorts.media.signature-required 控制。 */
|
||||||
"/files/**",
|
"/files/**",
|
||||||
@@ -51,9 +54,10 @@ public class SecurityConfig {
|
|||||||
"/swagger-ui/**",
|
"/swagger-ui/**",
|
||||||
"/swagger-ui.html",
|
"/swagger-ui.html",
|
||||||
"/v3/api-docs/**",
|
"/v3/api-docs/**",
|
||||||
/* 健康检查:给容器编排与冒烟脚本用(本项目没引 actuator,见 HealthController 注释) */
|
/* 健康检查与监控:/actuator/health 给容器编排,/actuator/prometheus 给 Prometheus 抓取指标 */
|
||||||
"/healthz",
|
"/healthz",
|
||||||
"/actuator/health"
|
"/actuator/health",
|
||||||
|
"/actuator/prometheus"
|
||||||
};
|
};
|
||||||
|
|
||||||
private final JwtAuthenticationFilter jwtAuthenticationFilter;
|
private final JwtAuthenticationFilter jwtAuthenticationFilter;
|
||||||
@@ -71,6 +75,7 @@ public class SecurityConfig {
|
|||||||
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
||||||
/* 评论列表允许匿名浏览;发布/删除仍需登录(未列入白名单即需鉴权) */
|
/* 评论列表允许匿名浏览;发布/删除仍需登录(未列入白名单即需鉴权) */
|
||||||
.requestMatchers(HttpMethod.GET, "/app/comments").permitAll()
|
.requestMatchers(HttpMethod.GET, "/app/comments").permitAll()
|
||||||
|
.requestMatchers(HttpMethod.GET, "/app/comments/count").permitAll()
|
||||||
.requestMatchers(PUBLIC_PATHS).permitAll()
|
.requestMatchers(PUBLIC_PATHS).permitAll()
|
||||||
.anyRequest().authenticated())
|
.anyRequest().authenticated())
|
||||||
.exceptionHandling(handling -> handling
|
.exceptionHandling(handling -> handling
|
||||||
|
|||||||
+10
@@ -37,6 +37,7 @@ public class EntitlementService implements EntitlementPort {
|
|||||||
|
|
||||||
public static final String TYPE_EPISODE = "EPISODE";
|
public static final String TYPE_EPISODE = "EPISODE";
|
||||||
public static final String TYPE_DRAMA = "DRAMA";
|
public static final String TYPE_DRAMA = "DRAMA";
|
||||||
|
public static final String TYPE_VIP = "VIP";
|
||||||
|
|
||||||
private final EntitlementMapper entitlementMapper;
|
private final EntitlementMapper entitlementMapper;
|
||||||
|
|
||||||
@@ -46,6 +47,15 @@ public class EntitlementService implements EntitlementPort {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
Long vipCount = entitlementMapper.selectCount(Wrappers.<Entitlement>lambdaQuery()
|
||||||
|
.eq(Entitlement::getUserId, userId)
|
||||||
|
.eq(Entitlement::getStatus, STATUS_ACTIVE)
|
||||||
|
.eq(Entitlement::getType, TYPE_VIP)
|
||||||
|
.and(w -> w.isNull(Entitlement::getExpireAt)
|
||||||
|
.or().gt(Entitlement::getExpireAt, now)));
|
||||||
|
if (vipCount != null && vipCount > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Long count = entitlementMapper.selectCount(Wrappers.<Entitlement>lambdaQuery()
|
Long count = entitlementMapper.selectCount(Wrappers.<Entitlement>lambdaQuery()
|
||||||
.eq(Entitlement::getUserId, userId)
|
.eq(Entitlement::getUserId, userId)
|
||||||
.eq(Entitlement::getStatus, STATUS_ACTIVE)
|
.eq(Entitlement::getStatus, STATUS_ACTIVE)
|
||||||
|
|||||||
+47
@@ -93,6 +93,49 @@ public class OrderService {
|
|||||||
.orderByDesc(OrderEvent::getId));
|
.orderByDesc(OrderEvent::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户端创建充值订单:按商品配置生成一笔 CREATED 订单,等待后续支付。
|
||||||
|
*
|
||||||
|
* <p>商品必须处于上架状态;金币数量按 coinAmount + bonusCoin 计算,
|
||||||
|
* 与商店票据链路 {@link #buildOrder} 的口径一致,交付时一次性到账。
|
||||||
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Orders createOrder(Long userId, Long productId) {
|
||||||
|
if (userId == null) {
|
||||||
|
throw new ServiceException(ErrorCode.UNAUTHORIZED);
|
||||||
|
}
|
||||||
|
Product product = productService.getExisting(productId);
|
||||||
|
if (product.getStatus() == null || product.getStatus() != 1) {
|
||||||
|
throw new ServiceException(ErrorCode.BAD_REQUEST, "商品已下架");
|
||||||
|
}
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
Orders order = new Orders();
|
||||||
|
order.setOrderNo(newOrderNo());
|
||||||
|
order.setUserId(userId);
|
||||||
|
order.setProductId(product.getId());
|
||||||
|
order.setProductCode(product.getCode());
|
||||||
|
order.setProductName(product.getName());
|
||||||
|
order.setType(StringUtils.hasText(product.getType()) ? product.getType() : ProductService.TYPE_COIN);
|
||||||
|
order.setPlatform(product.getPlatform());
|
||||||
|
order.setStoreProductId(product.getStoreProductId());
|
||||||
|
long coins = (product.getCoinAmount() == null ? 0L : product.getCoinAmount())
|
||||||
|
+ (product.getBonusCoin() == null ? 0L : product.getBonusCoin());
|
||||||
|
order.setCoinAmount(coins);
|
||||||
|
order.setAmount(product.getPriceAmount() == null ? BigDecimal.ZERO : product.getPriceAmount());
|
||||||
|
order.setCurrency(StringUtils.hasText(product.getCurrency()) ? product.getCurrency() : "IDR");
|
||||||
|
order.setQuantity(1);
|
||||||
|
order.setStatus(STATUS_CREATED);
|
||||||
|
order.setRegionCode("ID");
|
||||||
|
order.setChannel("IAP");
|
||||||
|
order.setExperimentId("");
|
||||||
|
order.setReceipt("");
|
||||||
|
order.setFailReason("");
|
||||||
|
order.setRefundReason("");
|
||||||
|
order.setCreatedAt(now);
|
||||||
|
ordersMapper.insert(order);
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端提交商店票据:**校验 → 建单 → 发权益**,一步都不能省。
|
* 客户端提交商店票据:**校验 → 建单 → 发权益**,一步都不能省。
|
||||||
*
|
*
|
||||||
@@ -273,6 +316,10 @@ public class OrderService {
|
|||||||
order.getOrderNo(), "order:" + order.getOrderNo() + ":coins",
|
order.getOrderNo(), "order:" + order.getOrderNo() + ":coins",
|
||||||
remark + ":" + order.getProductName(), true, operatorId);
|
remark + ":" + order.getProductName(), true, operatorId);
|
||||||
}
|
}
|
||||||
|
if (ProductService.TYPE_VIP.equals(order.getType())) {
|
||||||
|
entitlementService.grant(order.getUserId(), 0L, 0L,
|
||||||
|
EntitlementService.TYPE_VIP, "ORDER", order.getOrderNo());
|
||||||
|
}
|
||||||
order.setStatus(STATUS_DELIVERED);
|
order.setStatus(STATUS_DELIVERED);
|
||||||
order.setDeliveredAt(LocalDateTime.now());
|
order.setDeliveredAt(LocalDateTime.now());
|
||||||
order.setFailReason("");
|
order.setFailReason("");
|
||||||
|
|||||||
+15
-15
@@ -30,7 +30,7 @@ import java.util.List;
|
|||||||
* <li>`store_product_id` 在**同一 `platform` 下唯一** —— 否则同一商店商品被配置成两个商品,
|
* <li>`store_product_id` 在**同一 `platform` 下唯一** —— 否则同一商店商品被配置成两个商品,
|
||||||
* 客户端 verify 时"按 storeProductId 找到第一个"会随机发其中一个的金币;</li>
|
* 客户端 verify 时"按 storeProductId 找到第一个"会随机发其中一个的金币;</li>
|
||||||
* <li>`type=COIN_PACK` 要求 `coin_amount > 0`;`type=VIP` 要求 `vip_days > 0`;</li>
|
* <li>`type=COIN_PACK` 要求 `coin_amount > 0`;`type=VIP` 要求 `vip_days > 0`;</li>
|
||||||
* <li>**VIP 允许建档、不允许启用**(与 B1-1「VIP 订阅本轮不做」一致)。</li>
|
* <li>**VIP 允许建档、允许启用**(会员商品随金币包一起上架售卖)。</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@@ -64,6 +64,17 @@ public class ProductService {
|
|||||||
return ProductRespVO.of(getExisting(id));
|
return ProductRespVO.of(getExisting(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** C 端商品列表:只返回上架商品,type 可选过滤(自动归一化为大写)。 */
|
||||||
|
public List<ProductRespVO> listForApp(String type) {
|
||||||
|
String normalized = StringUtils.hasText(type) ? type.trim().toUpperCase() : null;
|
||||||
|
List<Product> records = productMapper.selectList(Wrappers.<Product>lambdaQuery()
|
||||||
|
.eq(Product::getStatus, 1)
|
||||||
|
.eq(normalized != null, Product::getType, normalized)
|
||||||
|
.orderByAsc(Product::getSort)
|
||||||
|
.orderByDesc(Product::getId));
|
||||||
|
return records.stream().map(ProductRespVO::of).toList();
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long create(ProductSaveReqVO req) {
|
public Long create(ProductSaveReqVO req) {
|
||||||
String code = req.getCode().trim();
|
String code = req.getCode().trim();
|
||||||
@@ -77,7 +88,6 @@ public class ProductService {
|
|||||||
applyFields(product, req, platform);
|
applyFields(product, req, platform);
|
||||||
// 新建默认下架:上架是显式动作,避免半配置的商品立刻对客户端可见
|
// 新建默认下架:上架是显式动作,避免半配置的商品立刻对客户端可见
|
||||||
product.setStatus(req.getStatus() == null ? 0 : req.getStatus());
|
product.setStatus(req.getStatus() == null ? 0 : req.getStatus());
|
||||||
requireVipNotEnabled(product);
|
|
||||||
productMapper.insert(product);
|
productMapper.insert(product);
|
||||||
return product.getId();
|
return product.getId();
|
||||||
}
|
}
|
||||||
@@ -96,11 +106,10 @@ public class ProductService {
|
|||||||
if (req.getStatus() != null) {
|
if (req.getStatus() != null) {
|
||||||
product.setStatus(req.getStatus());
|
product.setStatus(req.getStatus());
|
||||||
}
|
}
|
||||||
requireVipNotEnabled(product);
|
|
||||||
productMapper.updateById(product);
|
productMapper.updateById(product);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 上架 / 下架;VIP 商品只允许下架(第二阶段订阅上线后才放开)。 */
|
/** 上架 / 下架。 */
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateStatus(Long id, Integer status) {
|
public void updateStatus(Long id, Integer status) {
|
||||||
if (status == null || (status != 0 && status != 1)) {
|
if (status == null || (status != 0 && status != 1)) {
|
||||||
@@ -108,7 +117,6 @@ public class ProductService {
|
|||||||
}
|
}
|
||||||
Product product = getExisting(id);
|
Product product = getExisting(id);
|
||||||
product.setStatus(status);
|
product.setStatus(status);
|
||||||
requireVipNotEnabled(product);
|
|
||||||
productMapper.updateById(product);
|
productMapper.updateById(product);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,15 +169,6 @@ public class ProductService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** VIP 商品在订阅功能上线前不能启用(允许建档)。 */
|
|
||||||
private void requireVipNotEnabled(Product product) {
|
|
||||||
boolean enabled = product.getStatus() != null && product.getStatus() == 1;
|
|
||||||
if (enabled && TYPE_VIP.equals(product.getType())) {
|
|
||||||
throw new ServiceException(ErrorCode.BAD_REQUEST,
|
|
||||||
"会员商品在订阅功能上线前不能启用(可先建档,上线后再上下架)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void requireCodeFree(String code, Long excludeId) {
|
private void requireCodeFree(String code, Long excludeId) {
|
||||||
Long count = productMapper.selectCount(Wrappers.<Product>lambdaQuery()
|
Long count = productMapper.selectCount(Wrappers.<Product>lambdaQuery()
|
||||||
.eq(Product::getCode, code)
|
.eq(Product::getCode, code)
|
||||||
@@ -198,7 +197,8 @@ public class ProductService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Product getExisting(Long id) {
|
/** 按 id 取商品,不存在抛业务异常(供订单创建链路复用)。 */
|
||||||
|
public Product getExisting(Long id) {
|
||||||
Product product = id == null ? null : productMapper.selectById(id);
|
Product product = id == null ? null : productMapper.selectById(id);
|
||||||
if (product == null) {
|
if (product == null) {
|
||||||
throw new ServiceException(ErrorCode.DATA_NOT_FOUND, "商品不存在");
|
throw new ServiceException(ErrorCode.DATA_NOT_FOUND, "商品不存在");
|
||||||
|
|||||||
+6
-6
@@ -28,7 +28,7 @@ import static org.mockito.Mockito.verify;
|
|||||||
* 商品配置的业务校验。
|
* 商品配置的业务校验。
|
||||||
*
|
*
|
||||||
* <p>这几条直接决定 C 端发币口径,必须在服务端拦住(前端校验只是体验):
|
* <p>这几条直接决定 C 端发币口径,必须在服务端拦住(前端校验只是体验):
|
||||||
* `code` 唯一、`store_product_id` 同平台唯一、type 与金额/天数匹配、VIP 不允许启用。
|
* `code` 唯一、`store_product_id` 同平台唯一、type 与金额/天数匹配、VIP 允许启用。
|
||||||
*/
|
*/
|
||||||
class ProductServiceTest {
|
class ProductServiceTest {
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ class ProductServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_allow_creating_vip_but_reject_enabling_it() {
|
void should_allow_creating_and_enabling_vip() {
|
||||||
given(productMapper.selectCount(any())).willReturn(0L);
|
given(productMapper.selectCount(any())).willReturn(0L);
|
||||||
AtomicReference<Product> saved = captureInsert();
|
AtomicReference<Product> saved = captureInsert();
|
||||||
ProductSaveReqVO req = coinPack("vip_year", "vip_year");
|
ProductSaveReqVO req = coinPack("vip_year", "vip_year");
|
||||||
@@ -109,12 +109,12 @@ class ProductServiceTest {
|
|||||||
assertThat(saved.get().getType()).isEqualTo("VIP");
|
assertThat(saved.get().getType()).isEqualTo("VIP");
|
||||||
assertThat(saved.get().getStatus()).isZero();
|
assertThat(saved.get().getStatus()).isZero();
|
||||||
|
|
||||||
// 但不允许启用
|
// 也允许上架(会员商品随金币包一起售卖)
|
||||||
Product existing = saved.get();
|
Product existing = saved.get();
|
||||||
given(productMapper.selectById(any())).willReturn(existing);
|
given(productMapper.selectById(any())).willReturn(existing);
|
||||||
assertThatThrownBy(() -> productService.updateStatus(existing.getId(), 1))
|
productService.updateStatus(existing.getId(), 1);
|
||||||
.isInstanceOf(ServiceException.class)
|
assertThat(existing.getStatus()).isEqualTo(1);
|
||||||
.hasMessageContaining("会员商品在订阅功能上线前不能启用");
|
verify(productMapper).updateById(existing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -25,5 +25,10 @@
|
|||||||
<groupId>com.fruitshorts</groupId>
|
<groupId>com.fruitshorts</groupId>
|
||||||
<artifactId>fruitshorts-module-system</artifactId>
|
<artifactId>fruitshorts-module-system</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -22,11 +22,17 @@ public class Drama {
|
|||||||
private String title;
|
private String title;
|
||||||
private String subtitle;
|
private String subtitle;
|
||||||
private Long categoryId;
|
private Long categoryId;
|
||||||
|
/** 分类多选,逗号分隔的 category_id,category_id 保留第一个 */
|
||||||
|
private String categoryIds;
|
||||||
private String genre;
|
private String genre;
|
||||||
private String synopsis;
|
private String synopsis;
|
||||||
private String coverUrl;
|
private String coverUrl;
|
||||||
private String horizontalCoverUrl;
|
private String horizontalCoverUrl;
|
||||||
private String language;
|
private String language;
|
||||||
|
/** 内容类型:ANIME=漫剧,LIVE=真人剧 */
|
||||||
|
private String dramaType;
|
||||||
|
/** 内容类型多选,逗号分隔(ANIME/LIVE),drama_type 保留第一个 */
|
||||||
|
private String dramaTypes;
|
||||||
private Integer totalEpisodes;
|
private Integer totalEpisodes;
|
||||||
private Integer freeEpisodes;
|
private Integer freeEpisodes;
|
||||||
private Integer unlockCoin;
|
private Integer unlockCoin;
|
||||||
|
|||||||
+2
@@ -40,6 +40,8 @@ public class DramaEpisode {
|
|||||||
private String status;
|
private String status;
|
||||||
private LocalDateTime releaseAt;
|
private LocalDateTime releaseAt;
|
||||||
private Long playCount;
|
private Long playCount;
|
||||||
|
/** 本集点赞数(点赞目标为 EPISODE) */
|
||||||
|
private Long likeCount;
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
private LocalDateTime createdAt;
|
private LocalDateTime createdAt;
|
||||||
/** updated_at 交给数据库的 ON UPDATE CURRENT_TIMESTAMP 维护 */
|
/** updated_at 交给数据库的 ON UPDATE CURRENT_TIMESTAMP 维护 */
|
||||||
|
|||||||
Loaded 100 of 141 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user