refactor(app-api): 按新口径撤除 App 侧创作者中心的 works / stats
为什么:用户口径变更「创作者中心是 web 端,和 app 客户端没关系」,契约已由 PM 提交 bb21920
移除两条 C 端定义;本提交把代码对齐到新契约,App 侧创作者相关只保留入驻申请。
- 删除 GET /app/creator/works、GET /app/creator/stats 两个端点及无用注入
- 删除 CreatorStatsService.java(213 行,与后台 07 看板重复的独立实现)
- 删除随之成为死代码的:CreatorAppService.requireActiveCreator / myWorks、
CreatorCenterService.pageMyDramasOf、ErrorCode.CREATOR_NOT_ACTIVE(200007)
- 删除对应测试 7 条(works/stats 契约 4 条 + requireActive 3 条);
保留 apply 幂等与协议版本校验、config 白名单、notices 空列表
- 不动 POST /app/creator/apply、GET /app/config、GET /app/notices;不改 docs/api-phase1.md
- 实测:mvn test 98 → 91 条全过;package 通过;/v3/api-docs 接口数 41 → 39,
creator 相关只剩 /app/creator/apply;两个已撤除路径对已登录客户端返回 404
This commit is contained in:
1 parent
bb219203bc
commit
4418a840ec
7 files changed
+23
-422
No files matched your search
+6
-40
@@ -5,13 +5,10 @@ package com.fruitshorts.creator.service;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.fruitshorts.common.exception.ErrorCode;
|
||||
import com.fruitshorts.common.exception.ServiceException;
|
||||
import com.fruitshorts.common.pojo.PageResult;
|
||||
import com.fruitshorts.creator.dal.entity.Creator;
|
||||
import com.fruitshorts.creator.dal.mapper.CreatorMapper;
|
||||
import com.fruitshorts.creator.vo.CreatorApplyReqVO;
|
||||
import com.fruitshorts.creator.vo.CreatorApplyRespVO;
|
||||
import com.fruitshorts.creator.vo.CreatorCenterDramaQueryReqVO;
|
||||
import com.fruitshorts.creator.vo.CreatorCenterDramaVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
@@ -24,10 +21,13 @@ import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* C 端创作者入驻与作品(`/app/creator/**`)。
|
||||
* C 端创作者入驻(`POST /app/creator/apply`)。
|
||||
*
|
||||
* <p>与管理端创作者中心的关键区别:**归属按 `creator.user_id`(C 端账号)解析**,
|
||||
* 而管理端按 `creator.admin_user_id`(后台账号绑定)。两条链路互不影响,
|
||||
* <p>口径(2026-10-16 变更):**创作者中心由 Web 端承载**,App 侧只保留入驻申请 ——
|
||||
* 原来的"我的作品 / 数据看板"两条 C 端接口已按新契约撤除。
|
||||
*
|
||||
* <p>与管理端的关键区别:**归属按 `creator.user_id`(C 端账号)解析**,
|
||||
* 管理端按 `creator.admin_user_id`(后台账号绑定)。两条链路互不影响,
|
||||
* 这里**没有改动**管理端的入驻审核 / 开号 / 作品管理逻辑。
|
||||
*/
|
||||
@Slf4j
|
||||
@@ -36,7 +36,6 @@ import java.time.format.DateTimeFormatter;
|
||||
public class CreatorAppService {
|
||||
|
||||
private final CreatorMapper creatorMapper;
|
||||
private final CreatorCenterService creatorCenterService;
|
||||
|
||||
/**
|
||||
* 入驻申请(**幂等**)。
|
||||
@@ -103,39 +102,6 @@ public class CreatorAppService {
|
||||
.last("limit 1"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 要求当前 C 端账号是**生效中的创作者**,否则按状态给出明确错误(`200007`)。
|
||||
*
|
||||
* <p>刻意不返回空列表:客户端要能区分"没有作品"和"你还不是创作者"。
|
||||
*/
|
||||
public Creator requireActiveCreator(Long userId) {
|
||||
Creator creator = findByUserId(userId);
|
||||
if (creator == null) {
|
||||
throw new ServiceException(ErrorCode.CREATOR_NOT_ACTIVE, "尚未提交创作者入驻申请");
|
||||
}
|
||||
String status = creator.getStatus() == null ? "" : creator.getStatus();
|
||||
switch (status) {
|
||||
case CreatorService.STATUS_APPROVED -> {
|
||||
return creator;
|
||||
}
|
||||
case CreatorService.STATUS_PENDING -> throw new ServiceException(ErrorCode.CREATOR_NOT_ACTIVE,
|
||||
"入驻申请审核中,请耐心等待");
|
||||
case CreatorService.STATUS_REJECTED -> throw new ServiceException(ErrorCode.CREATOR_NOT_ACTIVE,
|
||||
"入驻申请未通过:" + (StringUtils.hasText(creator.getAuditNote())
|
||||
? creator.getAuditNote() : "可联系运营了解原因"));
|
||||
case CreatorService.STATUS_FROZEN -> throw new ServiceException(ErrorCode.CREATOR_NOT_ACTIVE,
|
||||
"创作者账号已冻结,请联系运营");
|
||||
default -> throw new ServiceException(ErrorCode.CREATOR_NOT_ACTIVE,
|
||||
"当前创作者状态不可用:" + status);
|
||||
}
|
||||
}
|
||||
|
||||
/** 我的作品(复用管理端创作者中心的查询与 VO 映射,口径一致)。 */
|
||||
public PageResult<CreatorCenterDramaVO> myWorks(Long userId, CreatorCenterDramaQueryReqVO req) {
|
||||
Creator creator = requireActiveCreator(userId);
|
||||
return creatorCenterService.pageMyDramasOf(creator, req);
|
||||
}
|
||||
|
||||
private CreatorApplyRespVO toResp(Creator creator, boolean created) {
|
||||
CreatorApplyRespVO vo = new CreatorApplyRespVO();
|
||||
vo.setId(creator.getId());
|
||||
|
||||
-19
@@ -171,25 +171,6 @@ public class CreatorCenterService {
|
||||
return new PageResult<>(result.getTotal(), toDramaVOList(creator.getId(), result.getRecords()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定创作者的作品分页(**C 端用**)。
|
||||
*
|
||||
* <p>与管理端 {@link #pageMyDramas} 共用同一套查询与 VO 映射,区别只在"创作者从哪来":
|
||||
* 管理端由后台账号绑定关系解析,C 端由 `creator.user_id`(C 端账号)解析。
|
||||
* 之所以单独开一个方法而不是把 creatorId 做成参数往上传:**不接受调用方传归属**,避免横向越权入口。
|
||||
*/
|
||||
public PageResult<CreatorCenterDramaVO> pageMyDramasOf(Creator creator,
|
||||
CreatorCenterDramaQueryReqVO req) {
|
||||
Page<Drama> page = new Page<>(req.getSafePageIndex(), req.getSafePageSize());
|
||||
IPage<Drama> result = dramaMapper.selectPage(page, Wrappers.<Drama>lambdaQuery()
|
||||
.eq(Drama::getCreatorId, creator.getId())
|
||||
.like(StringUtils.hasText(req.getKeyword()), Drama::getTitle, req.getKeyword())
|
||||
.eq(StringUtils.hasText(req.getStatus()), Drama::getStatus, req.getStatus())
|
||||
.orderByDesc(Drama::getUpdatedAt)
|
||||
.orderByDesc(Drama::getId));
|
||||
return new PageResult<>(result.getTotal(), toDramaVOList(creator.getId(), result.getRecords()));
|
||||
}
|
||||
|
||||
public CreatorCenterDramaVO myDramaDetail(Long dramaId) {
|
||||
Creator creator = requireCurrentCreator();
|
||||
Drama drama = requireMyDrama(dramaId);
|
||||
|
||||
Reference in new issue
Block a user