safe()->except(['system', 'page', 'per_page']); $filters['system'] = $request->boolean('system'); return ChannelResource::collection($this->channels->listPublic( $filters, $this->currentUserUid($request), $request->integer('per_page', 20), )); } /** * channel 详情 * * 公开的谁都能看;私有的只有拥有者、团队成员、被共享的人能看。带查看者的 `abilities`。 * * @unauthenticated * * @urlParam channel string required channel uid * * @responseStatus 403 私有 channel,且看不见 */ public function show(Request $request, Channel $channel) { return ChannelResource::make($this->channels->show($channel, $this->currentUserUid($request))); } /** * 改 channel 信息 * * 只改传了的字段。拥有者;团队的 channel 由团队 owner / manager / editor 改;共享权限 ≥30 也能改。 * 系统 channel 不能改。AI 模型不能改。 * * @urlParam channel string required channel uid * * @bodyParam name string 名字,最长 128;同一 studio 内不能重名 * @bodyParam type string 类型。Enum: translation,nissaya,original,wbw,commentary,similar * @bodyParam lang string 语言,最长 16 * @bodyParam summary string 简介,最长 1024 * @bodyParam status integer 10 私有、20 公开不列出(拿到链接能看,不进任何公开列表)、30 公开 * @bodyParam source_type string 来源。Enum: original,reprint,ai * @bodyParam source_id string 来源 id * @bodyParam config object 配置 * * @responseStatus 403 不能修改 */ public function update(UpdateChannelRequest $request, Channel $channel) { return ChannelResource::make($this->channels->update( $channel, $this->currentUser($request)['user_uid'], $request->validated(), )); } /** * 删除 channel * * 软删除,返回被删的 channel。个人 channel 由拥有者删,团队的只有团队 owner 能删。 * channel 下已有译文、术语或逐词时拒绝(409,`content` 列出有哪几类)。系统 channel 不能删。 * * @urlParam channel string required channel uid * * @responseStatus 403 不能删除 * @responseStatus 409 channel 下还有内容 */ public function destroy(Request $request, Channel $channel) { return ChannelResource::make($this->channels->delete( $channel, $this->currentUser($request)['user_uid'], )); } }