FastMovieAI AI短剧创作平台 二开基线
- 源码: xhadmincn/FastMovieAI (Apache 2.0) - 二开: Docker部署, Swoole改Select, route.php修复, 补update/VERSION - vendor/示例资源已gitignore
This commit is contained in:
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\admin\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
use plugin\shortplay\app\model\PluginShortplayActor;
|
||||
use plugin\shortplay\utils\enum\ActorAge;
|
||||
use plugin\shortplay\utils\enum\ActorGender;
|
||||
use plugin\shortplay\utils\enum\ActorSpeciesType;
|
||||
use plugin\shortplay\utils\enum\ActorStatus;
|
||||
use support\Request;
|
||||
|
||||
class ActorController extends Basic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new PluginShortplayActor;
|
||||
}
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder;
|
||||
$channelList = PluginChannelsUser::options();
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
$formBuilder->add('channels_uid', '渠道', 'select', '', [
|
||||
'options' => $channelList,
|
||||
'props' => [
|
||||
'placeholder' => '渠道搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('name', '名称', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '名称搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('actor_id', '演员ID', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '演员ID搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('channels', '渠道', [
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'channels.nickname',
|
||||
'avatar' => 'channels,headimg',
|
||||
'info' => 'channels.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'channels_uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('user', '用户', [
|
||||
'where' => [
|
||||
['uid', '!=', null]
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'user.nickname',
|
||||
'avatar' => 'user.headimg',
|
||||
'info' => 'user.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('actorinfo', '演员', [
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'name',
|
||||
'avatar' => 'headimg',
|
||||
'info' => 'actor_id',
|
||||
'preview' => true
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('three_view_image', '三视图', [
|
||||
'component' => [
|
||||
'name' => 'image',
|
||||
'props' => [
|
||||
'style' => 'width: 100px; height: 100px;',
|
||||
'fit' => 'cover'
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '133px'
|
||||
]
|
||||
]);
|
||||
$builder->add('species_type', '物种', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ActorSpeciesType::getOptions(),
|
||||
],
|
||||
'props' => [
|
||||
'width' => '180px'
|
||||
]
|
||||
]);
|
||||
$builder->add('gender', '性别', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ActorGender::getOptions(),
|
||||
],
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('age', '年龄', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ActorAge::getOptions(),
|
||||
],
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('status', '状态', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ActorStatus::getOptions(),
|
||||
],
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('remarks', '人物描述', [
|
||||
'props' => [
|
||||
'minWidth' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function query(Request $request)
|
||||
{
|
||||
$query = $request->post('query');
|
||||
if (empty($query)) {
|
||||
return $this->resData([]);
|
||||
}
|
||||
$where = [];
|
||||
$where[] = ['name|actor_id|remarks', 'like', "%{$query}%"];
|
||||
return $this->resData(PluginShortplayActor::options($where));
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$name = $request->get('name');
|
||||
if ($name) {
|
||||
$where[] = ['name', 'like', "%{$name}%"];
|
||||
}
|
||||
$actor_id = $request->get('actor_id');
|
||||
if ($actor_id) {
|
||||
$where[] = ['actor_id', 'like', "%{$actor_id}%"];
|
||||
}
|
||||
$channels_uid = $request->get('channels_uid');
|
||||
if ($channels_uid) {
|
||||
$where[] = ['channels_uid', '=', $channels_uid];
|
||||
}
|
||||
$list = PluginShortplayActor::where($where)->with(['user' => function ($query) {
|
||||
$query->field('id,nickname,headimg,mobile,channels_uid');
|
||||
}, 'channels' => function ($query) {
|
||||
$query->field('id,nickname,headimg,mobile');
|
||||
}])
|
||||
->order('id desc')->paginate($limit)->each(function ($item) {});
|
||||
return $this->resData($list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\admin\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\ActionBuilder;
|
||||
use app\expose\build\builder\ComponentBuilder;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use app\expose\enum\Action;
|
||||
use app\expose\enum\State;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
use plugin\shortplay\app\model\PluginShortplayDrama;
|
||||
use plugin\shortplay\app\model\PluginShortplayStyle;
|
||||
use plugin\shortplay\utils\enum\StyleClassify;
|
||||
use support\Request;
|
||||
|
||||
class DramaController extends Basic
|
||||
{
|
||||
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder([]);
|
||||
$builder->addHeader();
|
||||
$channelList = PluginChannelsUser::options();
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
$formBuilder->add('channels_uid', '渠道', 'select', '', [
|
||||
'options' => $channelList,
|
||||
'props' => [
|
||||
'placeholder' => '渠道搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('title', '名称', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '名称搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('uid', '用户ID', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '用户ID搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('channels', '渠道', [
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'channels.nickname',
|
||||
'avatar' => 'channels,headimg',
|
||||
'info' => 'channels.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'channels_uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('user', '用户', [
|
||||
'where' => [
|
||||
['uid', '!=', null]
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'user.nickname',
|
||||
'avatar' => 'user.headimg',
|
||||
'info' => 'user.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('title', '剧本名称', [
|
||||
'props' => [
|
||||
'minWidth' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('description', '剧本简介', [
|
||||
'props' => [
|
||||
'minWidth' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('cover', '封面', [
|
||||
'component' => [
|
||||
'name' => 'image',
|
||||
'props' => [
|
||||
'style' => 'width: 100px; height: 100px;',
|
||||
'fit' => 'cover'
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '133px'
|
||||
]
|
||||
]);
|
||||
|
||||
$builder->add('state', '状态', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => State::getOptions(),
|
||||
],
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$title = $request->get('title');
|
||||
if ($title) {
|
||||
$where[] = ['title', 'like', "%{$title}%"];
|
||||
}
|
||||
$uid = $request->get('uid');
|
||||
if ($uid) {
|
||||
$where[] = ['uid', '=', $uid];
|
||||
}
|
||||
$channels_uid = $request->get('channels_uid');
|
||||
if ($channels_uid) {
|
||||
$where[] = ['channels_uid', '=', $channels_uid];
|
||||
}
|
||||
$list = PluginShortplayDrama::where($where)
|
||||
->with(['channels' => function ($query) {
|
||||
$query->field('id,nickname,headimg,mobile');
|
||||
}])
|
||||
->order('id desc')->paginate($limit);
|
||||
return $this->resData($list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\admin\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\ActionBuilder;
|
||||
use app\expose\build\builder\ComponentBuilder;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use app\expose\enum\Action;
|
||||
use app\expose\enum\State;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisode;
|
||||
use plugin\shortplay\utils\enum\StyleClassify;
|
||||
use support\Request;
|
||||
|
||||
class DramaEpisodeController extends Basic
|
||||
{
|
||||
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder(
|
||||
[
|
||||
|
||||
'row-style' => 'max-height: 200px;'
|
||||
]
|
||||
);
|
||||
$builder->addHeader();
|
||||
$channelList = PluginChannelsUser::options();
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
$formBuilder->add('channels_uid', '渠道', 'select', '', [
|
||||
'options' => $channelList,
|
||||
'props' => [
|
||||
'placeholder' => '渠道搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('title', '分集名称', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '分集名称搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('uid', '用户ID', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '用户ID搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('channels', '渠道', [
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'channels.nickname',
|
||||
'avatar' => 'channels,headimg',
|
||||
'info' => 'channels.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'channels_uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('user', '用户', [
|
||||
'where' => [
|
||||
['uid', '!=', null]
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'user.nickname',
|
||||
'avatar' => 'user.headimg',
|
||||
'info' => 'user.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('title', '分集名称', [
|
||||
'props' => [
|
||||
'minWidth' => '200px',
|
||||
]
|
||||
]);
|
||||
$builder->add('content', '分集内容', [
|
||||
'props' => [
|
||||
'minWidth' => '300px',
|
||||
'show-overflow-tooltip'=>true
|
||||
]
|
||||
]);
|
||||
$builder->add('cover', '封面', [
|
||||
'component' => [
|
||||
'name' => 'image',
|
||||
'props' => [
|
||||
'style' => 'width: 100px; height: 100px;',
|
||||
'fit' => 'cover'
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '133px'
|
||||
]
|
||||
]);
|
||||
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$title = $request->get('title');
|
||||
if ($title) {
|
||||
$where[] = ['title', 'like', "%{$title}%"];
|
||||
}
|
||||
$uid = $request->get('uid');
|
||||
if ($uid) {
|
||||
$where[] = ['uid', '=', $uid];
|
||||
}
|
||||
$channels_uid = $request->get('channels_uid');
|
||||
if ($channels_uid) {
|
||||
$where[] = ['channels_uid', '=', $channels_uid];
|
||||
}
|
||||
$list = PluginShortplayDramaEpisode::where($where)
|
||||
->with(['channels' => function ($query) {
|
||||
$query->field('id,nickname,headimg,mobile');
|
||||
}])
|
||||
->order('id desc')->paginate($limit);
|
||||
return $this->resData($list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\admin\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\ActionBuilder;
|
||||
use app\expose\build\builder\ComponentBuilder;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use app\expose\enum\Action;
|
||||
use app\expose\enum\State;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
use plugin\shortplay\app\model\PluginShortplayStyle;
|
||||
use plugin\shortplay\utils\enum\StyleClassify;
|
||||
use support\Request;
|
||||
|
||||
class StyleController extends Basic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new PluginShortplayStyle;
|
||||
}
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder;
|
||||
$channelList = PluginChannelsUser::options();
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
$formBuilder->add('channels_uid', '渠道', 'select', '', [
|
||||
'options' => $channelList,
|
||||
'props' => [
|
||||
'placeholder' => '渠道搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('name', '名称', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '名称搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('classify', '风格分类', 'select', '', [
|
||||
'options' => StyleClassify::getOptions(),
|
||||
'required' => true,
|
||||
'props' => [
|
||||
'placeholder' => '风格分类搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('channels', '渠道', [
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'channels.nickname',
|
||||
'avatar' => 'channels,headimg',
|
||||
'info' => 'channels.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'channels_uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('classify', '风格分类', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => StyleClassify::getOptions(),
|
||||
],
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('styleinfo', '风格', [
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'name',
|
||||
'avatar' => 'image',
|
||||
'preview' => true
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('state', '状态', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => State::getOptions(),
|
||||
],
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('prompts', '提示词', [
|
||||
'props' => [
|
||||
'minWidth' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function query(Request $request)
|
||||
{
|
||||
$query = $request->post('query');
|
||||
if (empty($query)) {
|
||||
return $this->resData([]);
|
||||
}
|
||||
$where = [];
|
||||
$where[] = ['name|prompts', 'like', "%{$query}%"];
|
||||
return $this->resData(PluginShortplayStyle::options($where));
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$name = $request->get('name');
|
||||
if ($name) {
|
||||
$where[] = ['name', 'like', "%{$name}%"];
|
||||
}
|
||||
$classify = $request->get('classify');
|
||||
if ($classify) {
|
||||
$where[] = ['classify', '=', $classify];
|
||||
}
|
||||
$channels_uid = $request->get('channels_uid');
|
||||
if ($channels_uid) {
|
||||
$where[] = ['channels_uid', '=', $channels_uid];
|
||||
}
|
||||
$list = PluginShortplayStyle::where($where)
|
||||
->with(['channels' => function ($query) {
|
||||
$query->field('id,nickname,headimg,mobile');
|
||||
}])
|
||||
->order('id desc')->paginate($limit)->each(function ($item) {});
|
||||
return $this->resData($list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,632 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\enum\ResponseCode;
|
||||
use app\expose\enum\State;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\TransferException;
|
||||
use plugin\control\utils\yidevs\Yidevs;
|
||||
use plugin\finance\expose\helper\Account;
|
||||
use plugin\finance\utils\enum\PointsBillScene;
|
||||
use plugin\model\app\model\PluginModel;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\app\model\PluginModelTaskResult;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\model\utils\enum\ModelTaskStatus;
|
||||
use plugin\model\utils\enum\ModelType;
|
||||
use plugin\notification\expose\helper\Push;
|
||||
use plugin\shortplay\app\model\PluginShortplayActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayActorCharacterLook;
|
||||
use plugin\shortplay\app\model\PluginShortplayCharacterLook;
|
||||
use plugin\shortplay\app\model\PluginShortplayDrama;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisode;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisodeActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboard;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardDialogue;
|
||||
use plugin\shortplay\utils\enum\ActorAge;
|
||||
use plugin\shortplay\utils\enum\ActorGender;
|
||||
use plugin\shortplay\utils\enum\ActorSpeciesType;
|
||||
use plugin\shortplay\utils\enum\ActorStatus;
|
||||
use plugin\shortplay\utils\enum\VoiceLanguage;
|
||||
use support\Log;
|
||||
use support\Request;
|
||||
use support\think\Db;
|
||||
use Workerman\Coroutine;
|
||||
|
||||
class ActorController extends Basic
|
||||
{
|
||||
protected $notNeedLogin = ['index'];
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 2000);
|
||||
$page = $request->get('page');
|
||||
$type = $request->get('type');
|
||||
$where = [];
|
||||
// $where[] = ['status', '=', ActorStatus::GENERATED['value']];
|
||||
$whereOr = [];
|
||||
$params = [];
|
||||
$uid = $request->uid;
|
||||
switch ($type) {
|
||||
case 'public':
|
||||
$where[] = ['actor.uid', '=', null];
|
||||
break;
|
||||
case 'personal':
|
||||
if (!$request->uid) {
|
||||
return $this->code(ResponseCode::NEED_LOGIN, '请先登录');
|
||||
}
|
||||
$where[] = ['actor.uid', '=', $request->uid];
|
||||
$where[] = ['actor.drama_id', '=', null];
|
||||
break;
|
||||
case 'self':
|
||||
if (!$request->uid) {
|
||||
return $this->code(ResponseCode::NEED_LOGIN, '请先登录');
|
||||
}
|
||||
$where[] = ['actor.uid', '=', $request->uid];
|
||||
break;
|
||||
case 'storyboard':
|
||||
$storyboard_id = $request->get('storyboard_id');
|
||||
if (!$storyboard_id) {
|
||||
return $this->fail('分镜ID不能为空');
|
||||
}
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $storyboard_id])->find();
|
||||
if (!$PluginShortplayDramaStoryboard) {
|
||||
return $this->fail('分镜不存在');
|
||||
}
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $PluginShortplayDramaStoryboard->episode_id, 'drama_id' => $PluginShortplayDramaStoryboard->drama_id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $PluginShortplayDramaStoryboard->drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$whereOr[] = ['actor.uid', '=', null];
|
||||
$whereOr[] = ['actor.uid', '=', $request->uid];
|
||||
$params['drama_id'] = $PluginShortplayDrama->id;
|
||||
$params['episode_id'] = $PluginShortplayDramaEpisode->id;
|
||||
$params['storyboard_id'] = $PluginShortplayDramaStoryboard->id;
|
||||
break;
|
||||
case 'episode':
|
||||
$episode_id = $request->get('episode_id');
|
||||
if (!$episode_id) {
|
||||
return $this->fail('分集ID不能为空');
|
||||
}
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $episode_id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $PluginShortplayDramaEpisode->drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$whereOr[] = ['actor.uid', '=', null];
|
||||
$whereOr[] = ['actor.uid', '=', $request->uid];
|
||||
$params['drama_id'] = $PluginShortplayDrama->id;
|
||||
$params['episode_id'] = $PluginShortplayDramaEpisode->id;
|
||||
$params['storyboard_id'] = null;
|
||||
break;
|
||||
case 'drama':
|
||||
$drama_id = $request->get('drama_id');
|
||||
if (!$drama_id) {
|
||||
return $this->fail('短剧ID不能为空');
|
||||
}
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$whereOr[] = ['actor.uid', '=', null];
|
||||
$whereOr[] = ['actor.uid', '=', $request->uid];
|
||||
$params['drama_id'] = $PluginShortplayDrama->id;
|
||||
$params['episode_id'] = null;
|
||||
$params['storyboard_id'] = null;
|
||||
break;
|
||||
default:
|
||||
$whereOr[] = ['actor.uid', '=', null];
|
||||
$whereOr[] = ['actor.uid', '=', $request->uid];
|
||||
break;
|
||||
}
|
||||
$name = $request->get('name');
|
||||
if ($name) {
|
||||
$where[] = ['actor.name', 'like', '%' . $name . '%'];
|
||||
}
|
||||
$actor_id = $request->get('actor_id');
|
||||
if ($actor_id) {
|
||||
$where[] = ['actor.actor_id', 'like', '%' . $actor_id . '%'];
|
||||
}
|
||||
$species_type = $request->get('species_type');
|
||||
if ($species_type) {
|
||||
$where[] = ['actor.species_type', '=', $species_type];
|
||||
}
|
||||
$gender = $request->get('gender');
|
||||
if ($gender) {
|
||||
$where[] = ['actor.gender', '=', $gender];
|
||||
}
|
||||
$age = $request->get('age');
|
||||
if ($age) {
|
||||
$where[] = ['actor.age', '=', $age];
|
||||
}
|
||||
$PluginShortplayActor = PluginShortplayActor::actorQuery($params)->where($where)->whereOr($whereOr)->order('actor.id', 'desc')->limit($limit);
|
||||
if ($page) {
|
||||
$PluginShortplayActor = $PluginShortplayActor->paginate($limit, $page);
|
||||
} else {
|
||||
$PluginShortplayActor = $PluginShortplayActor->select();
|
||||
}
|
||||
$list = $PluginShortplayActor->each(function ($item) use ($uid, $params) {
|
||||
$item->species_type_enum = ActorSpeciesType::get($item->species_type);
|
||||
$item->gender_enum = ActorGender::get($item->gender);
|
||||
$item->age_enum = ActorAge::get($item->age);
|
||||
$item->is_edit = $item->uid == $uid && $uid;
|
||||
$params['actor_id'] = $item->id;
|
||||
$item->character_look_state = PluginShortplayActorCharacterLook::processing($params);
|
||||
if ($item->character_look_id) {
|
||||
$characterLook = PluginShortplayActorCharacterLook::where(['id' => $item->character_look_id])->with('characterLook')->find();
|
||||
if ($characterLook) {
|
||||
$item->characterLook = $characterLook->characterLook;
|
||||
}
|
||||
}
|
||||
});
|
||||
return $this->resData($list);
|
||||
}
|
||||
public function initializing(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
|
||||
$PluginShortplayActor = PluginShortplayActor::where([
|
||||
'id' => $id,
|
||||
'uid' => $request->uid
|
||||
])->find();
|
||||
|
||||
if (!$PluginShortplayActor) {
|
||||
return $this->fail('演员不存在');
|
||||
}
|
||||
$name = $request->post('name');
|
||||
if ($name) {
|
||||
$PluginShortplayActor->name = $name;
|
||||
}
|
||||
$actor_id = uniqid();
|
||||
if ($actor_id) {
|
||||
$PluginShortplayActor->actor_id = $actor_id;
|
||||
}
|
||||
$species_type = $request->post('species_type');
|
||||
if ($species_type) {
|
||||
$PluginShortplayActor->species_type = $species_type;
|
||||
}
|
||||
$gender = $request->post('gender');
|
||||
if ($gender) {
|
||||
$PluginShortplayActor->gender = $gender;
|
||||
}
|
||||
$age = $request->post('age');
|
||||
if ($age) {
|
||||
$PluginShortplayActor->age = $age;
|
||||
}
|
||||
$remarks = $request->post('remarks');
|
||||
if ($remarks) {
|
||||
$PluginShortplayActor->remarks = $remarks;
|
||||
}
|
||||
$imageState = PluginModelTask::processing(['alias_id' => $PluginShortplayActor->id, 'scene' => ModelScene::ACTOR_IMAGE['value']]);
|
||||
$threeViewImageState = PluginModelTask::processing(['alias_id' => $PluginShortplayActor->id, 'scene' => ModelScene::ACTOR_THREE_VIEW_IMAGE['value']]);
|
||||
if ($imageState > 0 || $threeViewImageState > 0) {
|
||||
return $this->fail('演员正在生成中');
|
||||
}
|
||||
|
||||
// ===== 表单参数 =====
|
||||
$image_model_id = $request->post('image_model_id');
|
||||
$three_view_model_id = $request->post('three_view_model_id');
|
||||
$image_state = (bool)$request->post('image_state');
|
||||
$three_view_image_state = (bool)$request->post('three_view_image_state');
|
||||
$image = $request->post('image');
|
||||
$three_view_image = $request->post('three_view_image');
|
||||
$image_reference_state = (bool)$request->post('image_reference_state');
|
||||
$reference_headimg = $request->post('reference_headimg');
|
||||
if ($image_reference_state && empty($reference_headimg)) {
|
||||
return $this->fail('请上传参考图片');
|
||||
}
|
||||
|
||||
// ===== 是否需要 AI 生成 =====
|
||||
$needAiImage = ($PluginShortplayActor->headimg && $image_state) ? empty($image) : true;
|
||||
$needSkipImage = $PluginShortplayActor->headimg && !$image_state;
|
||||
$needAiThreeView = ($PluginShortplayActor->three_view_image && $three_view_image_state) ? empty($three_view_image) : true;
|
||||
$needSkipThreeView = $PluginShortplayActor->three_view_image && !$three_view_image_state;
|
||||
$isDoubleAi = ($needAiImage && !$needSkipImage) && ($needAiThreeView && !$needSkipThreeView);
|
||||
|
||||
$ImagePluginModel = null;
|
||||
$ThreeViewPluginModel = null;
|
||||
|
||||
// =====================================================
|
||||
// 一、模型前置校验(任何 AI 调用前)
|
||||
// =====================================================
|
||||
|
||||
// 双 AI:必须一次性校验两个模型
|
||||
if ($isDoubleAi) {
|
||||
$ImagePluginModel = PluginModel::where([
|
||||
'id' => $image_model_id,
|
||||
'scene' => ModelScene::ACTOR_IMAGE['value'],
|
||||
'state' => State::YES['value']
|
||||
])->find();
|
||||
|
||||
$ThreeViewPluginModel = PluginModel::where([
|
||||
'id' => $three_view_model_id,
|
||||
'scene' => ModelScene::ACTOR_THREE_VIEW_IMAGE['value'],
|
||||
'state' => State::YES['value']
|
||||
])->find();
|
||||
|
||||
if (!$ImagePluginModel || !$ThreeViewPluginModel) {
|
||||
return $this->fail('模型不存在');
|
||||
}
|
||||
} else {
|
||||
// 单独 image AI
|
||||
if ($needAiImage && !$needSkipImage) {
|
||||
if (!$image_model_id) {
|
||||
return $this->fail('请选择角色形象模型');
|
||||
}
|
||||
$ImagePluginModel = PluginModel::where([
|
||||
'id' => $image_model_id,
|
||||
'scene' => ModelScene::ACTOR_IMAGE['value'],
|
||||
'state' => State::YES['value']
|
||||
])->find();
|
||||
|
||||
if (!$ImagePluginModel) {
|
||||
return $this->fail('角色形象模型不存在');
|
||||
}
|
||||
}
|
||||
|
||||
// 单独 three view AI
|
||||
if ($needAiThreeView && !$needSkipThreeView) {
|
||||
if (!$three_view_model_id) {
|
||||
return $this->fail('请选择角色三视图模型');
|
||||
}
|
||||
$ThreeViewPluginModel = PluginModel::where([
|
||||
'id' => $three_view_model_id,
|
||||
'scene' => ModelScene::ACTOR_THREE_VIEW_IMAGE['value'],
|
||||
'state' => State::YES['value']
|
||||
])->find();
|
||||
|
||||
if (!$ThreeViewPluginModel) {
|
||||
return $this->fail('角色三视图模型不存在');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// 二、角色形象 AI 生成
|
||||
// =====================================================
|
||||
|
||||
$lockImage = false;
|
||||
$taskId = null;
|
||||
if (!$needSkipImage) {
|
||||
if ($needAiImage) {
|
||||
$lockImage = true;
|
||||
$data = [
|
||||
'assistant' => $ImagePluginModel->assistant_id,
|
||||
'model' => $ImagePluginModel->model_id,
|
||||
'notify_url' => 'https://' . $request->host() . '/app/model/Notify/draw',
|
||||
'form_data' => [
|
||||
'prompt' => $PluginShortplayActor->remarks,
|
||||
'species' => ActorSpeciesType::getText($PluginShortplayActor->species_type),
|
||||
'gender' => ActorGender::getText($PluginShortplayActor->gender),
|
||||
'age' => ActorAge::getText($PluginShortplayActor->age),
|
||||
'aspect_ratio' => '1:1',
|
||||
]
|
||||
];
|
||||
if ($image_reference_state) {
|
||||
$data['form_data']['images'] = [$reference_headimg];
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$consume_ids = Account::decPoints($request->uid, $request->channels_uid, $ImagePluginModel->point, PointsBillScene::CONSUME['value'], null, '生成角色形象图', true);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
try {
|
||||
$result = Yidevs::DrawAssistantTIGI($request->channels_uid, $data);
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$task = new PluginModelTask();
|
||||
$task->channels_uid = $request->channels_uid;
|
||||
$task->uid = $request->uid;
|
||||
$task->model_id = $ImagePluginModel->id;
|
||||
$task->model_type = ModelType::DRAW['value'];
|
||||
$task->alias_id = $PluginShortplayActor->id;
|
||||
$task->scene = ModelScene::ACTOR_IMAGE['value'];
|
||||
$task->status = ModelTaskStatus::PROCESSING['value'];
|
||||
$task->task_id = $result['task_id'];
|
||||
$task->last_heartbeat = date('Y-m-d H:i:s');
|
||||
$task->consume_ids = $consume_ids;
|
||||
$task->save();
|
||||
$taskId = $task->id;
|
||||
$taskResult = new PluginModelTaskResult();
|
||||
$taskResult->task_id = $task->id;
|
||||
$taskResult->channels_uid = $request->channels_uid;
|
||||
$taskResult->params = $data;
|
||||
$taskResult->save();
|
||||
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw $e;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
if (!empty($consume_ids)) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
Account::refund($request->uid, $request->channels_uid, $consume_ids);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
Log::error('GenerateActorImage Error:' . $e->getMessage());
|
||||
return $this->fail('角色形象生成失败');
|
||||
}
|
||||
$PluginShortplayActor->headimg = null;
|
||||
}
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// 三、角色三视图 AI 生成
|
||||
// =====================================================
|
||||
if (!$needSkipThreeView) {
|
||||
if ($needAiThreeView) {
|
||||
$data = [
|
||||
'assistant' => $ThreeViewPluginModel->assistant_id,
|
||||
'model' => $ThreeViewPluginModel->model_id,
|
||||
'notify_url' => 'https://' . $request->host() . '/app/model/Notify/draw',
|
||||
'form_data' => [
|
||||
'prompt' => $PluginShortplayActor->remarks,
|
||||
'species' => ActorSpeciesType::getText($PluginShortplayActor->species_type),
|
||||
'gender' => ActorGender::getText($PluginShortplayActor->gender),
|
||||
'age' => ActorAge::getText($PluginShortplayActor->age),
|
||||
'aspect_ratio' => '1:1',
|
||||
]
|
||||
];
|
||||
|
||||
// 非 image AI 场景,必须依赖已有形象
|
||||
if (!$lockImage) {
|
||||
if (!$PluginShortplayActor->headimg) {
|
||||
return $this->fail('请先生成角色形象,再生成角色三视图');
|
||||
}
|
||||
$data['form_data']['images'] = [$PluginShortplayActor->headimg];
|
||||
}
|
||||
|
||||
try {
|
||||
if (!$lockImage) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
$consume_ids = Account::decPoints($request->uid, $request->channels_uid, $ThreeViewPluginModel->point, PointsBillScene::CONSUME['value'], null, '生成角色三视图', true);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
$result = Yidevs::DrawAssistantTIGI($request->channels_uid, $data);
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$task = new PluginModelTask();
|
||||
$task->channels_uid = $request->channels_uid;
|
||||
$task->uid = $request->uid;
|
||||
$task->model_id = $ThreeViewPluginModel->id;
|
||||
$task->model_type = ModelType::DRAW['value'];
|
||||
$task->alias_id = $PluginShortplayActor->id;
|
||||
$task->scene = ModelScene::ACTOR_THREE_VIEW_IMAGE['value'];
|
||||
$task->pre_task_id = $taskId;
|
||||
$task->status = $lockImage
|
||||
? ModelTaskStatus::WAIT['value']
|
||||
: ModelTaskStatus::PROCESSING['value'];
|
||||
$task->task_id = $lockImage ? null : $result['task_id'];
|
||||
$task->last_heartbeat = date('Y-m-d H:i:s');
|
||||
$task->consume_ids = $consume_ids;
|
||||
$task->save();
|
||||
|
||||
$taskResult = new PluginModelTaskResult();
|
||||
$taskResult->task_id = $task->id;
|
||||
$taskResult->channels_uid = $request->channels_uid;
|
||||
$taskResult->params = $data;
|
||||
$taskResult->save();
|
||||
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw $e;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
if (!empty($consume_ids)) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
Account::refund($request->uid, $request->channels_uid, $consume_ids);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
Log::error('GenerateActorThreeView Error:' . $e->getMessage());
|
||||
return $this->fail('角色三视图生成失败');
|
||||
}
|
||||
$PluginShortplayActor->three_view_image = null;
|
||||
}
|
||||
}
|
||||
$PluginShortplayActor->save();
|
||||
$PluginShortplayActor = PluginShortplayActor::where(['id' => $PluginShortplayActor->id])->find();
|
||||
return $this->resData($PluginShortplayActor);
|
||||
}
|
||||
public function update(Request $request)
|
||||
{
|
||||
$msg = '更新成功';
|
||||
Db::startTrans();
|
||||
try {
|
||||
$id = $request->post('id');
|
||||
$PluginShortplayDramaActor = null;
|
||||
$PluginShortplayDramaEpisodeActor = null;
|
||||
if ($id) {
|
||||
$PluginShortplayActor = PluginShortplayActor::where(['id' => $id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayActor) {
|
||||
throw new \Exception('演员不存在');
|
||||
}
|
||||
} else {
|
||||
$PluginShortplayActor = new PluginShortplayActor();
|
||||
$PluginShortplayActor->uid = $request->uid;
|
||||
$PluginShortplayActor->channels_uid = $request->channels_uid;
|
||||
$drama_id = $request->post('drama_id');
|
||||
if ($drama_id) {
|
||||
$PluginShortplayActor->drama_id = $drama_id;
|
||||
$PluginShortplayDramaActor = new PluginShortplayDramaActor();
|
||||
$PluginShortplayDramaActor->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayDramaActor->drama_id = $drama_id;
|
||||
}
|
||||
$episode_id = $request->post('episode_id');
|
||||
if ($episode_id) {
|
||||
$PluginShortplayActor->episode_id = $episode_id;
|
||||
$PluginShortplayDramaEpisodeActor = new PluginShortplayDramaEpisodeActor();
|
||||
$PluginShortplayDramaEpisodeActor->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayDramaEpisodeActor->drama_id = $drama_id;
|
||||
$PluginShortplayDramaEpisodeActor->episode_id = $episode_id;
|
||||
}
|
||||
$PluginShortplayActor->status = ActorStatus::INITIALIZING['value'];
|
||||
$msg = '创建成功';
|
||||
$PluginShortplayActor->actor_id = uniqid();
|
||||
}
|
||||
$PluginShortplayActor->name = $request->post('name');
|
||||
$PluginShortplayActor->headimg = $request->post('headimg');
|
||||
$PluginShortplayActor->species_type = $request->post('species_type');
|
||||
$PluginShortplayActor->gender = $request->post('gender');
|
||||
$PluginShortplayActor->age = $request->post('age');
|
||||
$PluginShortplayActor->remarks = $request->post('remarks');
|
||||
$PluginShortplayActor->three_view_image = $request->post('three_view_image');
|
||||
if ($PluginShortplayActor->headimg && $PluginShortplayActor->three_view_image) {
|
||||
$PluginShortplayActor->status = ActorStatus::GENERATED['value'];
|
||||
}
|
||||
$PluginShortplayActor->save();
|
||||
if ($PluginShortplayDramaActor) {
|
||||
$PluginShortplayDramaActor->actor_id = $PluginShortplayActor->id;
|
||||
$PluginShortplayDramaActor->save();
|
||||
}
|
||||
if ($PluginShortplayDramaEpisodeActor) {
|
||||
$PluginShortplayDramaEpisodeActor->actor_id = $PluginShortplayActor->id;
|
||||
$PluginShortplayDramaEpisodeActor->save();
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
return $this->success($msg, $PluginShortplayActor);
|
||||
}
|
||||
public function ReplaceActor(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$task_id = $request->post('task_id');
|
||||
$PluginShortplayActor = PluginShortplayActor::where(['id' => $id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayActor) {
|
||||
return $this->fail('演员不存在');
|
||||
}
|
||||
$PluginModelTask = PluginModelTask::where(['id' => $task_id, 'alias_id' => $PluginShortplayActor->id, 'scene' => ModelScene::ACTOR_IMAGE['value'], 'status' => ModelTaskStatus::SUCCESS['value']])->find();
|
||||
if (!$PluginModelTask) {
|
||||
return $this->fail('任务不存在');
|
||||
}
|
||||
$PluginShortplayActor->headimg = $PluginModelTask->result->image_path;
|
||||
$PluginModelTask = PluginModelTask::where(['pre_task_id' => $PluginModelTask->id, 'alias_id' => $PluginShortplayActor->id, 'scene' => ModelScene::ACTOR_THREE_VIEW_IMAGE['value'], 'status' => ModelTaskStatus::SUCCESS['value']])->find();
|
||||
if ($PluginModelTask) {
|
||||
$PluginShortplayActor->three_view_image = $PluginModelTask->result->image_path;
|
||||
$PluginShortplayActor->status = ActorStatus::GENERATED['value'];
|
||||
} else {
|
||||
$PluginShortplayActor->status = ActorStatus::INITIALIZING['value'];
|
||||
$PluginShortplayActor->three_view_image = null;
|
||||
}
|
||||
$PluginShortplayActor->save();
|
||||
$PluginShortplayActor = PluginShortplayActor::where(['id' => $id])->find();
|
||||
return $this->resData($PluginShortplayActor);
|
||||
}
|
||||
public function voice(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$drama_id = $request->post('drama_id');
|
||||
$episode_id = $request->post('episode_id');
|
||||
$storyboard_id = $request->post('storyboard_id');
|
||||
$scene_id = $request->post('scene_id');
|
||||
$dialogue_id = $request->post('dialogue_id');
|
||||
$apply_scope = $request->post('apply_scope');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$voice = $request->post('voice');
|
||||
if (!empty($voice['emotions_enum']) && empty($voice['selected_emotion'])) {
|
||||
$voice['selected_emotion'] = $voice['emotions_enum'][0];
|
||||
}
|
||||
if (empty($voice['selected_language'])) {
|
||||
$voice['selected_language'] = VoiceLanguage::ZH;
|
||||
}
|
||||
if ($apply_scope === 'scene') {
|
||||
$PluginShortplayDramaStoryboards = PluginShortplayDramaStoryboard::where(['scene_id' => $scene_id, 'drama_id' => $PluginShortplayDrama->id])->find();
|
||||
if ($PluginShortplayDramaStoryboards->isEmpty()) {
|
||||
throw new \Exception('该场景下无分镜');
|
||||
}
|
||||
foreach ($PluginShortplayDramaStoryboards as $PluginShortplayDramaStoryboard) {
|
||||
$PluginShortplayDramaStoryboardActor = PluginShortplayDramaStoryboardActor::where(['storyboard_id' => $PluginShortplayDramaStoryboard->id, 'actor_id' => $id])->find();
|
||||
if ($PluginShortplayDramaStoryboardActor) {
|
||||
$PluginShortplayDramaStoryboardActor->voice = $voice;
|
||||
$PluginShortplayDramaStoryboardActor->save();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$ActorModel = null;
|
||||
switch ($apply_scope) {
|
||||
case 'drama':
|
||||
$ActorModel = PluginShortplayDramaActor::where(['drama_id' => $PluginShortplayDrama->id, 'actor_id' => $id])->find();
|
||||
break;
|
||||
case 'episode':
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $episode_id, 'drama_id' => $PluginShortplayDrama->id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
throw new \Exception('分集不存在');
|
||||
}
|
||||
$ActorModel = PluginShortplayDramaEpisodeActor::where(['episode_id' => $PluginShortplayDramaEpisode->id, 'actor_id' => $id])->find();
|
||||
break;
|
||||
case 'storyboard':
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $storyboard_id, 'drama_id' => $PluginShortplayDrama->id])->find();
|
||||
if (!$PluginShortplayDramaStoryboard) {
|
||||
throw new \Exception('分镜不存在');
|
||||
}
|
||||
$ActorModel = PluginShortplayDramaStoryboardActor::where(['storyboard_id' => $PluginShortplayDramaStoryboard->id, 'actor_id' => $id])->find();
|
||||
break;
|
||||
case 'dialogue':
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $storyboard_id, 'drama_id' => $PluginShortplayDrama->id])->find();
|
||||
if (!$PluginShortplayDramaStoryboard) {
|
||||
throw new \Exception('分镜不存在');
|
||||
}
|
||||
$ActorModel = PluginShortplayDramaStoryboardDialogue::where(['id' => $dialogue_id, 'storyboard_id' => $PluginShortplayDramaStoryboard->id])->find();
|
||||
break;
|
||||
}
|
||||
if (!$ActorModel) {
|
||||
throw new \Exception('演员不存在');
|
||||
}
|
||||
$ActorModel->voice = $voice;
|
||||
$ActorModel->save();
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
return $this->success('更新成功');
|
||||
}
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$PluginShortplayActor = PluginShortplayActor::where(['id' => $id, 'uid' => $request->uid])->whereNull('drama_id')->find();
|
||||
if (!$PluginShortplayActor) {
|
||||
return $this->fail('演员不存在');
|
||||
}
|
||||
$PluginShortplayActor->delete();
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\TransferException;
|
||||
use plugin\notification\expose\helper\Push;
|
||||
use plugin\shortplay\app\model\PluginShortplayActorCharacterLook;
|
||||
use plugin\shortplay\app\model\PluginShortplayDrama;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisode;
|
||||
use plugin\shortplay\app\model\PluginShortplayCharacterLook;
|
||||
use plugin\shortplay\utils\enum\ActorStatus;
|
||||
use support\Log;
|
||||
use support\Request;
|
||||
use Workerman\Coroutine;
|
||||
|
||||
class CharacterLookController extends Basic
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$type = $request->get('type');
|
||||
$where = [];
|
||||
switch ($type) {
|
||||
case 'episode':
|
||||
$episode_id = $request->get('episode_id');
|
||||
if (!$episode_id) {
|
||||
return $this->fail('分集ID不能为空');
|
||||
}
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $episode_id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $PluginShortplayDramaEpisode->drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$where[] = ['episode_id', '=', $PluginShortplayDramaEpisode->id];
|
||||
break;
|
||||
case 'drama':
|
||||
$drama_id = $request->get('drama_id');
|
||||
if (!$drama_id) {
|
||||
return $this->fail('短剧ID不能为空');
|
||||
}
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$where[] = ['drama_id', '=', $PluginShortplayDrama->id];
|
||||
break;
|
||||
case 'actor':
|
||||
$actor_id = $request->get('actor_id');
|
||||
if (!$actor_id) {
|
||||
return $this->fail('演员ID不能为空');
|
||||
}
|
||||
$PluginShortplayActorCharacterLook = PluginShortplayActorCharacterLook::where(['actor_id' => $actor_id, 'uid' => $request->uid])->order('id', 'desc')->with('characterLook')->select()->each(function ($item) {
|
||||
$item->component = 'actor';
|
||||
});
|
||||
return $this->resData($PluginShortplayActorCharacterLook);
|
||||
default:
|
||||
$where[] = ['uid', '=', $request->uid];
|
||||
break;
|
||||
}
|
||||
$keywords = $request->get('keywords');
|
||||
if ($keywords) {
|
||||
$where[] = ['title|overall_style|makeup|hair_style|status_note', 'like', '%' . $keywords . '%'];
|
||||
}
|
||||
$PluginShortplayCharacterLook = PluginShortplayCharacterLook::where($where)->order('id', 'desc')->select()->each(function ($item) {});
|
||||
return $this->resData($PluginShortplayCharacterLook);
|
||||
}
|
||||
public function update(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
if ($drama_id) {
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
}
|
||||
$episode_id = $request->post('episode_id');
|
||||
if ($episode_id) {
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $episode_id, 'drama_id' => $drama_id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
}
|
||||
$id = $request->post('id');
|
||||
if ($id) {
|
||||
$PluginShortplayCharacterLook = PluginShortplayCharacterLook::where(['id' => $id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayCharacterLook) {
|
||||
return $this->fail('装扮不存在');
|
||||
}
|
||||
} else {
|
||||
$PluginShortplayCharacterLook = new PluginShortplayCharacterLook();
|
||||
$PluginShortplayCharacterLook->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayCharacterLook->uid = $request->uid;
|
||||
if ($drama_id) {
|
||||
$PluginShortplayCharacterLook->drama_id = $PluginShortplayDrama->id;
|
||||
}
|
||||
if ($episode_id) {
|
||||
$PluginShortplayCharacterLook->drama_id = $PluginShortplayDramaEpisode->drama_id;
|
||||
$PluginShortplayCharacterLook->episode_id = $PluginShortplayDramaEpisode->id;
|
||||
}
|
||||
}
|
||||
$costume_reference_state = (bool)$request->post('costume_reference_state');
|
||||
$D = $request->post();
|
||||
if (!empty($D['title'])) {
|
||||
$PluginShortplayCharacterLook->title = $D['title'];
|
||||
}
|
||||
if (!empty($D['overall_style'])) {
|
||||
$PluginShortplayCharacterLook->overall_style = $D['overall_style'];
|
||||
}
|
||||
if (!empty($D['makeup'])) {
|
||||
$PluginShortplayCharacterLook->makeup = $D['makeup'];
|
||||
}
|
||||
if (!empty($D['hair_style'])) {
|
||||
$PluginShortplayCharacterLook->hair_style = $D['hair_style'];
|
||||
}
|
||||
if (!empty($D['status_note'])) {
|
||||
$PluginShortplayCharacterLook->status_note = $D['status_note'];
|
||||
}
|
||||
if (!empty($D['costume'])) {
|
||||
$PluginShortplayCharacterLook->costume = $D['costume'];
|
||||
}
|
||||
$PluginShortplayCharacterLook->status = ActorStatus::INITIALIZING['value'];
|
||||
if (!empty($D['costume_url'])) {
|
||||
$PluginShortplayCharacterLook->costume_url = $D['costume_url'];
|
||||
if (!$costume_reference_state) {
|
||||
$PluginShortplayCharacterLook->status = ActorStatus::GENERATED['value'];
|
||||
}
|
||||
}
|
||||
$PluginShortplayCharacterLook->save();
|
||||
$model_id = $request->post('model_id');
|
||||
if ($model_id && $PluginShortplayCharacterLook->status === ActorStatus::INITIALIZING['value']) {
|
||||
$data = [
|
||||
'uid' => $request->uid,
|
||||
'channels_uid' => $request->channels_uid,
|
||||
'token' => $request->token,
|
||||
'origin' => $request->header('origin'),
|
||||
'referer' => $request->header('referer'),
|
||||
'host' => $request->host(),
|
||||
'form_data' => [
|
||||
'id' => $PluginShortplayCharacterLook->id,
|
||||
'model_id' => $model_id,
|
||||
'costume_url' => $PluginShortplayCharacterLook->costume_url,
|
||||
'costume_reference_state' => $costume_reference_state
|
||||
],
|
||||
];
|
||||
Coroutine::create(function () use ($data) {
|
||||
try {
|
||||
$client = new Client([
|
||||
'base_uri' => 'http://127.0.0.1:' . getenv('SERVER_PORT'),
|
||||
'verify' => false,
|
||||
'proxy' => false
|
||||
]);
|
||||
$response = $client->post('/app/shortplay/api/Generate/characterLookCostume', [
|
||||
'json' => $data['form_data'],
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json',
|
||||
'Authorization' => $data['token'],
|
||||
'Origin' => $data['origin'],
|
||||
'Referer' => $data['referer'],
|
||||
'Host' => $data['host'],
|
||||
],
|
||||
]);
|
||||
$result = json_decode($response->getBody()->getContents(), true);
|
||||
if (!isset($result['code']) || $result['code'] != 200) {
|
||||
Log::error('初始化装扮失败:' . $result['msg']);
|
||||
} else {
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'event' => 'generatecharacterlookcostume'
|
||||
], [
|
||||
'id' => $data['form_data']['id'],
|
||||
'status' => ActorStatus::PENDING,
|
||||
]);
|
||||
}
|
||||
} catch (TransferException $e) {
|
||||
Log::error('初始化装扮失败:' . $e->getMessage() . PHP_EOL . $e->getTraceAsString());
|
||||
} catch (\Throwable $th) {
|
||||
Log::error('初始化装扮失败:' . $th->getMessage() . PHP_EOL . $th->getTraceAsString());
|
||||
}
|
||||
});
|
||||
}
|
||||
return $this->resData($PluginShortplayCharacterLook);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\helper\Config;
|
||||
use app\expose\utils\Str;
|
||||
use app\model\Uploads as ModelUploads;
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use plugin\shortplay\app\model\PluginShortplayDrama;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisode;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisodeActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaScene;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboard;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardProp;
|
||||
use plugin\shortplay\utils\enum\VoiceLanguage;
|
||||
use Shopwwi\WebmanFilesystem\Storage;
|
||||
use support\Log;
|
||||
use support\Request;
|
||||
use support\think\Db;
|
||||
use Webman\Http\UploadFile;
|
||||
use Workerman\Coroutine;
|
||||
|
||||
class DramaController extends Basic
|
||||
{
|
||||
public function uploadChunkCheck(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$episode_id = $request->post('episode_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $episode_id, 'drama_id' => $PluginShortplayDrama->id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
// 保存分片目录
|
||||
$tempDir = runtime_path('temp/chunks/' . $drama_id . '_' . $episode_id);
|
||||
if (!is_dir($tempDir)) {
|
||||
mkdir($tempDir, 0777, true);
|
||||
} else {
|
||||
# 清空目录
|
||||
shell_exec('rm -rf ' . $tempDir . '/*');
|
||||
}
|
||||
return $this->success();
|
||||
}
|
||||
public function uploadChunk(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$episode_id = $request->post('episode_id');
|
||||
$chunkIndex = intval($request->post('chunkIndex', 0));
|
||||
$totalChunks = intval($request->post('totalChunks', 0));
|
||||
|
||||
if (!$drama_id || !$episode_id || $totalChunks <= 0) {
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
|
||||
// 上传的文件片段
|
||||
$chunkFile = $request->file('chunkData');
|
||||
if (!$chunkFile || $chunkFile->isValid() !== true) {
|
||||
return $this->fail('分片上传失败');
|
||||
}
|
||||
|
||||
// 保存分片目录
|
||||
$tempDir = runtime_path('temp/chunks/' . $drama_id . '_' . $episode_id);
|
||||
if (!is_dir($tempDir)) {
|
||||
mkdir($tempDir, 0777, true);
|
||||
}
|
||||
|
||||
// 分片保存路径
|
||||
$chunkPath = $tempDir . '/' . $chunkIndex;
|
||||
$chunkFile->move($chunkPath);
|
||||
|
||||
return $this->success('分片上传成功');
|
||||
}
|
||||
public function mergeChunks(Request $request)
|
||||
{
|
||||
Coroutine::create(function () use ($request) {
|
||||
try {
|
||||
$drama_id = $request->post('drama_id');
|
||||
$episode_id = $request->post('episode_id');
|
||||
$totalChunks = intval($request->post('totalChunks', 0));
|
||||
$channels_uid = (int)$request->channels_uid;
|
||||
if (empty($channels_uid)) {
|
||||
throw new \Exception('渠道用户ID不存在');
|
||||
}
|
||||
|
||||
if (!$drama_id || !$episode_id || $totalChunks <= 0) {
|
||||
throw new \Exception('参数错误');
|
||||
}
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
throw new \Exception('短剧不存在');
|
||||
}
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $episode_id, 'drama_id' => $PluginShortplayDrama->id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
throw new \Exception('分集不存在');
|
||||
}
|
||||
|
||||
$tempDir = runtime_path('temp/chunks/' . $drama_id . '_' . $episode_id);
|
||||
if (!is_dir($tempDir)) {
|
||||
throw new \Exception('分片目录不存在');
|
||||
}
|
||||
|
||||
$targetDir = runtime_path('temp/videos/');
|
||||
if (!is_dir($targetDir)) mkdir($targetDir, 0777, true);
|
||||
|
||||
$targetPath = $targetDir . $drama_id . '_' . $episode_id . '.mp4';
|
||||
if (file_exists($targetPath)) {
|
||||
\unlink($targetPath);
|
||||
}
|
||||
|
||||
$out = fopen($targetPath, 'ab');
|
||||
if (!$out) {
|
||||
throw new \Exception('打开文件失败');
|
||||
}
|
||||
|
||||
// 合并分片
|
||||
for ($i = 0; $i < $totalChunks; $i++) {
|
||||
$chunkPath = $tempDir . '/' . $i;
|
||||
if (!file_exists($chunkPath)) {
|
||||
fclose($out);
|
||||
throw new \Exception("分片 {$i} 不存在");
|
||||
}
|
||||
$in = fopen($chunkPath, 'rb');
|
||||
stream_copy_to_stream($in, $out);
|
||||
fclose($in);
|
||||
// 删除分片
|
||||
unlink($chunkPath);
|
||||
}
|
||||
fclose($out);
|
||||
|
||||
// 删除分片目录
|
||||
rmdir($tempDir);
|
||||
try {
|
||||
$file = new UploadFile($targetPath, $drama_id . '_' . $episode_id . '.mp4', 'video/mp4', 0);
|
||||
$config = new Config('filesystem', '', $channels_uid);
|
||||
$classify = Uploads::getClassify($channels_uid, 'uploads/drama/video', '短剧', $config->default);
|
||||
$Storage = new Storage($config->toArray());
|
||||
$date_path = date('Ymd');
|
||||
$result = $Storage->adapter($classify->channels)->path($classify->dir_name . '/' . $date_path)->upload($file);
|
||||
\unlink($targetPath);
|
||||
$Uploads = new ModelUploads();
|
||||
$Uploads->classify_id = $classify->id;
|
||||
$Uploads->filename = $result->origin_name;
|
||||
$Uploads->path = $result->file_name;
|
||||
$Uploads->ext = $result->extension;
|
||||
$Uploads->mime = $result->mime_type;
|
||||
$Uploads->size = $result->size;
|
||||
$Uploads->channels = $classify->channels;
|
||||
$Uploads->channels_uid = $channels_uid;
|
||||
$Uploads->save();
|
||||
} catch (\Throwable $th) {
|
||||
\unlink($targetPath);
|
||||
throw $th;
|
||||
}
|
||||
$PluginShortplayDramaEpisode->video_path = $result->file_url;
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['drama_id' => $PluginShortplayDrama->id, 'episode_id' => $PluginShortplayDramaEpisode->id])->whereNotNull('image')->order('sort ASC')->find();
|
||||
$PluginShortplayDramaEpisode->cover = $PluginShortplayDramaStoryboard->image;
|
||||
$PluginShortplayDramaEpisode->save();
|
||||
} catch (\Throwable $th) {
|
||||
Log::error('合并分片失败:' . $th->getMessage(), $th->getTrace());
|
||||
}
|
||||
});
|
||||
return $this->success('合并成功');
|
||||
}
|
||||
public function update(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$D = $request->post();
|
||||
if (!empty($D['style_id'])) {
|
||||
$PluginShortplayDrama->style_id = $D['style_id'];
|
||||
}
|
||||
if (!empty($D['aspect_ratio'])) {
|
||||
$PluginShortplayDrama->aspect_ratio = $D['aspect_ratio'];
|
||||
}
|
||||
if (!empty($D['title'])) {
|
||||
$PluginShortplayDrama->title = $D['title'];
|
||||
}
|
||||
if (!empty($D['overall_hook'])) {
|
||||
$PluginShortplayDrama->overall_hook = $D['overall_hook'];
|
||||
}
|
||||
if (!empty($D['core_catharsis_mechanism'])) {
|
||||
$PluginShortplayDrama->core_catharsis_mechanism = $D['core_catharsis_mechanism'];
|
||||
}
|
||||
if (!empty($D['main_conflict'])) {
|
||||
$PluginShortplayDrama->main_conflict = $D['main_conflict'];
|
||||
}
|
||||
if (!empty($D['relationship_mainline'])) {
|
||||
$PluginShortplayDrama->relationship_mainline = $D['relationship_mainline'];
|
||||
}
|
||||
if (!empty($D['description'])) {
|
||||
$PluginShortplayDrama->description = $D['description'];
|
||||
}
|
||||
if (!empty($D['background_description'])) {
|
||||
$PluginShortplayDrama->background_description = $D['background_description'];
|
||||
}
|
||||
if (!empty($D['outline'])) {
|
||||
$PluginShortplayDrama->outline = $D['outline'];
|
||||
}
|
||||
$PluginShortplayDrama->save();
|
||||
return $this->success('更新成功');
|
||||
}
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
PluginShortplayDramaActor::where(['drama_id' => $PluginShortplayDrama->id])->delete();
|
||||
$PluginShortplayDramaEpisodes = PluginShortplayDramaEpisode::where(['drama_id' => $PluginShortplayDrama->id])->select();
|
||||
foreach ($PluginShortplayDramaEpisodes as $PluginShortplayDramaEpisode) {
|
||||
PluginShortplayDramaEpisodeActor::where(['episode_id' => $PluginShortplayDramaEpisode->id])->delete();
|
||||
$PluginShortplayDramaEpisode->delete();
|
||||
}
|
||||
PluginShortplayDramaScene::where(['drama_id' => $PluginShortplayDrama->id])->delete();
|
||||
$PluginShortplayDramaStoryboards = PluginShortplayDramaStoryboard::where(['drama_id' => $PluginShortplayDrama->id])->select();
|
||||
foreach ($PluginShortplayDramaStoryboards as $PluginShortplayDramaStoryboard) {
|
||||
PluginShortplayDramaStoryboardActor::where(['storyboard_id' => $PluginShortplayDramaStoryboard->id])->delete();
|
||||
PluginShortplayDramaStoryboardProp::where(['storyboard_id' => $PluginShortplayDramaStoryboard->id])->delete();
|
||||
$PluginShortplayDramaStoryboard->delete();
|
||||
}
|
||||
$PluginShortplayDrama->delete();
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
public function voice(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$voice = $request->post('voice');
|
||||
if (!empty($voice['emotions_enum']) && empty($voice['selected_emotion'])) {
|
||||
$voice['selected_emotion'] = $voice['emotions_enum'][0];
|
||||
}
|
||||
if (empty($voice['selected_language'])) {
|
||||
$voice['selected_language'] = VoiceLanguage::ZH;
|
||||
}
|
||||
$PluginShortplayDrama->voice = $voice;
|
||||
$PluginShortplayDrama->save();
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
return $this->success('更新成功');
|
||||
}
|
||||
public function deleteActor(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$PluginShortplayDramaActor = PluginShortplayDramaActor::where(['actor_id' => $id, 'drama_id' => $PluginShortplayDrama->id])->find();
|
||||
if (!$PluginShortplayDramaActor) {
|
||||
return $this->fail('演员不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$PluginShortplayDramaActor->delete();
|
||||
PluginShortplayDramaEpisodeActor::where(['drama_id' => $PluginShortplayDrama->id, 'actor_id' => $PluginShortplayDramaActor->actor_id])->delete();
|
||||
PluginShortplayDramaStoryboardActor::where(['drama_id' => $PluginShortplayDrama->id, 'actor_id' => $PluginShortplayDramaActor->actor_id])->delete();
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use plugin\shortplay\app\model\PluginShortplayActorCharacterLook;
|
||||
use plugin\shortplay\app\model\PluginShortplayDrama;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisode;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisodeActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboard;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayShare;
|
||||
use plugin\shortplay\app\model\PluginShortplayShareEpisode;
|
||||
use support\Request;
|
||||
use support\think\Db;
|
||||
|
||||
class DramaEpisodeController extends Basic
|
||||
{
|
||||
public function details(Request $request)
|
||||
{
|
||||
$drama_id = $request->get('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$episode_id = $request->get('episode_id');
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $episode_id, 'drama_id' => $PluginShortplayDrama->id])->with('drama')->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
$PluginShortplayDramaEpisode->is_share = PluginShortplayShareEpisode::where(['drama_id' => $PluginShortplayDrama->id, 'episode_id' => $episode_id])->count();
|
||||
return $this->resData($PluginShortplayDramaEpisode);
|
||||
}
|
||||
public function share(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$episode_id = $request->post('episode_id');
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $episode_id, 'drama_id' => $PluginShortplayDrama->id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$PluginShortplayShare = PluginShortplayShare::where(['drama_id' => $PluginShortplayDrama->id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayShare) {
|
||||
$PluginShortplayShare = new PluginShortplayShare();
|
||||
$PluginShortplayShare->drama_id = $PluginShortplayDrama->id;
|
||||
$PluginShortplayShare->uid = $request->uid;
|
||||
$PluginShortplayShare->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayShare->save();
|
||||
}
|
||||
$PluginShortplayShareEpisode = PluginShortplayShareEpisode::where(['drama_id' => $PluginShortplayDrama->id, 'episode_id' => $PluginShortplayDramaEpisode->id])->find();
|
||||
if (!$PluginShortplayShareEpisode) {
|
||||
$PluginShortplayShareEpisode = new PluginShortplayShareEpisode();
|
||||
$PluginShortplayShareEpisode->share_id = $PluginShortplayShare->id;
|
||||
$PluginShortplayShareEpisode->drama_id = $PluginShortplayDrama->id;
|
||||
$PluginShortplayShareEpisode->episode_id = $PluginShortplayDramaEpisode->id;
|
||||
$PluginShortplayShareEpisode->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayShareEpisode->save();
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
return $this->success('分享成功');
|
||||
}
|
||||
public function episodes(Request $request)
|
||||
{
|
||||
$drama_id = $request->get('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['drama_id' => $PluginShortplayDrama->id])->with(['scenes' => function ($query) {
|
||||
$query->order('sort', 'asc');
|
||||
}, 'storyboards' => function ($query) {
|
||||
$query->order('sort', 'asc');
|
||||
}])->select();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
return $this->resData($PluginShortplayDramaEpisode);
|
||||
}
|
||||
public function create(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$id = $request->post('id');
|
||||
if ($id) {
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $id, 'drama_id' => $PluginShortplayDrama->id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
throw new \Exception('分集不存在');
|
||||
}
|
||||
$msg = '更新成功';
|
||||
} else {
|
||||
$PluginShortplayDramaEpisode = new PluginShortplayDramaEpisode();
|
||||
$PluginShortplayDramaEpisode->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayDramaEpisode->uid = $request->uid;
|
||||
$PluginShortplayDramaEpisode->drama_id = $PluginShortplayDrama->id;
|
||||
$PluginShortplayDramaEpisode->episode_no = PluginShortplayDramaEpisode::where(['drama_id' => $PluginShortplayDrama->id])->max('episode_no') + 1;
|
||||
$msg = '创建成功';
|
||||
$PluginShortplayDrama->episode_num = Db::raw('episode_num + 1');
|
||||
$PluginShortplayDrama->save();
|
||||
}
|
||||
$PluginShortplayDramaEpisode->title = $request->post('title');
|
||||
$PluginShortplayDramaEpisode->content = $request->post('content');
|
||||
$PluginShortplayDramaEpisode->save();
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
return $this->success($msg);
|
||||
}
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $id, 'drama_id' => $PluginShortplayDrama->id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$PluginShortplayDramaEpisode->delete();
|
||||
# 重排分集
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['drama_id' => $drama_id])->order('episode_no asc')->select();
|
||||
$episode_no = 1;
|
||||
foreach ($PluginShortplayDramaEpisode as $PluginShortplayDramaEpisode) {
|
||||
$PluginShortplayDramaEpisode->episode_no = $episode_no;
|
||||
$PluginShortplayDramaEpisode->save();
|
||||
$episode_no++;
|
||||
}
|
||||
$PluginShortplayDrama->episode_num = Db::raw('episode_num - 1');
|
||||
$PluginShortplayDrama->save();
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
public function deleteActor(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$episode_id = $request->post('episode_id');
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $episode_id, 'drama_id' => $PluginShortplayDrama->id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
$PluginShortplayDramaEpisodeActor = PluginShortplayDramaEpisodeActor::where(['actor_id' => $id, 'episode_id' => $PluginShortplayDramaEpisode->id])->find();
|
||||
if (!$PluginShortplayDramaEpisodeActor) {
|
||||
return $this->fail('演员不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$PluginShortplayDramaEpisodeActor->delete();
|
||||
PluginShortplayDramaStoryboardActor::where(['episode_id' => $PluginShortplayDramaEpisode->id, 'actor_id' => $PluginShortplayDramaEpisodeActor->actor_id])->delete();
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
public function CharacterLook(Request $request)
|
||||
{
|
||||
$actor_id = $request->post('actor_id');
|
||||
$drama_id = $request->post('drama_id');
|
||||
$episode_id = $request->post('episode_id');
|
||||
$character_look_id = $request->post('character_look_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $episode_id, 'drama_id' => $PluginShortplayDrama->id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
$PluginShortplayDramaEpisodeActor = PluginShortplayDramaEpisodeActor::where(['episode_id' => $PluginShortplayDramaEpisode->id, 'actor_id' => $actor_id])->find();
|
||||
if (!$PluginShortplayDramaEpisodeActor) {
|
||||
return $this->fail('演员不存在');
|
||||
}
|
||||
$PluginShortplayActorCharacterLook = PluginShortplayActorCharacterLook::where(['id' => $character_look_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayActorCharacterLook) {
|
||||
return $this->fail('演员妆容不存在');
|
||||
}
|
||||
$PluginShortplayDramaEpisodeActor->character_look_id = $PluginShortplayActorCharacterLook->id;
|
||||
$PluginShortplayDramaEpisodeActor->headimg = $PluginShortplayActorCharacterLook->headimg;
|
||||
$PluginShortplayDramaEpisodeActor->three_view_image = $PluginShortplayActorCharacterLook->three_view_image;
|
||||
$PluginShortplayDramaEpisodeActor->save();
|
||||
return $this->success('设置成功');
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\enum\State;
|
||||
use plugin\control\utils\yidevs\Yidevs;
|
||||
use plugin\finance\expose\helper\Account;
|
||||
use plugin\finance\utils\enum\PointsBillScene;
|
||||
use plugin\model\app\model\PluginModel;
|
||||
use plugin\notification\expose\helper\Push;
|
||||
use plugin\shortplay\app\model\PluginShortplayActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDrama;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaActor;
|
||||
use plugin\shortplay\utils\enum\ActorAge;
|
||||
use plugin\shortplay\utils\enum\ActorGender;
|
||||
use plugin\shortplay\utils\enum\ActorSpeciesType;
|
||||
use plugin\shortplay\utils\enum\ActorStatus;
|
||||
use support\Log;
|
||||
use support\Request;
|
||||
use think\facade\Db;
|
||||
use Workerman\Coroutine;
|
||||
|
||||
class IndexController extends Basic
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return $this->success('Hello World');
|
||||
}
|
||||
public function submit(Request $request)
|
||||
{
|
||||
$post = $request->post();
|
||||
if (empty($post['script'])) {
|
||||
return $this->fail('请选择你要创建短视频或短剧');
|
||||
}
|
||||
if (empty($post['style'])) {
|
||||
return $this->fail('请选择短剧风格画风');
|
||||
}
|
||||
if (empty($post['aspect_ratio'])) {
|
||||
return $this->fail('请选择短剧比例');
|
||||
}
|
||||
if (empty($post['episode_sum'])) {
|
||||
return $this->fail('请选择短剧集数');
|
||||
}
|
||||
if (empty($post['episode_duration'])) {
|
||||
return $this->fail('请选择短剧每集时长');
|
||||
}
|
||||
$episode_sum = abs($post['episode_sum']);
|
||||
$episode_duration = abs($post['episode_duration']);
|
||||
if ($episode_sum <= 0 || $episode_sum > 500) {
|
||||
switch ($post['script']) {
|
||||
case 'script':
|
||||
$episode_sum = 1;
|
||||
$episode_duration = 300;
|
||||
break;
|
||||
case 'drama':
|
||||
$episode_sum = 80;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($episode_duration < 60 || $episode_duration > 300) {
|
||||
$episode_duration = 60;
|
||||
}
|
||||
if (empty($post['prompt'])) {
|
||||
return $this->fail('请提供一个创意想法');
|
||||
}
|
||||
if (empty($post['model'])) {
|
||||
return $this->fail('请选择模型');
|
||||
}
|
||||
$PluginModel = PluginModel::where(['id' => $post['model'], 'state' => State::YES['value']])->find();
|
||||
if (!$PluginModel) {
|
||||
return $this->fail('模型不存在');
|
||||
}
|
||||
$prompt = $post['prompt'];
|
||||
$species = [];
|
||||
$gender = [];
|
||||
$age = [];
|
||||
foreach (ActorSpeciesType::getOptions() as $value) {
|
||||
$species[] = $value['label'] . ':' . $value['value'] . '';
|
||||
}
|
||||
foreach (ActorGender::getOptions() as $value) {
|
||||
$gender[] = $value['label'] . ':' . $value['value'] . '';
|
||||
}
|
||||
foreach (ActorAge::getOptions() as $value) {
|
||||
$age[] = $value['label'] . ':' . $value['value'] . '';
|
||||
}
|
||||
$PluginShortplayDrama = new PluginShortplayDrama();
|
||||
$PluginShortplayDrama->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayDrama->uid = $request->uid;
|
||||
$PluginShortplayDrama->model_id = $PluginModel->id;
|
||||
$PluginShortplayDrama->style_id = $post['style'];
|
||||
$PluginShortplayDrama->script = $post['script'];
|
||||
$PluginShortplayDrama->aspect_ratio = $post['aspect_ratio'];
|
||||
$PluginShortplayDrama->episode_sum = $episode_sum;
|
||||
$PluginShortplayDrama->episode_duration = $episode_duration;
|
||||
$PluginShortplayDrama->state = State::NO['value'];
|
||||
$PluginShortplayDrama->save();
|
||||
$data = [
|
||||
'channels_uid' => $request->channels_uid,
|
||||
'uid' => $request->uid,
|
||||
'model_id' => $PluginModel->id,
|
||||
'amount' => $PluginModel->point,
|
||||
'uuid' => $PluginShortplayDrama->id,
|
||||
'params' => [
|
||||
'model' => $PluginModel->model_id,
|
||||
'assistant' => $PluginModel->assistant_id,
|
||||
'form_data' => [
|
||||
'prompt' => $prompt,
|
||||
'species' => implode(',', $species),
|
||||
'gender' => implode(',', $gender),
|
||||
'age' => implode(',', $age),
|
||||
'episode_sum' => $episode_sum,
|
||||
'episode_duration' => $episode_duration,
|
||||
]
|
||||
],
|
||||
];
|
||||
Coroutine::create(function () use ($data) {
|
||||
try {
|
||||
Db::startTrans();
|
||||
try {
|
||||
$ids = Account::decPoints($data['uid'], $data['channels_uid'], $data['amount'], PointsBillScene::CONSUME['value'], null, '创建短剧', true);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'event' => 'generatecreatedrama'
|
||||
], [
|
||||
'uuid' => $data['uuid'],
|
||||
'msg' => $th->getMessage()
|
||||
]);
|
||||
PluginShortplayDrama::where(['id' => $data['uuid']])->delete();
|
||||
return;
|
||||
}
|
||||
$result = Yidevs::ChatAssistantCompletions($data['channels_uid'], $data['params']);
|
||||
if (empty($result)) {
|
||||
throw new \Exception('创建短剧失败');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $data['uuid']])->find();
|
||||
$PluginShortplayDrama->state = State::YES['value'];
|
||||
$PluginShortplayDrama->title = $result['title'];
|
||||
$PluginShortplayDrama->description = $result['description'];
|
||||
$PluginShortplayDrama->background_description = $result['background_description'];
|
||||
$PluginShortplayDrama->outline = $result['outline'];
|
||||
$PluginShortplayDrama->overall_hook = $result['overall_hook'];
|
||||
$PluginShortplayDrama->core_catharsis_mechanism = $result['core_catharsis_mechanism'];
|
||||
$PluginShortplayDrama->main_conflict = $result['main_conflict'];
|
||||
$PluginShortplayDrama->relationship_mainline = $result['relationship_mainline'];
|
||||
$PluginShortplayDrama->episode_num = 0;
|
||||
$PluginShortplayDrama->save();
|
||||
if (!empty($result['actor'])) {
|
||||
$PluginShortplayActors = PluginShortplayActor::whereIn('actor_id', $result['actor'])->field('id,actor_id')->select();
|
||||
foreach ($PluginShortplayActors as $PluginShortplayActor) {
|
||||
$PluginShortplayDramaActor = new PluginShortplayDramaActor();
|
||||
$PluginShortplayDramaActor->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayDramaActor->drama_id = $PluginShortplayDrama->id;
|
||||
$PluginShortplayDramaActor->actor_id = $PluginShortplayActor->id;
|
||||
$PluginShortplayDramaActor->save();
|
||||
}
|
||||
}
|
||||
if (!empty($result['create_actor'])) {
|
||||
foreach ($result['create_actor'] as $actor) {
|
||||
$PluginShortplayActor = PluginShortplayActor::where(['name' => $actor['name'], 'channels_uid' => $data['channels_uid'], 'drama_id' => $PluginShortplayDrama->id])->field('id,actor_id')->find();
|
||||
if (!$PluginShortplayActor) {
|
||||
$PluginShortplayActor = new PluginShortplayActor();
|
||||
$PluginShortplayActor->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayActor->drama_id = $PluginShortplayDrama->id;
|
||||
$PluginShortplayActor->uid = $data['uid'];
|
||||
$PluginShortplayActor->actor_id = uniqid();
|
||||
$PluginShortplayActor->name = $actor['name'];
|
||||
$PluginShortplayActor->species_type = $actor['species'];
|
||||
$PluginShortplayActor->gender = $actor['gender'];
|
||||
$PluginShortplayActor->age = $actor['age'];
|
||||
$PluginShortplayActor->remarks = $actor['description'];
|
||||
$PluginShortplayActor->status = ActorStatus::INITIALIZING['value'];
|
||||
$PluginShortplayActor->save();
|
||||
}
|
||||
$PluginShortplayDramaActor = new PluginShortplayDramaActor();
|
||||
$PluginShortplayDramaActor->channels_uid = $data['channels_uid'];
|
||||
$PluginShortplayDramaActor->drama_id = $PluginShortplayDrama->id;
|
||||
$PluginShortplayDramaActor->actor_id = $PluginShortplayActor->id;
|
||||
$PluginShortplayDramaActor->save();
|
||||
}
|
||||
}
|
||||
Db::commit();
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'event' => 'generatecreatedrama'
|
||||
], [
|
||||
'uuid' => $data['uuid'],
|
||||
'drama_id' => $PluginShortplayDrama->id,
|
||||
'msg' => '创建短剧成功'
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
Log::error('创建短剧失败:' . $th->getMessage() . PHP_EOL . $th->getTraceAsString());
|
||||
throw $th;
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
if (!empty($ids)) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
Account::refund($data['uid'], $data['channels_uid'], $ids);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
PluginShortplayDrama::where(['id' => $data['uuid']])->delete();
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'event' => 'generatecreatedrama'
|
||||
], [
|
||||
'uuid' => $data['uuid'],
|
||||
'msg' => '创建短剧失败'
|
||||
]);
|
||||
}
|
||||
});
|
||||
return $this->resData(['uuid' => $data['uuid']]);
|
||||
/* if ($post['script'] == 'script') {
|
||||
} else {
|
||||
if (empty($post['title'])) {
|
||||
return $this->fail('请输入短剧标题');
|
||||
}
|
||||
if (empty($post['description'])) {
|
||||
return $this->fail('请输入短剧描述');
|
||||
}
|
||||
$PluginShortplayDrama = new PluginShortplayDrama();
|
||||
$PluginShortplayDrama->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayDrama->uid = $request->uid;
|
||||
$PluginShortplayDrama->style_id = $post['style'];
|
||||
$PluginShortplayDrama->script = $post['script'];
|
||||
$PluginShortplayDrama->description = $post['description'];
|
||||
$PluginShortplayDrama->title = $post['title'];
|
||||
$PluginShortplayDrama->aspect_ratio = $post['aspect_ratio'];
|
||||
$PluginShortplayDrama->episode_sum = $episode_sum;
|
||||
$PluginShortplayDrama->episode_duration = $episode_duration;
|
||||
$PluginShortplayDrama->episode_num = 0;
|
||||
if (!empty($post['model'])) {
|
||||
$PluginModel = PluginModel::where(['id' => $post['model'], 'state' => State::YES['value']])->find();
|
||||
if (!$PluginModel) {
|
||||
return $this->fail('模型不存在');
|
||||
}
|
||||
$PluginShortplayDrama->model_id = $PluginModel->id;
|
||||
}
|
||||
if (!empty($post['cover'])) {
|
||||
$PluginShortplayDrama->cover = $post['cover'];
|
||||
}
|
||||
$PluginShortplayDrama->save();
|
||||
}
|
||||
return $this->resData(['drama_id' => $PluginShortplayDrama->id]); */
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,415 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\enum\ResponseCode;
|
||||
use app\expose\enum\State;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\TransferException;
|
||||
use plugin\control\utils\yidevs\Yidevs;
|
||||
use plugin\finance\expose\helper\Account;
|
||||
use plugin\finance\utils\enum\PointsBillScene;
|
||||
use plugin\model\app\model\PluginModel;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\app\model\PluginModelTaskResult;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\model\utils\enum\ModelTaskStatus;
|
||||
use plugin\model\utils\enum\ModelType;
|
||||
use plugin\notification\expose\helper\Push;
|
||||
use plugin\shortplay\app\model\PluginShortplayProp;
|
||||
use plugin\shortplay\app\model\PluginShortplayDrama;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisode;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardProp;
|
||||
use plugin\shortplay\utils\enum\PropStatus;
|
||||
use support\Log;
|
||||
use support\Request;
|
||||
use support\think\Db;
|
||||
use Workerman\Coroutine;
|
||||
|
||||
class PropController extends Basic
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 2000);
|
||||
$type = $request->get('type');
|
||||
$where = [];
|
||||
// $where[] = ['status', '=', PropStatus::GENERATED['value']];
|
||||
$where[] = ['uid', '=', $request->uid];
|
||||
switch ($type) {
|
||||
case 'episode':
|
||||
$episode_id = $request->get('episode_id');
|
||||
if (!$episode_id) {
|
||||
return $this->fail('分集ID不能为空');
|
||||
}
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $episode_id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $PluginShortplayDramaEpisode->drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$where[] = ['episode_id', '=', $PluginShortplayDramaEpisode->id];
|
||||
break;
|
||||
case 'drama':
|
||||
$drama_id = $request->get('drama_id');
|
||||
if (!$drama_id) {
|
||||
return $this->fail('短剧ID不能为空');
|
||||
}
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$where[] = ['drama_id', '=', $PluginShortplayDrama->id];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$name = $request->get('name');
|
||||
if ($name) {
|
||||
$where[] = ['name|prop_id', 'like', '%' . $name . '%'];
|
||||
}
|
||||
$PluginShortplayProp = PluginShortplayProp::where($where)->order('id', 'desc')->limit($limit)->select()->each(function ($item) {
|
||||
// $item->status_enum = PropStatus::get($item->status);
|
||||
});
|
||||
return $this->resData($PluginShortplayProp);
|
||||
}
|
||||
public function initializing(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
|
||||
$PluginShortplayProp = PluginShortplayProp::where([
|
||||
'id' => $id,
|
||||
'uid' => $request->uid
|
||||
])->find();
|
||||
if (!$PluginShortplayProp) {
|
||||
return $this->fail('物品不存在');
|
||||
}
|
||||
$description = $request->post('description');
|
||||
if ($description) {
|
||||
$PluginShortplayProp->description = $description;
|
||||
}
|
||||
|
||||
$imageState = PluginModelTask::processing(['alias_id' => $PluginShortplayProp->id, 'scene' => ModelScene::PROP_IMAGE['value']]);
|
||||
$threeViewImageState = PluginModelTask::processing(['alias_id' => $PluginShortplayProp->id, 'scene' => ModelScene::PROP_THREE_VIEW_IMAGE['value']]);
|
||||
if ($imageState > 0 || $threeViewImageState > 0) {
|
||||
return $this->fail('物品正在生成中');
|
||||
}
|
||||
|
||||
// ===== 表单参数 =====
|
||||
$image_model_id = $request->post('image_model_id');
|
||||
$three_view_model_id = $request->post('three_view_model_id');
|
||||
$image_state = (bool)$request->post('image_state');
|
||||
$three_view_image_state = (bool)$request->post('three_view_image_state');
|
||||
$image = $request->post('image');
|
||||
$three_view_image = $request->post('three_view_image');
|
||||
$image_reference_state = (bool)$request->post('image_reference_state');
|
||||
$reference_image = $request->post('reference_image');
|
||||
if ($image_reference_state && empty($reference_image)) {
|
||||
return $this->fail('请上传参考图片');
|
||||
}
|
||||
|
||||
// ===== 是否需要 AI 生成 =====
|
||||
$needAiImage = ($PluginShortplayProp->image && $image_state) ? empty($image) : true;
|
||||
$needSkipImage = $PluginShortplayProp->image && !$image_state;
|
||||
$needAiThreeView = ($PluginShortplayProp->three_view_image && $three_view_image_state) ? empty($three_view_image) : true;
|
||||
$needSkipThreeView = $PluginShortplayProp->three_view_image && !$three_view_image_state;
|
||||
$isDoubleAi = ($needAiImage && !$needSkipImage) && ($needAiThreeView && !$needSkipThreeView);
|
||||
|
||||
$ImagePluginModel = null;
|
||||
$ThreeViewPluginModel = null;
|
||||
|
||||
// =====================================================
|
||||
// 一、模型前置校验(任何 AI 调用前)
|
||||
// =====================================================
|
||||
|
||||
// 双 AI:必须一次性校验两个模型
|
||||
if ($isDoubleAi) {
|
||||
$ImagePluginModel = PluginModel::where([
|
||||
'id' => $image_model_id,
|
||||
'scene' => ModelScene::PROP_IMAGE['value'],
|
||||
'state' => State::YES['value']
|
||||
])->find();
|
||||
|
||||
$ThreeViewPluginModel = PluginModel::where([
|
||||
'id' => $three_view_model_id,
|
||||
'scene' => ModelScene::PROP_THREE_VIEW_IMAGE['value'],
|
||||
'state' => State::YES['value']
|
||||
])->find();
|
||||
|
||||
if (!$ImagePluginModel || !$ThreeViewPluginModel) {
|
||||
return $this->fail('模型不存在');
|
||||
}
|
||||
} else {
|
||||
// 单独 image AI
|
||||
if ($needAiImage && !$needSkipImage) {
|
||||
$ImagePluginModel = PluginModel::where([
|
||||
'id' => $image_model_id,
|
||||
'scene' => ModelScene::PROP_IMAGE['value'],
|
||||
'state' => State::YES['value']
|
||||
])->find();
|
||||
|
||||
if (!$ImagePluginModel) {
|
||||
return $this->fail('物品图片模型不存在');
|
||||
}
|
||||
}
|
||||
|
||||
// 单独 three view AI
|
||||
if ($needAiThreeView && !$needSkipThreeView) {
|
||||
$ThreeViewPluginModel = PluginModel::where([
|
||||
'id' => $three_view_model_id,
|
||||
'scene' => ModelScene::PROP_THREE_VIEW_IMAGE['value'],
|
||||
'state' => State::YES['value']
|
||||
])->find();
|
||||
|
||||
if (!$ThreeViewPluginModel) {
|
||||
return $this->fail('物品三视图模型不存在');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// 二、物品图片 AI 生成
|
||||
// =====================================================
|
||||
|
||||
$lockImage = false;
|
||||
$taskId = null;
|
||||
if (!$needSkipImage) {
|
||||
if ($needAiImage) {
|
||||
$lockImage = true;
|
||||
$data = [
|
||||
'assistant' => $ImagePluginModel->assistant_id,
|
||||
'model' => $ImagePluginModel->model_id,
|
||||
'notify_url' => 'https://' . $request->host() . '/app/model/Notify/draw',
|
||||
'form_data' => [
|
||||
'prompt' => $PluginShortplayProp->description,
|
||||
'aspect_ratio' => '1:1',
|
||||
]
|
||||
];
|
||||
if ($image_reference_state) {
|
||||
$data['form_data']['images'] = [$reference_image];
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$consume_ids = Account::decPoints($request->uid, $request->channels_uid, $ImagePluginModel->point, PointsBillScene::CONSUME['value'], null, '生成物品图片', true);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
try {
|
||||
$result = Yidevs::DrawAssistantTIGI($request->channels_uid, $data);
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$task = new PluginModelTask();
|
||||
$task->channels_uid = $request->channels_uid;
|
||||
$task->uid = $request->uid;
|
||||
$task->model_id = $ImagePluginModel->id;
|
||||
$task->model_type = ModelType::DRAW['value'];
|
||||
$task->alias_id = $PluginShortplayProp->id;
|
||||
$task->scene = ModelScene::PROP_IMAGE['value'];
|
||||
$task->status = ModelTaskStatus::PROCESSING['value'];
|
||||
$task->task_id = $result['task_id'];
|
||||
$task->last_heartbeat = date('Y-m-d H:i:s');
|
||||
$task->consume_ids = $consume_ids;
|
||||
$task->save();
|
||||
$taskId = $task->id;
|
||||
$taskResult = new PluginModelTaskResult();
|
||||
$taskResult->task_id = $task->id;
|
||||
$taskResult->channels_uid = $request->channels_uid;
|
||||
$taskResult->params = $data;
|
||||
$taskResult->save();
|
||||
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw $e;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
if (!empty($consume_ids)) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
Account::refund($request->uid, $request->channels_uid, $consume_ids);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
Log::error('GeneratePropImage Error:' . $e->getMessage());
|
||||
return $this->fail('物品图片生成失败');
|
||||
}
|
||||
$PluginShortplayProp->image = null;
|
||||
}
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// 三、物品三视图 AI 生成
|
||||
// =====================================================
|
||||
if (!$needSkipThreeView) {
|
||||
if ($needAiThreeView) {
|
||||
$data = [
|
||||
'assistant' => $ThreeViewPluginModel->assistant_id,
|
||||
'model' => $ThreeViewPluginModel->model_id,
|
||||
'notify_url' => 'https://' . $request->host() . '/app/model/Notify/draw',
|
||||
'form_data' => [
|
||||
'prompt' => $PluginShortplayProp->description,
|
||||
'aspect_ratio' => '1:1',
|
||||
]
|
||||
];
|
||||
|
||||
// 非 image AI 场景,必须依赖已有形象
|
||||
if (!$lockImage) {
|
||||
if (!$PluginShortplayProp->image) {
|
||||
return $this->fail('请先生成物品图片,再生成物品三视图');
|
||||
}
|
||||
$data['form_data']['images'] = [$PluginShortplayProp->image];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$consume_ids = Account::decPoints($request->uid, $request->channels_uid, $ThreeViewPluginModel->point, PointsBillScene::CONSUME['value'], null, '生成物品三视图', true);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
try {
|
||||
if (!$lockImage) {
|
||||
$result = Yidevs::DrawAssistantTIGI($request->channels_uid, $data);
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$task = new PluginModelTask();
|
||||
$task->channels_uid = $request->channels_uid;
|
||||
$task->uid = $request->uid;
|
||||
$task->model_id = $ThreeViewPluginModel->id;
|
||||
$task->model_type = ModelType::DRAW['value'];
|
||||
$task->alias_id = $PluginShortplayProp->id;
|
||||
$task->scene = ModelScene::PROP_THREE_VIEW_IMAGE['value'];
|
||||
$task->pre_task_id = $taskId;
|
||||
$task->status = $lockImage
|
||||
? ModelTaskStatus::WAIT['value']
|
||||
: ModelTaskStatus::PROCESSING['value'];
|
||||
$task->task_id = $lockImage ? null : $result['task_id'];
|
||||
$task->last_heartbeat = date('Y-m-d H:i:s');
|
||||
$task->consume_ids = $consume_ids;
|
||||
$task->save();
|
||||
|
||||
$taskResult = new PluginModelTaskResult();
|
||||
$taskResult->task_id = $task->id;
|
||||
$taskResult->channels_uid = $request->channels_uid;
|
||||
$taskResult->params = $data;
|
||||
$taskResult->save();
|
||||
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw $e;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
if (!empty($consume_ids)) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
Account::refund($request->uid, $request->channels_uid, $consume_ids);
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
Log::error('GeneratePropThreeView Error:' . $e->getMessage());
|
||||
return $this->fail('物品三视图生成失败');
|
||||
}
|
||||
$PluginShortplayProp->three_view_image = null;
|
||||
}
|
||||
}
|
||||
$PluginShortplayProp->save();
|
||||
|
||||
$PluginShortplayProp = PluginShortplayProp::where(['id' => $PluginShortplayProp->id])->find();
|
||||
return $this->resData($PluginShortplayProp);
|
||||
}
|
||||
public function update(Request $request)
|
||||
{
|
||||
$msg = '更新成功';
|
||||
Db::startTrans();
|
||||
try {
|
||||
$id = $request->post('id');
|
||||
if ($id) {
|
||||
$PluginShortplayProp = PluginShortplayProp::where(['id' => $id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayProp) {
|
||||
throw new \Exception('物品不存在');
|
||||
}
|
||||
} else {
|
||||
$PluginShortplayProp = new PluginShortplayProp();
|
||||
$PluginShortplayProp->uid = $request->uid;
|
||||
$PluginShortplayProp->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayProp->status = PropStatus::INITIALIZING['value'];
|
||||
$drama_id = $request->post('drama_id');
|
||||
if ($drama_id) {
|
||||
$PluginShortplayProp->drama_id = $drama_id;
|
||||
}
|
||||
$episode_id = $request->post('episode_id');
|
||||
if ($episode_id) {
|
||||
$PluginShortplayProp->episode_id = $episode_id;
|
||||
}
|
||||
$msg = '创建成功';
|
||||
$PluginShortplayProp->prop_id = uniqid();
|
||||
}
|
||||
$PluginShortplayProp->name = $request->post('name');
|
||||
$PluginShortplayProp->image = $request->post('image');
|
||||
$PluginShortplayProp->description = $request->post('description');
|
||||
$PluginShortplayProp->three_view_image = $request->post('three_view_image');
|
||||
$PluginShortplayProp->save();
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
return $this->success($msg, $PluginShortplayProp);
|
||||
}
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$PluginShortplayProp = PluginShortplayProp::where(['id' => $id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayProp) {
|
||||
return $this->fail('物品不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
PluginShortplayDramaStoryboardProp::where(['prop_id' => $PluginShortplayProp->id])->delete();
|
||||
$PluginShortplayProp->delete();
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
public function ReplaceProp(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$task_id = $request->post('task_id');
|
||||
$PluginShortplayProp = PluginShortplayProp::where(['id' => $id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayProp) {
|
||||
return $this->fail('物品不存在');
|
||||
}
|
||||
$PluginModelTask = PluginModelTask::where(['id' => $task_id, 'alias_id' => $PluginShortplayProp->id, 'scene' => ModelScene::PROP_IMAGE['value'], 'status' => ModelTaskStatus::SUCCESS['value']])->find();
|
||||
if (!$PluginModelTask) {
|
||||
return $this->fail('任务不存在');
|
||||
}
|
||||
$PluginShortplayProp->image = $PluginModelTask->result->image_path;
|
||||
$PluginModelTask = PluginModelTask::where(['pre_task_id' => $PluginModelTask->id, 'alias_id' => $PluginShortplayProp->id, 'scene' => ModelScene::PROP_THREE_VIEW_IMAGE['value'], 'status' => ModelTaskStatus::SUCCESS['value']])->find();
|
||||
if ($PluginModelTask) {
|
||||
$PluginShortplayProp->three_view_image = $PluginModelTask->result->image_path;
|
||||
$PluginShortplayProp->status = PropStatus::GENERATED['value'];
|
||||
} else {
|
||||
$PluginShortplayProp->status = PropStatus::INITIALIZING['value'];
|
||||
$PluginShortplayProp->three_view_image = null;
|
||||
}
|
||||
$PluginShortplayProp->save();
|
||||
$PluginShortplayProp = PluginShortplayProp::where(['id' => $id])->find();
|
||||
return $this->resData($PluginShortplayProp);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use plugin\shortplay\app\model\PluginShortplayDrama;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaScene;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboard;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardProp;
|
||||
use support\Request;
|
||||
use support\think\Db;
|
||||
|
||||
class SceneController extends Basic
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$drama_id = $request->get('drama_id');
|
||||
$episode_id = $request->get('episode_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$PluginShortplayDramaScenes = PluginShortplayDramaScene::where(['drama_id' => $PluginShortplayDrama->id, 'episode_id' => $episode_id])->order('sort asc')->select();
|
||||
return $this->resData($PluginShortplayDramaScenes);
|
||||
}
|
||||
public function updateSort(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$scenes = $request->post('scenes');
|
||||
if (empty($scenes)) {
|
||||
$id = $request->post('id');
|
||||
$sort = $request->post('sort');
|
||||
$PluginShortplayDramaScene = PluginShortplayDramaScene::where(['drama_id' => $PluginShortplayDrama->id, 'id' => $id])->find();
|
||||
if (!$PluginShortplayDramaScene) {
|
||||
return $this->fail('场景不存在');
|
||||
}
|
||||
$PluginShortplayDramaScene->sort = $sort;
|
||||
$PluginShortplayDramaScene->save();
|
||||
} else {
|
||||
Db::startTrans();
|
||||
try {
|
||||
foreach ($scenes as $scene) {
|
||||
$PluginShortplayDramaScene = PluginShortplayDramaScene::where(['drama_id' => $PluginShortplayDrama->id, 'id' => $scene['id']])->find();
|
||||
if (!$PluginShortplayDramaScene) {
|
||||
continue;
|
||||
}
|
||||
$PluginShortplayDramaScene->sort = $scene['sort'];
|
||||
$PluginShortplayDramaScene->save();
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
}
|
||||
return $this->success('更新成功');
|
||||
}
|
||||
public function copyScene(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$episode_id = $request->post('episode_id');
|
||||
$scene_id = $request->post('scene_id');
|
||||
|
||||
// 校验短剧
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where([
|
||||
'id' => $drama_id,
|
||||
'uid' => $request->uid
|
||||
])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
|
||||
// 校验原场景
|
||||
$origin = PluginShortplayDramaScene::where([
|
||||
'drama_id' => $drama_id,
|
||||
'id' => $scene_id
|
||||
])->find();
|
||||
if (!$origin) {
|
||||
return $this->fail('原场景不存在');
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 3. 插入复制后的场景
|
||||
unset($origin['id']); // 删除原场景ID
|
||||
$origin['sort'] = PluginShortplayDramaScene::where(['drama_id' => $drama_id, 'episode_id' => $episode_id])->max('sort') + 1 ?? 1;
|
||||
$origin['create_time'] = time();
|
||||
$origin['update_time'] = time();
|
||||
$origin['episode_id'] = $episode_id;
|
||||
$PluginShortplayDramaScene = new PluginShortplayDramaScene;
|
||||
$PluginShortplayDramaScene->save($origin);
|
||||
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
|
||||
return $this->resData($PluginShortplayDramaScene);
|
||||
}
|
||||
public function deleteScene(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$episode_id = $request->post('episode_id');
|
||||
$id = $request->post('id');
|
||||
|
||||
// 校验短剧是否存在
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where([
|
||||
'id' => $drama_id,
|
||||
'uid' => $request->uid
|
||||
])->find();
|
||||
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
if ($id) {
|
||||
// 校验场景是否存在
|
||||
$PluginShortplayDramaScene = PluginShortplayDramaScene::where([
|
||||
'id' => $id,
|
||||
'drama_id' => $drama_id,
|
||||
'episode_id' => $episode_id
|
||||
])->find();
|
||||
|
||||
if (!$PluginShortplayDramaScene) {
|
||||
return $this->fail('场景不存在');
|
||||
}
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
if ($id) {
|
||||
// 1. 删除该场景
|
||||
PluginShortplayDramaScene::where([
|
||||
'id' => $id,
|
||||
'drama_id' => $drama_id
|
||||
])->delete();
|
||||
PluginShortplayDramaStoryboard::where([
|
||||
'drama_id' => $drama_id,
|
||||
'scene_id' => $PluginShortplayDramaScene->id
|
||||
])->update(['scene_id' => null]);
|
||||
|
||||
|
||||
// 2. 重新拉取该 episode 的所有场景并重排 sort
|
||||
$PluginShortplayDramaScenes = PluginShortplayDramaScene::where([
|
||||
'drama_id' => $drama_id,
|
||||
'episode_id' => $episode_id
|
||||
])
|
||||
->order('sort asc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$sort = 1;
|
||||
foreach ($PluginShortplayDramaScenes as $sb) {
|
||||
PluginShortplayDramaScene::where(['id' => $sb['id']])
|
||||
->update(['sort' => $sort++]);
|
||||
}
|
||||
} else {
|
||||
$PluginShortplayDramaScenes = PluginShortplayDramaScene::where(['drama_id' => $drama_id, 'episode_id' => $episode_id])->order('sort asc')->select();
|
||||
foreach ($PluginShortplayDramaScenes as $scene) {
|
||||
PluginShortplayDramaStoryboard::where(['drama_id' => $drama_id, 'scene_id' => $scene->id])->update(['scene_id' => null]);
|
||||
$scene->delete();
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
public function insertAfter(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$episode_id = $request->post('episode_id');
|
||||
$after_id = $request->post('after_id');
|
||||
|
||||
$drama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$drama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
|
||||
$afterSort = 0;
|
||||
if ($after_id) {
|
||||
$after = PluginShortplayDramaScene::where([
|
||||
'drama_id' => $drama->id,
|
||||
'id' => $after_id,
|
||||
'episode_id' => $episode_id
|
||||
])->find();
|
||||
|
||||
if (!$after) {
|
||||
return $this->fail('指定的场景不存在');
|
||||
}
|
||||
$afterSort = $after->sort;
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 从 after.sort + 1 开始,所有后续 +1
|
||||
PluginShortplayDramaScene::where([
|
||||
'drama_id' => $drama_id,
|
||||
'episode_id' => $episode_id
|
||||
])
|
||||
->where('sort', '>', $afterSort)
|
||||
->inc('sort', 1)
|
||||
->update();
|
||||
|
||||
// 插入新的空白场景
|
||||
$new = new PluginShortplayDramaScene();
|
||||
$new->channels_uid = $request->channels_uid;
|
||||
$new->drama_id = $drama->id;
|
||||
$new->episode_id = $episode_id;
|
||||
$new->sort = $afterSort + 1;
|
||||
$new->save();
|
||||
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
|
||||
return $this->success('插入成功', ['id' => $new->id]);
|
||||
}
|
||||
public function update(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$episode_id = $request->post('episode_id');
|
||||
$id = $request->post('id');
|
||||
$D = $request->post();
|
||||
if ($id) {
|
||||
$PluginShortplayDramaScene = PluginShortplayDramaScene::where(['id' => $id, 'drama_id' => $drama_id, 'episode_id' => $episode_id])->find();
|
||||
if (!$PluginShortplayDramaScene) {
|
||||
return $this->fail('场景不存在');
|
||||
}
|
||||
} else {
|
||||
$PluginShortplayDramaScene = new PluginShortplayDramaScene();
|
||||
$PluginShortplayDramaScene->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayDramaScene->uid = $request->uid;
|
||||
$PluginShortplayDramaScene->drama_id = $drama_id;
|
||||
$PluginShortplayDramaScene->episode_id = $episode_id;
|
||||
$PluginShortplayDramaScene->sort = PluginShortplayDramaScene::where(['drama_id' => $drama_id, 'episode_id' => $episode_id])->max('sort') + 1 ?? 1;
|
||||
}
|
||||
if (!empty($D['title'])) {
|
||||
$PluginShortplayDramaScene->title = $D['title'];
|
||||
}
|
||||
if (!empty($D['scene_space'])) {
|
||||
$PluginShortplayDramaScene->scene_space = $D['scene_space'];
|
||||
}
|
||||
if (!empty($D['scene_location'])) {
|
||||
$PluginShortplayDramaScene->scene_location = $D['scene_location'];
|
||||
}
|
||||
if (!empty($D['scene_time'])) {
|
||||
$PluginShortplayDramaScene->scene_time = $D['scene_time'];
|
||||
}
|
||||
if (!empty($D['scene_weather'])) {
|
||||
$PluginShortplayDramaScene->scene_weather = $D['scene_weather'];
|
||||
}
|
||||
if (!empty($D['description'])) {
|
||||
$PluginShortplayDramaScene->description = $D['description'];
|
||||
}
|
||||
if (!empty($D['atmosphere'])) {
|
||||
$PluginShortplayDramaScene->atmosphere = $D['atmosphere'];
|
||||
}
|
||||
if (!empty($D['image'])) {
|
||||
$PluginShortplayDramaScene->image = $D['image'];
|
||||
}
|
||||
$PluginShortplayDramaScene->save();
|
||||
return $this->resData($PluginShortplayDramaScene);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisode;
|
||||
use plugin\shortplay\app\model\PluginShortplayShare;
|
||||
use plugin\shortplay\app\model\PluginShortplayShareEpisode;
|
||||
use plugin\shortplay\app\model\PluginShortplayShareLikes;
|
||||
use plugin\user\app\model\PluginUser;
|
||||
use support\Request;
|
||||
use think\facade\Db;
|
||||
|
||||
class SquareController extends Basic
|
||||
{
|
||||
protected $notNeedLogin = ['index', 'details'];
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$uid = $request->uid;
|
||||
$PluginShortplayShare = PluginShortplayShare::with(['drama' => function ($query) {
|
||||
$query->field('id,channels_uid,title,cover');
|
||||
}, 'user' => function ($query) {
|
||||
$query->field('id,channels_uid,nickname,headimg');
|
||||
}])->order('update_time desc,id desc')->paginate($limit)->each(function ($item) use ($uid) {
|
||||
$item->is_likes = false;
|
||||
if ($uid) {
|
||||
$item->is_likes = PluginShortplayShareLikes::where(['share_id' => $item->id, 'uid' => $uid])->count() > 0;
|
||||
}
|
||||
$item->episode = PluginShortplayShareEpisode::where(['share_id' => $item->id])->find();
|
||||
$item->episode_num = PluginShortplayShareEpisode::where(['share_id' => $item->id])->count();
|
||||
});
|
||||
if ($PluginShortplayShare->isEmpty()) {
|
||||
return $this->fail('暂无数据');
|
||||
}
|
||||
return $this->resData($PluginShortplayShare);
|
||||
}
|
||||
public function details(Request $request)
|
||||
{
|
||||
$drama_id = $request->get('drama_id');
|
||||
$episode_id = $request->get('episode_id');
|
||||
$PluginShortplayShare = PluginShortplayShare::where(['drama_id' => $drama_id])->find();
|
||||
if (!$PluginShortplayShare) {
|
||||
return $this->fail('分享不存在');
|
||||
}
|
||||
$PluginShortplayShareEpisode = PluginShortplayShareEpisode::where(['share_id' => $PluginShortplayShare->id, 'episode_id' => $episode_id])->find();
|
||||
if (!$PluginShortplayShareEpisode) {
|
||||
return $this->fail('分享分集不存在');
|
||||
}
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $PluginShortplayShareEpisode->episode_id, 'drama_id' => $PluginShortplayShare->drama_id])->with(['drama' => function ($query) {
|
||||
$query->field('id,channels_uid,title,cover,description');
|
||||
}])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
$PluginShortplayDramaEpisode->user = PluginUser::where(['id' => $PluginShortplayShare->uid])->field('channels_uid,headimg,nickname')->find();
|
||||
$PluginShortplayDramaEpisode->share = $PluginShortplayShare;
|
||||
$PluginShortplayDramaEpisode->is_likes = false;
|
||||
if ($request->uid) {
|
||||
$PluginShortplayDramaEpisode->is_likes = PluginShortplayShareLikes::where(['share_id' => $PluginShortplayShare->id, 'uid' => $request->uid])->count() > 0;
|
||||
}
|
||||
return $this->resData($PluginShortplayDramaEpisode);
|
||||
}
|
||||
public function episodes(Request $request)
|
||||
{
|
||||
$drama_id = $request->get('drama_id');
|
||||
$PluginShortplayShare = PluginShortplayShare::where(['drama_id' => $drama_id])->find();
|
||||
if (!$PluginShortplayShare) {
|
||||
return $this->fail('分享不存在');
|
||||
}
|
||||
$PluginShortplayShareEpisode = PluginShortplayShareEpisode::alias('a')->where(['a.share_id' => $PluginShortplayShare->id])
|
||||
->join('PluginShortplayDramaEpisode e', 'e.id=a.episode_id')
|
||||
->field('a.*,e.episode_no')
|
||||
->order('e.episode_no asc')
|
||||
->select();
|
||||
return $this->resData($PluginShortplayShareEpisode);
|
||||
}
|
||||
public function likes(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayShare = PluginShortplayShare::where(['drama_id' => $drama_id])->find();
|
||||
if (!$PluginShortplayShare) {
|
||||
return $this->fail('分享不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$PluginShortplayShareLikes = PluginShortplayShareLikes::where(['share_id' => $PluginShortplayShare->id, 'uid' => $request->uid])->find();
|
||||
if ($PluginShortplayShareLikes) {
|
||||
$PluginShortplayShare->likes = Db::raw('likes-1');
|
||||
$PluginShortplayShare->save();
|
||||
$PluginShortplayShareLikes->delete();
|
||||
} else {
|
||||
$PluginShortplayShare->likes = Db::raw('likes+1');
|
||||
$PluginShortplayShare->save();
|
||||
$PluginShortplayShareLikes = new PluginShortplayShareLikes();
|
||||
$PluginShortplayShareLikes->share_id = $PluginShortplayShare->id;
|
||||
$PluginShortplayShareLikes->uid = $request->uid;
|
||||
$PluginShortplayShareLikes->save();
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
$PluginShortplayShare = PluginShortplayShare::where(['id' => $PluginShortplayShare->id])->find();
|
||||
return $this->resData($PluginShortplayShare);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,780 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\model\utils\enum\ModelTaskStatus;
|
||||
use plugin\notification\expose\helper\Push;
|
||||
use plugin\shortplay\app\model\PluginShortplayActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayActorCharacterLook;
|
||||
use plugin\shortplay\app\model\PluginShortplayDrama;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisode;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisodeActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboard;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardDialogue;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardProp;
|
||||
use plugin\shortplay\app\model\PluginShortplayProp;
|
||||
use plugin\shortplay\utils\enum\ActorStatus;
|
||||
use plugin\shortplay\utils\enum\PropStatus;
|
||||
use support\Cache;
|
||||
use support\Log;
|
||||
use support\Request;
|
||||
use support\think\Db;
|
||||
use Workerman\Coroutine;
|
||||
|
||||
class StoryboardController extends Basic
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$type = $request->get('type');
|
||||
$where = [];
|
||||
switch ($type) {
|
||||
case 'episode':
|
||||
$episode_id = $request->get('episode_id');
|
||||
if (!$episode_id) {
|
||||
return $this->fail('分集ID不能为空');
|
||||
}
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $episode_id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $PluginShortplayDramaEpisode->drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$where[] = ['episode_id', '=', $PluginShortplayDramaEpisode->id];
|
||||
break;
|
||||
case 'drama':
|
||||
break;
|
||||
default:
|
||||
$drama_id = $request->get('drama_id');
|
||||
if (!$drama_id) {
|
||||
return $this->fail('短剧ID不能为空');
|
||||
}
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$where[] = ['drama_id', '=', $PluginShortplayDrama->id];
|
||||
break;
|
||||
}
|
||||
$description = $request->get('description');
|
||||
if ($description) {
|
||||
$where[] = ['description', 'like', '%' . $description . '%'];
|
||||
}
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where($where)->with(['sceneFind', 'props', 'dialogues'])->order('sort asc,id asc')->select()->each(function ($item) {});
|
||||
return $this->resData($PluginShortplayDramaStoryboard);
|
||||
}
|
||||
public function updateSort(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$storyboards = $request->post('storyboards');
|
||||
if (empty($storyboards)) {
|
||||
$id = $request->post('id');
|
||||
$sort = $request->post('sort');
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['drama_id' => $PluginShortplayDrama->id, 'id' => $id])->find();
|
||||
if (!$PluginShortplayDramaStoryboard) {
|
||||
return $this->fail('分镜不存在');
|
||||
}
|
||||
$PluginShortplayDramaStoryboard->sort = $sort;
|
||||
$PluginShortplayDramaStoryboard->save();
|
||||
} else {
|
||||
Db::startTrans();
|
||||
try {
|
||||
foreach ($storyboards as $storyboard) {
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['drama_id' => $PluginShortplayDrama->id, 'id' => $storyboard['id']])->find();
|
||||
if (!$PluginShortplayDramaStoryboard) {
|
||||
continue;
|
||||
}
|
||||
$PluginShortplayDramaStoryboard->sort = $storyboard['sort'];
|
||||
$PluginShortplayDramaStoryboard->save();
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
}
|
||||
return $this->success('更新成功');
|
||||
}
|
||||
public function copyStoryboard(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$copy_id = $request->post('copy_id'); // 要复制的 storyboard ID
|
||||
$new_sort = $request->post('new_sort');
|
||||
|
||||
// 校验短剧
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where([
|
||||
'id' => $drama_id,
|
||||
'uid' => $request->uid
|
||||
])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
|
||||
// 校验原分镜
|
||||
$origin = PluginShortplayDramaStoryboard::where([
|
||||
'drama_id' => $drama_id,
|
||||
'id' => $copy_id
|
||||
])->find();
|
||||
if (!$origin) {
|
||||
return $this->fail('原分镜不存在');
|
||||
}
|
||||
|
||||
// 校验 new_sort
|
||||
if (!$new_sort || !is_numeric($new_sort)) {
|
||||
return $this->fail('new_sort 不合法');
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 1. 查询当前 scene 内所有分镜
|
||||
$sceneStoryboards = PluginShortplayDramaStoryboard::where([
|
||||
'drama_id' => $drama_id,
|
||||
'episode_id' => $origin->episode_id,
|
||||
])
|
||||
->order('sort asc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 2. 将 sort >= new_sort 的分镜全部 +1
|
||||
foreach ($sceneStoryboards as $sb) {
|
||||
if ($sb['sort'] >= $new_sort) {
|
||||
PluginShortplayDramaStoryboard::where(['id' => $sb['id']])
|
||||
->update(['sort' => $sb['sort'] + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 插入复制后的分镜
|
||||
unset($origin['id']); // 删除原分镜ID
|
||||
$origin['sort'] = $new_sort;
|
||||
$origin['create_time'] = time();
|
||||
$origin['update_time'] = time();
|
||||
$PluginShortplayDramaStoryboard = new PluginShortplayDramaStoryboard;
|
||||
$PluginShortplayDramaStoryboard->save($origin);
|
||||
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $PluginShortplayDramaStoryboard->id])->with(['actors', 'sceneFind', 'props', 'dialogues'])->find();
|
||||
return $this->resData($PluginShortplayDramaStoryboard);
|
||||
}
|
||||
public function deleteStoryboard(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$episode_id = $request->post('episode_id');
|
||||
$id = $request->post('id');
|
||||
|
||||
// 校验短剧是否存在
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where([
|
||||
'id' => $drama_id,
|
||||
'uid' => $request->uid
|
||||
])->find();
|
||||
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where([
|
||||
'id' => $episode_id,
|
||||
'drama_id' => $drama_id
|
||||
])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
if ($id) {
|
||||
// 校验分镜是否存在
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where([
|
||||
'id' => $id,
|
||||
'drama_id' => $drama_id,
|
||||
])->find();
|
||||
|
||||
if (!$PluginShortplayDramaStoryboard) {
|
||||
return $this->fail('分镜不存在');
|
||||
}
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
if ($id) {
|
||||
PluginShortplayDramaStoryboardActor::where(['storyboard_id' => $PluginShortplayDramaStoryboard->id])->delete();
|
||||
PluginShortplayDramaStoryboardDialogue::where(['storyboard_id' => $PluginShortplayDramaStoryboard->id])->delete();
|
||||
$PluginShortplayDramaStoryboardProps = PluginShortplayDramaStoryboardProp::where(['storyboard_id' => $PluginShortplayDramaStoryboard->id])->select();
|
||||
foreach ($PluginShortplayDramaStoryboardProps as $PluginShortplayDramaStoryboardProp) {
|
||||
PluginShortplayProp::where(['id' => $PluginShortplayDramaStoryboardProp->prop_id, 'status' => PropStatus::INITIALIZING['value']])->delete();
|
||||
$PluginShortplayDramaStoryboardProp->delete();
|
||||
}
|
||||
$PluginShortplayDramaStoryboard->delete();
|
||||
$PluginShortplayDramaStoryboards = PluginShortplayDramaStoryboard::where([
|
||||
'drama_id' => $drama_id,
|
||||
'episode_id' => $episode_id,
|
||||
])
|
||||
->order('sort asc')
|
||||
->select();
|
||||
|
||||
$sort = 1;
|
||||
foreach ($PluginShortplayDramaStoryboards as $sb) {
|
||||
$sb->sort = $sort++;
|
||||
$sb->save();
|
||||
}
|
||||
} else {
|
||||
$PluginShortplayDramaStoryboards = PluginShortplayDramaStoryboard::where([
|
||||
'drama_id' => $drama_id,
|
||||
'episode_id' => $episode_id,
|
||||
])->select();
|
||||
foreach ($PluginShortplayDramaStoryboards as $PluginShortplayDramaStoryboard) {
|
||||
PluginShortplayDramaStoryboardActor::where(['storyboard_id' => $PluginShortplayDramaStoryboard->id])->delete();
|
||||
PluginShortplayDramaStoryboardDialogue::where(['storyboard_id' => $PluginShortplayDramaStoryboard->id])->delete();
|
||||
PluginShortplayDramaStoryboardProp::where(['storyboard_id' => $PluginShortplayDramaStoryboard->id])->delete();
|
||||
$PluginShortplayDramaStoryboard->delete();
|
||||
}
|
||||
PluginShortplayProp::where(['episode_id' => $PluginShortplayDramaEpisode->id, 'status' => PropStatus::INITIALIZING['value']])->delete();
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
public function insertAfter(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$episode_id = $request->post('episode_id');
|
||||
$after_id = $request->post('after_id');
|
||||
|
||||
$drama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$drama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$afterSort = 0;
|
||||
if ($after_id) {
|
||||
$after = PluginShortplayDramaStoryboard::where([
|
||||
'drama_id' => $drama->id,
|
||||
'id' => $after_id,
|
||||
])->find();
|
||||
|
||||
if (!$after) {
|
||||
return $this->fail('指定的分镜不存在');
|
||||
}
|
||||
$afterSort = $after->sort;
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 从 after.sort + 1 开始,所有后续 +1
|
||||
PluginShortplayDramaStoryboard::where([
|
||||
'drama_id' => $drama_id,
|
||||
'episode_id' => $episode_id,
|
||||
])
|
||||
->where('sort', '>', $afterSort)
|
||||
->inc('sort', 1)
|
||||
->update();
|
||||
|
||||
// 插入新的空白分镜
|
||||
$new = new PluginShortplayDramaStoryboard();
|
||||
$new->channels_uid = $request->channels_uid;
|
||||
$new->drama_id = $drama->id;
|
||||
$new->episode_id = $episode_id;
|
||||
$new->sort = $afterSort + 1;
|
||||
$new->duration = 5000;
|
||||
$new->save();
|
||||
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $new->id])->with(['actors', 'sceneFind', 'props', 'dialogues'])->find();
|
||||
return $this->resData($PluginShortplayDramaStoryboard);
|
||||
}
|
||||
public function update(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$episode_id = $request->post('episode_id');
|
||||
$id = $request->post('id');
|
||||
$D = $request->post();
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $id, 'drama_id' => $drama_id, 'episode_id' => $episode_id])->find();
|
||||
if (!$PluginShortplayDramaStoryboard) {
|
||||
return $this->fail('分镜不存在');
|
||||
}
|
||||
if (!empty($D['scene_id'])) {
|
||||
$PluginShortplayDramaStoryboard->scene_id = $D['scene_id'];
|
||||
}
|
||||
if (!empty($D['description'])) {
|
||||
$PluginShortplayDramaStoryboard->description = $D['description'];
|
||||
}
|
||||
if (!empty($D['shot_type'])) {
|
||||
$PluginShortplayDramaStoryboard->shot_type = $D['shot_type'];
|
||||
}
|
||||
if (!empty($D['shot_angle'])) {
|
||||
$PluginShortplayDramaStoryboard->shot_angle = $D['shot_angle'];
|
||||
}
|
||||
if (!empty($D['shot_motion'])) {
|
||||
$PluginShortplayDramaStoryboard->shot_motion = $D['shot_motion'];
|
||||
}
|
||||
if (!empty($D['image'])) {
|
||||
$PluginShortplayDramaStoryboard->image = $D['image'];
|
||||
$PluginShortplayDramaStoryboard->use_material_type = 'image';
|
||||
}
|
||||
if (!empty($D['video'])) {
|
||||
$PluginShortplayDramaStoryboard->video = $D['video'];
|
||||
$PluginShortplayDramaStoryboard->use_material_type = 'video';
|
||||
}
|
||||
if (isset($D['narration'])) {
|
||||
$PluginShortplayDramaStoryboard->narration = $D['narration'];
|
||||
}
|
||||
if (isset($D['sfx'])) {
|
||||
$PluginShortplayDramaStoryboard->sfx = $D['sfx'];
|
||||
}
|
||||
$PluginShortplayDramaStoryboard->save();
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $PluginShortplayDramaStoryboard->id])->with(['actors', 'sceneFind', 'props', 'dialogues'])->find();
|
||||
return $this->resData($PluginShortplayDramaStoryboard);
|
||||
}
|
||||
public function joinActor(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$storyboard_id = $request->post('storyboard_id');
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $storyboard_id, 'drama_id' => $drama_id])->find();
|
||||
if (!$PluginShortplayDramaStoryboard) {
|
||||
return $this->fail('分镜不存在');
|
||||
}
|
||||
$actor_id = $request->post('actor_id');
|
||||
$PluginShortplayActor = PluginShortplayActor::where(['id' => $actor_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayActor) {
|
||||
$PluginShortplayActor = PluginShortplayActor::where(['id' => $actor_id, 'channels_uid' => $request->channels_uid])->whereNull('uid')->find();
|
||||
}
|
||||
if (!$PluginShortplayActor) {
|
||||
return $this->fail('演员不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
if (!PluginShortplayDramaStoryboardActor::where(['storyboard_id' => $storyboard_id, 'actor_id' => $actor_id])->count()) {
|
||||
$PluginShortplayDramaStoryboardActor = new PluginShortplayDramaStoryboardActor();
|
||||
$PluginShortplayDramaStoryboardActor->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayDramaStoryboardActor->drama_id = $PluginShortplayDramaStoryboard->drama_id;
|
||||
$PluginShortplayDramaStoryboardActor->episode_id = $PluginShortplayDramaStoryboard->episode_id;
|
||||
$PluginShortplayDramaStoryboardActor->storyboard_id = $storyboard_id;
|
||||
$PluginShortplayDramaStoryboardActor->actor_id = $actor_id;
|
||||
$PluginShortplayDramaStoryboardActor->save();
|
||||
}
|
||||
if (!PluginShortplayDramaEpisodeActor::where(['episode_id' => $PluginShortplayDramaStoryboard->episode_id, 'actor_id' => $actor_id])->count()) {
|
||||
$PluginShortplayDramaEpisodeActor = new PluginShortplayDramaEpisodeActor();
|
||||
$PluginShortplayDramaEpisodeActor->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayDramaEpisodeActor->drama_id = $PluginShortplayDramaStoryboard->drama_id;
|
||||
$PluginShortplayDramaEpisodeActor->episode_id = $PluginShortplayDramaStoryboard->episode_id;
|
||||
$PluginShortplayDramaEpisodeActor->actor_id = $actor_id;
|
||||
$PluginShortplayDramaEpisodeActor->save();
|
||||
}
|
||||
if (!PluginShortplayDramaActor::where(['drama_id' => $drama_id, 'actor_id' => $actor_id])->count()) {
|
||||
$PluginShortplayDramaActor = new PluginShortplayDramaActor();
|
||||
$PluginShortplayDramaActor->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayDramaActor->drama_id = $drama_id;
|
||||
$PluginShortplayDramaActor->actor_id = $actor_id;
|
||||
$PluginShortplayDramaActor->save();
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $storyboard_id])->with(['actors', 'sceneFind', 'props', 'dialogues'])->find();
|
||||
return $this->resData($PluginShortplayDramaStoryboard);
|
||||
}
|
||||
public function deleteActor(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$id = $request->post('id');
|
||||
$storyboard_id = $request->post('storyboard_id');
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $storyboard_id, 'drama_id' => $drama_id])->find();
|
||||
if (!$PluginShortplayDramaStoryboard) {
|
||||
return $this->fail('分镜不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
PluginShortplayDramaStoryboardActor::where(['id' => $id, 'storyboard_id' => $PluginShortplayDramaStoryboard->id])->delete();
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $storyboard_id])->with(['actors', 'sceneFind', 'props', 'dialogues'])->find();
|
||||
return $this->resData($PluginShortplayDramaStoryboard);
|
||||
}
|
||||
public function joinProp(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$storyboard_id = $request->post('storyboard_id');
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $storyboard_id, 'drama_id' => $drama_id])->find();
|
||||
if (!$PluginShortplayDramaStoryboard) {
|
||||
return $this->fail('分镜不存在');
|
||||
}
|
||||
$prop_id = $request->post('prop_id');
|
||||
$PluginShortplayProp = PluginShortplayProp::where(['id' => $prop_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayProp) {
|
||||
return $this->fail('物品不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
if (!PluginShortplayDramaStoryboardProp::where(['storyboard_id' => $storyboard_id, 'prop_id' => $PluginShortplayProp->id])->count()) {
|
||||
$PluginShortplayDramaStoryboardProp = new PluginShortplayDramaStoryboardProp();
|
||||
$PluginShortplayDramaStoryboardProp->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayDramaStoryboardProp->storyboard_id = $storyboard_id;
|
||||
$PluginShortplayDramaStoryboardProp->prop_id = $PluginShortplayProp->id;
|
||||
$PluginShortplayDramaStoryboardProp->save();
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $storyboard_id])->with(['actors', 'sceneFind', 'props', 'dialogues'])->find();
|
||||
return $this->resData($PluginShortplayDramaStoryboard);
|
||||
}
|
||||
public function deleteProp(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$id = $request->post('id');
|
||||
$storyboard_id = $request->post('storyboard_id');
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $storyboard_id, 'drama_id' => $drama_id])->find();
|
||||
if (!$PluginShortplayDramaStoryboard) {
|
||||
return $this->fail('分镜不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
PluginShortplayDramaStoryboardProp::where(['id' => $id, 'storyboard_id' => $PluginShortplayDramaStoryboard->id])->delete();
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $storyboard_id])->with(['actors', 'sceneFind', 'props', 'dialogues'])->find();
|
||||
return $this->resData($PluginShortplayDramaStoryboard);
|
||||
}
|
||||
public function ReplaceStoryboard(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$task_id = $request->post('task_id');
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $id])->find();
|
||||
if (!$PluginShortplayDramaStoryboard) {
|
||||
return $this->fail('分镜不存在');
|
||||
}
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $PluginShortplayDramaStoryboard->drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$PluginModelTask = PluginModelTask::where(['id' => $task_id, 'alias_id' => $PluginShortplayDramaStoryboard->id, 'status' => ModelTaskStatus::SUCCESS['value']])->with(['result'])->find();
|
||||
if (!$PluginModelTask) {
|
||||
return $this->fail('任务不存在');
|
||||
}
|
||||
if ($PluginModelTask->scene == ModelScene::STORYBOARD_IMAGE['value']) {
|
||||
$PluginShortplayDramaStoryboard->image = $PluginModelTask->result->image_path;
|
||||
$PluginShortplayDramaStoryboard->use_material_type = 'image';
|
||||
}
|
||||
if ($PluginModelTask->scene == ModelScene::STORYBOARD_VIDEO['value']) {
|
||||
$PluginShortplayDramaStoryboard->video = $PluginModelTask->result->video_path;
|
||||
$PluginShortplayDramaStoryboard->use_material_type = 'video';
|
||||
}
|
||||
$PluginShortplayDramaStoryboard->save();
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $id])->with(['actors', 'sceneFind', 'props', 'dialogues'])->find();
|
||||
return $this->resData($PluginShortplayDramaStoryboard);
|
||||
}
|
||||
public function CharacterLook(Request $request)
|
||||
{
|
||||
$actor_id = $request->post('actor_id');
|
||||
$drama_id = $request->post('drama_id');
|
||||
$episode_id = $request->post('episode_id');
|
||||
$storyboard_id = $request->post('storyboard_id');
|
||||
$character_look_id = $request->post('character_look_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $episode_id, 'drama_id' => $PluginShortplayDrama->id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $storyboard_id, 'drama_id' => $drama_id, 'episode_id' => $episode_id])->find();
|
||||
if (!$PluginShortplayDramaStoryboard) {
|
||||
return $this->fail('分镜不存在');
|
||||
}
|
||||
$PluginShortplayDramaStoryboardActor = PluginShortplayDramaStoryboardActor::where(['storyboard_id' => $PluginShortplayDramaStoryboard->id, 'actor_id' => $actor_id])->find();
|
||||
if (!$PluginShortplayDramaStoryboardActor) {
|
||||
return $this->fail('演员不存在');
|
||||
}
|
||||
$PluginShortplayActorCharacterLook = PluginShortplayActorCharacterLook::where(['id' => $character_look_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayActorCharacterLook) {
|
||||
return $this->fail('演员妆容不存在');
|
||||
}
|
||||
$PluginShortplayDramaStoryboardActor->character_look_id = $PluginShortplayActorCharacterLook->id;
|
||||
$PluginShortplayDramaStoryboardActor->headimg = $PluginShortplayActorCharacterLook->headimg;
|
||||
$PluginShortplayDramaStoryboardActor->three_view_image = $PluginShortplayActorCharacterLook->three_view_image;
|
||||
$PluginShortplayDramaStoryboardActor->save();
|
||||
return $this->success('设置成功');
|
||||
}
|
||||
public function downloadPackage(Request $request)
|
||||
{
|
||||
$drama_id = $request->get('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$episode_id = $request->get('episode_id');
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $episode_id, 'drama_id' => $PluginShortplayDrama->id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
# 初始化打包
|
||||
$uuid = uniqid();
|
||||
$data = [
|
||||
'uuid' => $uuid,
|
||||
'uid' => $PluginShortplayDrama->uid,
|
||||
'channels_uid' => $PluginShortplayDrama->channels_uid,
|
||||
'drama_id' => $PluginShortplayDrama->id,
|
||||
'episode_id' => $PluginShortplayDramaEpisode->id,
|
||||
'url' => $request->header('x-forwarded-proto') . '://' . $request->host() . '/app/shortplay/download/storyboard?uuid=' . $uuid,
|
||||
];
|
||||
Coroutine::create(function () use ($data) {
|
||||
try {
|
||||
sleep(2);
|
||||
$PluginShortplayDramaStoryboards = PluginShortplayDramaStoryboard::where(['drama_id' => $data['drama_id'], 'episode_id' => $data['episode_id']])->with(['dialogues'])->order('sort', 'asc')->select();
|
||||
$storyboardSum = count($PluginShortplayDramaStoryboards);
|
||||
$zip = new \ZipArchive();
|
||||
$filename = $data['drama_id'] . '_' . $data['episode_id'] . '.zip';
|
||||
$filepath = runtime_path('temp/storyboard/');
|
||||
if (!is_dir($filepath)) {
|
||||
mkdir($filepath, 0777, true);
|
||||
}
|
||||
if (!$zip->open($filepath . $filename, \ZipArchive::CREATE | \ZipArchive::OVERWRITE)) {
|
||||
throw new \Exception('打包失败');
|
||||
}
|
||||
$localFiles = [];
|
||||
# 打包图片素材
|
||||
$index = 0;
|
||||
foreach ($PluginShortplayDramaStoryboards as $PluginShortplayDramaStoryboard) {
|
||||
if (!empty($PluginShortplayDramaStoryboard->image)) {
|
||||
$localfile = Uploads::downloadTemp($PluginShortplayDramaStoryboard->image);
|
||||
if (!file_exists($localfile)) {
|
||||
throw new \Exception('图片素材下载失败');
|
||||
}
|
||||
$localFiles[] = $localfile;
|
||||
$ext = pathinfo($localfile, PATHINFO_EXTENSION);
|
||||
$zip->addFile($localfile, $PluginShortplayDramaStoryboard->sort . '/image.' . $ext);
|
||||
$progress = 5 + round(($index / $storyboardSum) * 10);
|
||||
$index++;
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'event' => 'downloadPackage',
|
||||
], ['uuid' => $data['uuid'], 'action' => 'process', 'index' => 1, 'progress' => $progress]);
|
||||
}
|
||||
}
|
||||
# 打包视频素材
|
||||
$index = 0;
|
||||
foreach ($PluginShortplayDramaStoryboards as $PluginShortplayDramaStoryboard) {
|
||||
if (!empty($PluginShortplayDramaStoryboard->video)) {
|
||||
$localfile = Uploads::downloadTemp($PluginShortplayDramaStoryboard->video);
|
||||
if (!file_exists($localfile)) {
|
||||
throw new \Exception('视频素材下载失败');
|
||||
}
|
||||
$ext = pathinfo($localfile, PATHINFO_EXTENSION);
|
||||
$zip->addFile($localfile, $PluginShortplayDramaStoryboard->sort . '/video.' . $ext);
|
||||
$localFiles[] = $localfile;
|
||||
$progress = 15 + round(($index / $storyboardSum) * 40);
|
||||
$index++;
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'event' => 'downloadPackage',
|
||||
], ['uuid' => $data['uuid'], 'action' => 'process', 'index' => 2, 'progress' => $progress]);
|
||||
}
|
||||
}
|
||||
# 打包对话素材
|
||||
$srtContent = [];
|
||||
|
||||
/**
|
||||
* 毫秒 → SRT 时间格式
|
||||
*/
|
||||
function msToSrtTime(int $ms): string
|
||||
{
|
||||
$hours = floor($ms / 3600000);
|
||||
$minutes = floor(($ms % 3600000) / 60000);
|
||||
$seconds = floor(($ms % 60000) / 1000);
|
||||
$milliseconds = $ms % 1000;
|
||||
|
||||
return sprintf(
|
||||
'%02d:%02d:%02d,%03d',
|
||||
$hours,
|
||||
$minutes,
|
||||
$seconds,
|
||||
$milliseconds
|
||||
);
|
||||
}
|
||||
|
||||
$index = 1; // SRT 序号必须从 1 开始
|
||||
$currentTimeline = 0; // 全局时间轴(毫秒)
|
||||
|
||||
foreach ($PluginShortplayDramaStoryboards as $storyboard) {
|
||||
if (empty($storyboard->dialogues)) {
|
||||
continue;
|
||||
}
|
||||
$dialogueText = '';
|
||||
$maxEnd = 0;
|
||||
foreach ($storyboard->dialogues as $dialogue) {
|
||||
|
||||
// 当前字幕在全局时间轴中的开始 / 结束时间
|
||||
$startMs = $currentTimeline + $dialogue->start_time;
|
||||
$endMs = $currentTimeline + $dialogue->end_time;
|
||||
|
||||
$temp =
|
||||
$index . "\n" .
|
||||
msToSrtTime($startMs) . " --> " . msToSrtTime($endMs) . "\n" .
|
||||
trim($dialogue->content) . "\n";
|
||||
$dialogueText .= $temp . "\n";
|
||||
$srtContent[] = $temp;
|
||||
$index++;
|
||||
$maxEnd = max($maxEnd, $endMs);
|
||||
}
|
||||
|
||||
$currentTimeline += $maxEnd;
|
||||
if (!empty($dialogueText)) {
|
||||
$zip->addFromString($storyboard->sort . '/对话.txt', $dialogueText);
|
||||
}
|
||||
}
|
||||
|
||||
// 最终 SRT 文本
|
||||
$srtText = implode("\n", $srtContent);
|
||||
$zip->addFromString('字幕.srt', $srtText);
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'event' => 'downloadPackage',
|
||||
], ['uuid' => $data['uuid'], 'action' => 'process', 'index' => 3, 'progress' => 55]);
|
||||
# 打包音频素材
|
||||
$index = 0;
|
||||
foreach ($PluginShortplayDramaStoryboards as $PluginShortplayDramaStoryboard) {
|
||||
if (empty($PluginShortplayDramaStoryboard->dialogues)) {
|
||||
continue;
|
||||
}
|
||||
$n = 0;
|
||||
foreach ($PluginShortplayDramaStoryboard->dialogues as $PluginShortplayDramaStoryboardDialogue) {
|
||||
if (!empty($PluginShortplayDramaStoryboardDialogue->audio)) {
|
||||
$localfile = Uploads::downloadTemp($PluginShortplayDramaStoryboardDialogue->audio);
|
||||
if (!file_exists($localfile)) {
|
||||
throw new \Exception('音频素材下载失败');
|
||||
}
|
||||
$ext = pathinfo($localfile, PATHINFO_EXTENSION);
|
||||
$zip->addFile($localfile, $PluginShortplayDramaStoryboard->sort . "/{$n}-{$PluginShortplayDramaStoryboardDialogue->actor->name}." . $ext);
|
||||
$localFiles[] = $localfile;
|
||||
}
|
||||
$n++;
|
||||
}
|
||||
$progress = 55 + round(($index / $storyboardSum) * 10);
|
||||
$index++;
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'event' => 'downloadPackage',
|
||||
], ['uuid' => $data['uuid'], 'action' => 'process', 'index' => 4, 'progress' => $progress]);
|
||||
}
|
||||
# 打包旁白素材
|
||||
foreach ($PluginShortplayDramaStoryboards as $PluginShortplayDramaStoryboard) {
|
||||
if (!empty($PluginShortplayDramaStoryboard->narration)) {
|
||||
$zip->addFromString($PluginShortplayDramaStoryboard->sort . '/旁白.txt', $PluginShortplayDramaStoryboard->narration);
|
||||
}
|
||||
}
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'event' => 'downloadPackage',
|
||||
], ['uuid' => $data['uuid'], 'action' => 'process', 'index' => 5, 'progress' => 75]);
|
||||
# 打包旁白音频素材
|
||||
$index = 0;
|
||||
foreach ($PluginShortplayDramaStoryboards as $PluginShortplayDramaStoryboard) {
|
||||
if (!empty($PluginShortplayDramaStoryboard->narration_audio)) {
|
||||
$localfile = Uploads::downloadTemp($PluginShortplayDramaStoryboard->narration_audio);
|
||||
if (!file_exists($localfile)) {
|
||||
throw new \Exception('旁白音频素材下载失败');
|
||||
}
|
||||
$ext = pathinfo($localfile, PATHINFO_EXTENSION);
|
||||
$zip->addFile($localfile, $PluginShortplayDramaStoryboard->sort . '/旁白.' . $ext);
|
||||
$localFiles[] = $localfile;
|
||||
}
|
||||
$progress = 75 + round(($index / $storyboardSum) * 10);
|
||||
$index++;
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'event' => 'downloadPackage',
|
||||
], ['uuid' => $data['uuid'], 'action' => 'process', 'index' => 6, 'progress' => $progress]);
|
||||
}
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'event' => 'downloadPackage',
|
||||
], ['uuid' => $data['uuid'], 'action' => 'process', 'index' => 7, 'progress' => 95]);
|
||||
$zip->close();
|
||||
$cacheData = [
|
||||
'uuid' => $data['uuid'],
|
||||
'filename' => $filename,
|
||||
'filepath' => $filepath,
|
||||
];
|
||||
Cache::set('downloadPackage_' . $data['uuid'], $cacheData, 60 * 60 * 24);
|
||||
foreach ($localFiles as $localFile) {
|
||||
if (file_exists($localFile)) {
|
||||
unlink($localFile);
|
||||
}
|
||||
}
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'event' => 'downloadPackage',
|
||||
], ['uuid' => $data['uuid'], 'action' => 'process', 'index' => 7, 'progress' => 100, 'url' => $data['url'], 'filename' => $filename]);
|
||||
} catch (\Throwable | ClientException | RequestException $th) {
|
||||
Log::error("下载打包异常:" . $th->getMessage(), $th->getTrace());
|
||||
Push::send([
|
||||
'uid' => $data['uid'],
|
||||
'channels_uid' => $data['channels_uid'],
|
||||
'event' => 'downloadPackage',
|
||||
], ['uuid' => $data['uuid'], 'msg' => $th->getMessage()]);
|
||||
}
|
||||
});
|
||||
return $this->resData(['uuid' => $uuid]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\shortplay\app\model\PluginShortplayActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDrama;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisode;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisodeActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboard;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardActor;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaStoryboardDialogue;
|
||||
use support\Request;
|
||||
use support\think\Db;
|
||||
|
||||
class StoryboardDialogueController extends Basic
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$drama_id = $request->get('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$episode_id = $request->get('episode_id');
|
||||
if ($episode_id) {
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['id' => $episode_id, 'drama_id' => $PluginShortplayDrama->id])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
}
|
||||
$where = [];
|
||||
$storyboard_id = $request->get('storyboard_id');
|
||||
if ($storyboard_id) {
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $storyboard_id, 'drama_id' => $drama_id])->find();
|
||||
if (!$PluginShortplayDramaStoryboard) {
|
||||
return $this->fail('分镜不存在');
|
||||
}
|
||||
$where[] = ['storyboard_id', '=', $PluginShortplayDramaStoryboard->id];
|
||||
} else {
|
||||
$ids = PluginShortplayDramaStoryboard::where(['episode_id' => $PluginShortplayDramaEpisode->id, 'drama_id' => $drama_id])->column('id');
|
||||
if (empty($ids)) {
|
||||
return $this->resData([]);
|
||||
}
|
||||
$where[] = ['storyboard_id', 'in', $ids];
|
||||
}
|
||||
$PluginShortplayDramaStoryboardDialogue = PluginShortplayDramaStoryboardDialogue::where($where)->with(['actor', 'storyboard'])->order('start_time asc,id asc')->select()->each(function ($item) {
|
||||
$item->voice_level = 'dialogue';
|
||||
if (!$item->voice) {
|
||||
$ActorVoiceLevel = [
|
||||
[
|
||||
'level' => 'storyboard',
|
||||
'model' => PluginShortplayDramaStoryboardActor::class,
|
||||
'where' => [
|
||||
'storyboard_id' => $item->storyboard_id,
|
||||
'actor_id' => $item->actor_id
|
||||
]
|
||||
],
|
||||
[
|
||||
'level' => 'episode',
|
||||
'model' => PluginShortplayDramaEpisodeActor::class,
|
||||
'where' => [
|
||||
'episode_id' => $item->storyboard->episode_id,
|
||||
'actor_id' => $item->actor_id
|
||||
]
|
||||
],
|
||||
[
|
||||
'level' => 'drama',
|
||||
'model' => PluginShortplayDramaActor::class,
|
||||
'where' => [
|
||||
'drama_id' => $item->storyboard->drama_id,
|
||||
'actor_id' => $item->actor_id
|
||||
]
|
||||
],
|
||||
[
|
||||
'level' => 'actor',
|
||||
'model' => PluginShortplayActor::class,
|
||||
'where' => [
|
||||
'actor_id' => $item->actor_id
|
||||
]
|
||||
]
|
||||
];
|
||||
foreach ($ActorVoiceLevel as $ActorVoiceLevelItem) {
|
||||
$PluginActorVoice = $ActorVoiceLevelItem['model']::where($ActorVoiceLevelItem['where'])->find();
|
||||
if ($PluginActorVoice && $PluginActorVoice->voice) {
|
||||
$item->voice = $PluginActorVoice->voice;
|
||||
$item->voice_level = $ActorVoiceLevelItem['level'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return $this->resData($PluginShortplayDramaStoryboardDialogue);
|
||||
}
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$storyboard_id = $request->post('storyboard_id');
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $storyboard_id, 'drama_id' => $drama_id])->find();
|
||||
if (!$PluginShortplayDramaStoryboard) {
|
||||
return $this->fail('分镜不存在');
|
||||
}
|
||||
$dialogue_id = $request->post('dialogue_id');
|
||||
$PluginShortplayDramaStoryboardDialogue = PluginShortplayDramaStoryboardDialogue::where(['id' => $dialogue_id, 'storyboard_id' => $PluginShortplayDramaStoryboard->id])->find();
|
||||
if (!$PluginShortplayDramaStoryboardDialogue) {
|
||||
return $this->success('已删除');
|
||||
}
|
||||
if ($PluginShortplayDramaStoryboardDialogue->delete()) {
|
||||
return $this->success('删除成功');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
}
|
||||
}
|
||||
public function save(Request $request)
|
||||
{
|
||||
$drama_id = $request->post('drama_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$storyboard_id = $request->post('storyboard_id');
|
||||
$PluginShortplayDramaStoryboard = PluginShortplayDramaStoryboard::where(['id' => $storyboard_id, 'drama_id' => $drama_id])->find();
|
||||
if (!$PluginShortplayDramaStoryboard) {
|
||||
return $this->fail('分镜不存在');
|
||||
}
|
||||
$actor_id = $request->post('actor_id');
|
||||
$PluginShortplayActor = PluginShortplayActor::where(['id' => $actor_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayActor) {
|
||||
$PluginShortplayActor = PluginShortplayActor::where(['id' => $actor_id, 'channels_uid' => $request->channels_uid])->whereNull('uid')->find();
|
||||
}
|
||||
if (!$PluginShortplayActor) {
|
||||
return $this->fail('演员不存在');
|
||||
}
|
||||
$id = $request->post('id');
|
||||
if ($id) {
|
||||
$PluginShortplayDramaStoryboardDialogue = PluginShortplayDramaStoryboardDialogue::where(['id' => $id, 'storyboard_id' => $PluginShortplayDramaStoryboard->id])->find();
|
||||
if (!$PluginShortplayDramaStoryboardDialogue) {
|
||||
return $this->fail('对话不存在');
|
||||
}
|
||||
} else {
|
||||
$PluginShortplayDramaStoryboardDialogue = new PluginShortplayDramaStoryboardDialogue();
|
||||
$PluginShortplayDramaStoryboardDialogue->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayDramaStoryboardDialogue->storyboard_id = $PluginShortplayDramaStoryboard->id;
|
||||
$PluginShortplayDramaStoryboardDialogue->actor_id = $PluginShortplayActor->id;
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$D = $request->post();
|
||||
$PluginShortplayDramaStoryboardDialogue->prosody_speed = $D['prosody_speed'];
|
||||
$PluginShortplayDramaStoryboardDialogue->prosody_volume = $D['prosody_volume'];
|
||||
$PluginShortplayDramaStoryboardDialogue->emotion = $D['emotion'];
|
||||
$PluginShortplayDramaStoryboardDialogue->start_time = $D['start_time'];
|
||||
$PluginShortplayDramaStoryboardDialogue->end_time = $D['end_time'];
|
||||
$PluginShortplayDramaStoryboardDialogue->content = $D['content'];
|
||||
$PluginShortplayDramaStoryboardDialogue->save();
|
||||
if (!PluginShortplayDramaEpisodeActor::where(['episode_id' => $PluginShortplayDramaStoryboard->episode_id, 'actor_id' => $actor_id])->count()) {
|
||||
$PluginShortplayDramaEpisodeActor = new PluginShortplayDramaEpisodeActor();
|
||||
$PluginShortplayDramaEpisodeActor->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayDramaEpisodeActor->drama_id = $PluginShortplayDramaStoryboard->drama_id;
|
||||
$PluginShortplayDramaEpisodeActor->episode_id = $PluginShortplayDramaStoryboard->episode_id;
|
||||
$PluginShortplayDramaEpisodeActor->actor_id = $actor_id;
|
||||
$PluginShortplayDramaEpisodeActor->save();
|
||||
}
|
||||
if (!PluginShortplayDramaActor::where(['drama_id' => $PluginShortplayDrama->id, 'actor_id' => $actor_id])->count()) {
|
||||
$PluginShortplayDramaActor = new PluginShortplayDramaActor();
|
||||
$PluginShortplayDramaActor->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayDramaActor->drama_id = $drama_id;
|
||||
$PluginShortplayDramaActor->actor_id = $actor_id;
|
||||
$PluginShortplayDramaActor->save();
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
$PluginShortplayDramaStoryboardDialogue = PluginShortplayDramaStoryboardDialogue::where(['id' => $PluginShortplayDramaStoryboardDialogue->id])->with(['actor'])->find();
|
||||
return $this->resData($PluginShortplayDramaStoryboardDialogue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\enum\State;
|
||||
use plugin\shortplay\app\model\PluginShortplayStyle;
|
||||
use support\Request;
|
||||
|
||||
class StyleController extends Basic
|
||||
{
|
||||
protected $notNeedLogin = ['index'];
|
||||
public function index(Request $request)
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['state', '=', State::YES['value']];
|
||||
$name = $request->get('name');
|
||||
if ($name) {
|
||||
$where[] = ['name', 'like', '%' . $name . '%'];
|
||||
}
|
||||
$classify = $request->get('classify','all');
|
||||
if ($classify != 'all') {
|
||||
$where[] = ['classify', '=', $classify];
|
||||
}
|
||||
$PluginShortplayStyle = PluginShortplayStyle::where($where)->order('id', 'desc')->select();
|
||||
return $this->resData($PluginShortplayStyle);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use plugin\control\expose\trait\Uploads;
|
||||
|
||||
class UploadsController extends Basic
|
||||
{
|
||||
use Uploads;
|
||||
public function __construct()
|
||||
{
|
||||
$request = request();
|
||||
$this->uid = $request->uid;
|
||||
$this->channels_uid = $request->channels_uid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\enum\State;
|
||||
use plugin\control\utils\yidevs\Yidevs;
|
||||
use plugin\model\app\model\PluginModel;
|
||||
use plugin\model\app\model\PluginModelVoice;
|
||||
use plugin\model\utils\enum\ModelVoiceStatus;
|
||||
use plugin\shortplay\utils\enum\ActorAge;
|
||||
use plugin\shortplay\utils\enum\ActorGender;
|
||||
use support\Request;
|
||||
|
||||
class VoiceController extends Basic
|
||||
{
|
||||
public function list(Request $request)
|
||||
{
|
||||
$model_id = $request->get('model_id');
|
||||
$scene = $request->get('scene');
|
||||
$action = $request->get('action', 'yidevs');
|
||||
if ($action == 'yidevs') {
|
||||
$PluginModel = PluginModel::where(['id' => $model_id, 'scene' => $scene, 'state' => State::YES['value']])->find();
|
||||
if (!$PluginModel) {
|
||||
return $this->fail('模型不存在');
|
||||
}
|
||||
try {
|
||||
$result = Yidevs::AudioVoiceList($PluginModel->channels_uid, ['model' => $PluginModel->model_id]);
|
||||
return $this->resData($result);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->exception($th);
|
||||
}
|
||||
} else {
|
||||
$model_id = $request->get('model_id');
|
||||
$where = [];
|
||||
$where[] = ['channels_uid', '=', $request->channels_uid];
|
||||
$where[] = ['uid', '=', $request->uid];
|
||||
if ($model_id) {
|
||||
$where[] = ['model_id', '=', $model_id];
|
||||
}
|
||||
$where[] = ['status', '=', ModelVoiceStatus::SUCCESS['value']];
|
||||
$voice = PluginModelVoice::where($where)->order('id desc')->select()->each(function ($item) {
|
||||
$item->gender_enum = ActorGender::get($item->gender);
|
||||
$item->age_enum = ActorAge::get($item->age);
|
||||
});
|
||||
return $this->resData($voice);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\api\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\enum\State;
|
||||
use plugin\shortplay\app\model\PluginShortplayDrama;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisode;
|
||||
use plugin\shortplay\app\model\PluginShortplayShare;
|
||||
use plugin\shortplay\app\model\PluginShortplayShareEpisode;
|
||||
use plugin\shortplay\app\model\PluginShortplayShareLikes;
|
||||
use support\Request;
|
||||
use think\facade\Db;
|
||||
|
||||
class WorksController extends Basic
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$where[] = ['uid', '=', $request->uid];
|
||||
$name = $request->get('name');
|
||||
if ($name) {
|
||||
$where[] = ['name', 'like', '%' . $name . '%'];
|
||||
}
|
||||
$script = $request->get('script', 'all');
|
||||
if ($script != 'all') {
|
||||
$where[] = ['script', '=', $script];
|
||||
}
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where($where)->order('state asc ,id desc')->paginate($limit)->each(function ($item) {});
|
||||
return $this->resData($PluginShortplayDrama);
|
||||
}
|
||||
public function updateCover(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$cover = $request->post('cover');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$PluginShortplayDrama->cover = $cover;
|
||||
$PluginShortplayDrama->save();
|
||||
return $this->success('更新成功');
|
||||
}
|
||||
public function details(Request $request)
|
||||
{
|
||||
$id = $request->get('id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $id, 'uid' => $request->uid])->with(['episodes', 'style'])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
if ($PluginShortplayDrama->cover_state > 0) {
|
||||
$PluginShortplayDrama->cover = null;
|
||||
}
|
||||
return $this->resData($PluginShortplayDrama);
|
||||
}
|
||||
public function episode(Request $request)
|
||||
{
|
||||
$drama_id = $request->get('drama_id');
|
||||
$episode_id = $request->get('episode_id');
|
||||
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $drama_id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayDrama) {
|
||||
return $this->fail('短剧不存在');
|
||||
}
|
||||
$PluginShortplayDramaEpisode = PluginShortplayDramaEpisode::where(['drama_id' => $PluginShortplayDrama->id, 'id' => $episode_id])->with(['scenes' => function ($query) {
|
||||
$query->order('sort', 'asc');
|
||||
}, 'storyboards' => function ($query) {
|
||||
$query->order('sort', 'asc');
|
||||
}])->find();
|
||||
if (!$PluginShortplayDramaEpisode) {
|
||||
return $this->fail('分集不存在');
|
||||
}
|
||||
return $this->resData($PluginShortplayDramaEpisode);
|
||||
}
|
||||
|
||||
public function share(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$where[] = ['psd.uid', '=', $request->uid];
|
||||
$name = $request->get('name');
|
||||
if ($name) {
|
||||
$where[] = ['psd.name', 'like', '%' . $name . '%'];
|
||||
}
|
||||
$script = $request->get('script', 'all');
|
||||
if ($script != 'all') {
|
||||
$where[] = ['psd.script', '=', $script];
|
||||
}
|
||||
$PluginShortplayDrama = PluginShortplayDrama::alias('psd')
|
||||
->join('plugin_shortplay_share pss', 'psd.id = pss.drama_id')
|
||||
->where($where)
|
||||
->order('pss.update_time desc,pss.id desc')
|
||||
->field('psd.*,pss.likes,pss.id as share_id')
|
||||
->paginate($limit)
|
||||
->each(function ($item) {});
|
||||
return $this->resData($PluginShortplayDrama);
|
||||
}
|
||||
|
||||
public function deleteShare(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$PluginShortplayShare = PluginShortplayShare::where(['id' => $id, 'uid' => $request->uid])->find();
|
||||
if (!$PluginShortplayShare) {
|
||||
return $this->fail('分享不存在');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
PluginShortplayShareEpisode::where(['share_id' => $PluginShortplayShare->id])->delete();
|
||||
PluginShortplayShareLikes::where(['share_id' => $PluginShortplayShare->id])->delete();
|
||||
$PluginShortplayShare->delete();
|
||||
Db::commit();
|
||||
} catch (\Throwable $th) {
|
||||
Db::rollback();
|
||||
return $this->fail($th->getMessage());
|
||||
}
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,441 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\control\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\ActionBuilder;
|
||||
use app\expose\build\builder\ComponentBuilder;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use app\expose\enum\Action;
|
||||
use plugin\shortplay\app\model\PluginShortplayActor;
|
||||
use plugin\shortplay\utils\enum\ActorAge;
|
||||
use plugin\shortplay\utils\enum\ActorGender;
|
||||
use plugin\shortplay\utils\enum\ActorSpeciesType;
|
||||
use plugin\shortplay\utils\enum\ActorStatus;
|
||||
use support\Request;
|
||||
|
||||
class ActorController extends Basic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new PluginShortplayActor;
|
||||
}
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder;
|
||||
$builder->addAction('操作', [
|
||||
'width' => '180px',
|
||||
'fixed' => 'right'
|
||||
]);
|
||||
$builder->addTableAction('编辑', [
|
||||
'model' => Action::DIALOG['value'],
|
||||
'path' => '/app/shortplay/control/Actor/update',
|
||||
'props' => [
|
||||
'title' => '编辑《ID:{id}》演员'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'primary',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->addTableAction('初始化', [
|
||||
'model' => Action::COMFIRM['value'],
|
||||
'path' => '/app/shortplay/control/Actor/submitInit',
|
||||
'props' => [
|
||||
'title' => '确定要初始化《{name}》演员吗?'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'warning',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->addHeader();
|
||||
$builder->addHeaderAction('创建演员', [
|
||||
'model' => Action::DIALOG['value'],
|
||||
'path' => '/app/shortplay/control/Actor/create',
|
||||
'props' => [
|
||||
'title' => '创建演员'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'success'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
$formBuilder->add('name', '名称', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '名称搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('actor_id', '演员ID', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '演员ID搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('drama_id','公共演员','select','',[
|
||||
'options' => [
|
||||
['label' => '是', 'value' => 1],
|
||||
['label' => '否', 'value' => 0]
|
||||
],
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('user', '用户', [
|
||||
'where' => [
|
||||
['uid', '!=', null]
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'user.nickname',
|
||||
'avatar' => 'user.headimg',
|
||||
'info' => 'user.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('actorinfo', '演员', [
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'name',
|
||||
'avatar' => 'headimg',
|
||||
'info' => 'actor_id',
|
||||
'preview' => true
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('three_view_image', '三视图', [
|
||||
'component' => [
|
||||
'name' => 'image',
|
||||
'props' => [
|
||||
'style' => 'width: 100px; height: 100px;',
|
||||
'fit' => 'cover'
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '133px'
|
||||
]
|
||||
]);
|
||||
$builder->add('species_type', '物种', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ActorSpeciesType::getOptions(),
|
||||
],
|
||||
'props' => [
|
||||
'width' => '180px'
|
||||
]
|
||||
]);
|
||||
$builder->add('gender', '性别', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ActorGender::getOptions(),
|
||||
],
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('age', '年龄', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ActorAge::getOptions(),
|
||||
],
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('status', '状态', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => ActorStatus::getOptions(),
|
||||
],
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('remarks', '人物描述', [
|
||||
'props' => [
|
||||
'minWidth' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function query(Request $request)
|
||||
{
|
||||
$query = $request->post('query');
|
||||
if (empty($query)) {
|
||||
return $this->resData([]);
|
||||
}
|
||||
$where = [];
|
||||
$where[] = ['name|actor_id|remarks', 'like', "%{$query}%"];
|
||||
return $this->resData(PluginShortplayActor::options($where));
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$where[] = ['channels_uid', '=', $request->channels_uid];
|
||||
$name = $request->get('name');
|
||||
if ($name) {
|
||||
$where[] = ['name', 'like', "%{$name}%"];
|
||||
}
|
||||
$actor_id = $request->get('actor_id');
|
||||
if ($actor_id) {
|
||||
$where[] = ['actor_id', 'like', "%{$actor_id}%"];
|
||||
}
|
||||
$drama_id = $request->get('drama_id');
|
||||
if ($drama_id==1) {
|
||||
$where[] = ['uid', '=', null];
|
||||
} else {
|
||||
$where[] = ['uid', '>', 0];
|
||||
}
|
||||
$list = PluginShortplayActor::where($where)->with(['user' => function ($query) {
|
||||
$query->field('id,nickname,headimg,mobile,channels_uid');
|
||||
}])
|
||||
->order('id desc')->paginate($limit)->each(function ($item) {});
|
||||
return $this->resData($list);
|
||||
}
|
||||
public function create(Request $request)
|
||||
{
|
||||
if ($request->method() === 'POST') {
|
||||
$D = $request->post();
|
||||
try {
|
||||
$PluginShortplayActor = new PluginShortplayActor;
|
||||
$PluginShortplayActor->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayActor->name = $D['name'];
|
||||
$PluginShortplayActor->headimg = $D['headimg'];
|
||||
$PluginShortplayActor->species_type = $D['species_type'];
|
||||
$PluginShortplayActor->gender = $D['gender'];
|
||||
$PluginShortplayActor->age = $D['age'];
|
||||
$PluginShortplayActor->status = $D['status'];
|
||||
$PluginShortplayActor->three_view_image = $D['three_view_image'];
|
||||
$PluginShortplayActor->remarks = $D['remarks'];
|
||||
$PluginShortplayActor->save();
|
||||
} catch (\Throwable $th) {
|
||||
return $this->exception($th);
|
||||
}
|
||||
return $this->success('创建成功');
|
||||
}
|
||||
$builder = $this->getFormBuilder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function update(Request $request)
|
||||
{
|
||||
if ($request->method() === 'POST') {
|
||||
$D = $request->post();
|
||||
try {
|
||||
$PluginShortplayActor = PluginShortplayActor::where(['id' => $D['id'], 'channels_uid' => $request->channels_uid])->find();
|
||||
$PluginShortplayActor->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayActor->name = $D['name'];
|
||||
$PluginShortplayActor->headimg = $D['headimg'];
|
||||
$PluginShortplayActor->species_type = $D['species_type'];
|
||||
$PluginShortplayActor->gender = $D['gender'];
|
||||
$PluginShortplayActor->age = $D['age'];
|
||||
$PluginShortplayActor->status = $D['status'];
|
||||
$PluginShortplayActor->three_view_image = $D['three_view_image'];
|
||||
$PluginShortplayActor->remarks = $D['remarks'];
|
||||
$PluginShortplayActor->save();
|
||||
} catch (\Throwable $th) {
|
||||
return $this->exception($th);
|
||||
}
|
||||
return $this->success('更新成功');
|
||||
}
|
||||
$id = $request->get('id');
|
||||
$Actor = PluginShortplayActor::where(['id' => $id, 'channels_uid' => $request->channels_uid])->find();
|
||||
$builder = $this->getFormBuilder();
|
||||
$builder->setData($Actor->toArray());
|
||||
return $this->resData($builder);
|
||||
}
|
||||
private function getFormBuilder()
|
||||
{
|
||||
$builder = new FormBuilder(null, null, [
|
||||
'translations' => true,
|
||||
'size' => 'large',
|
||||
]);
|
||||
$Component = new ComponentBuilder;
|
||||
$builder->add('headimg', '形象', 'bundle', '', [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 8
|
||||
],
|
||||
'prompt' => [
|
||||
$Component->add('text', ['default' => '支持jpg、png、jpeg格式,大小不超过3M'], ['type' => 'info', 'size' => 'small'])->builder()
|
||||
],
|
||||
'props' => [
|
||||
'accept' => 'image/jpeg,image/png,image/jpg',
|
||||
'multiple' => 1,
|
||||
'size' => 3,
|
||||
'customStyle' => '--el-upload-list-picture-card-height:200px;--el-upload-list-picture-card-width:160px;'
|
||||
]
|
||||
]);
|
||||
$builder->add('three_view_image', '三视图', 'bundle', '', [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 8
|
||||
],
|
||||
'prompt' => [
|
||||
$Component->add('text', ['default' => '支持jpg、png、jpeg格式,大小不超过3M,推荐1:1比例'], ['type' => 'info', 'size' => 'small'])->builder()
|
||||
],
|
||||
'props' => [
|
||||
'accept' => 'image/jpeg,image/png,image/jpg',
|
||||
'multiple' => 1,
|
||||
'size' => 3,
|
||||
'customStyle' => '--el-upload-list-picture-card-height:200px;--el-upload-list-picture-card-width:200px;'
|
||||
]
|
||||
]);
|
||||
$builder->add('name', '名称', 'input', '', [
|
||||
'required' => true,
|
||||
'maxlength' => 30,
|
||||
'show-word-limit' => true,
|
||||
]);
|
||||
$builder->add('species_type', '物种', 'select', '', [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 8
|
||||
],
|
||||
'options' => ActorSpeciesType::getOptions(),
|
||||
'required' => true,
|
||||
]);
|
||||
$builder->add('gender', '性别', 'select', '', [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 8
|
||||
],
|
||||
'options' => ActorGender::getOptions(),
|
||||
'required' => true,
|
||||
]);
|
||||
$builder->add('age', '年龄', 'select', '', [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 8
|
||||
],
|
||||
'options' => ActorAge::getOptions(),
|
||||
'required' => true,
|
||||
]);
|
||||
$builder->add('status', '状态', 'radio', ActorStatus::INITIALIZING['value'], [
|
||||
'options' => ActorStatus::getOptions(),
|
||||
'subProps' => [
|
||||
'border' => true
|
||||
],
|
||||
'required' => true,
|
||||
]);
|
||||
$builder->add('remarks', '人物描述', 'input', '', [
|
||||
'props' => [
|
||||
'type' => 'textarea',
|
||||
'autosize' => [
|
||||
'minRows' => 4,
|
||||
'maxRows' => 20
|
||||
]
|
||||
]
|
||||
]);
|
||||
return $builder;
|
||||
}
|
||||
public function generateHeadimg(Request $request)
|
||||
{
|
||||
$prompt = $request->post('prompt');
|
||||
if (empty($prompt)) {
|
||||
return $this->fail('AI提示词不能为空');
|
||||
}
|
||||
$actionBuilder = new ActionBuilder();
|
||||
$headimg = 'https://' . $request->host() . '/uploads/default/20251122/5b8dcf4cbec3ba58057884929194349c_69217f42205c5.jfif';
|
||||
$actionBuilder->setData([
|
||||
'headimg' => $headimg
|
||||
]);
|
||||
$actionBuilder->setDataAction('append');
|
||||
return $this->success('生成成功', $actionBuilder);
|
||||
}
|
||||
public function generateThreeViewImage(Request $request)
|
||||
{
|
||||
$prompt = $request->post('prompt');
|
||||
if (empty($prompt)) {
|
||||
return $this->fail('AI提示词不能为空');
|
||||
}
|
||||
$actionBuilder = new ActionBuilder();
|
||||
$headimg = 'https://' . $request->host() . '/uploads/default/20251122/5b8dcf4cbec3ba58057884929194349c_69217f42205c5.jfif';
|
||||
$actionBuilder->setData([
|
||||
'three_view_image' => $headimg
|
||||
]);
|
||||
$actionBuilder->setDataAction('append');
|
||||
return $this->success('生成成功', $actionBuilder);
|
||||
}
|
||||
public function submitInit(Request $request)
|
||||
{
|
||||
$id = $request->post('id');
|
||||
$Actor = PluginShortplayActor::where(['id' => $id, 'channels_uid' => $request->channels_uid])->find();
|
||||
if (!$Actor) {
|
||||
return $this->fail('演员不存在');
|
||||
}
|
||||
$Actor->status = ActorStatus::PENDING['value'];
|
||||
$Actor->actor_id = uniqid();
|
||||
$Actor->three_view_image = $Actor->headimg;
|
||||
$Actor->save();
|
||||
return $this->success('初始化成功');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\control\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\ActionBuilder;
|
||||
use app\expose\build\builder\ComponentBuilder;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use app\expose\enum\Action;
|
||||
use app\expose\enum\State;
|
||||
use plugin\shortplay\app\model\PluginShortplayDrama;
|
||||
use plugin\shortplay\app\model\PluginShortplayStyle;
|
||||
use plugin\shortplay\utils\enum\StyleClassify;
|
||||
use support\Request;
|
||||
|
||||
class DramaController extends Basic
|
||||
{
|
||||
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder([
|
||||
]);
|
||||
// $builder->addAction('操作', [
|
||||
// 'width' => '180px',
|
||||
// 'fixed' => 'right'
|
||||
// ]);
|
||||
// $builder->addTableAction('编辑', [
|
||||
// 'model' => Action::DIALOG['value'],
|
||||
// 'path' => '/app/shortplay/control/Actor/update',
|
||||
// 'props' => [
|
||||
// 'title' => '编辑《ID:{id}》演员'
|
||||
// ],
|
||||
// 'component' => [
|
||||
// 'name' => 'button',
|
||||
// 'props' => [
|
||||
// 'type' => 'primary',
|
||||
// 'size' => 'small'
|
||||
// ]
|
||||
// ]
|
||||
// ]);
|
||||
$builder->addHeader();
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
$formBuilder->add('title', '名称', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '名称搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('uid', '用户ID', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '用户ID搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('user', '用户', [
|
||||
'where' => [
|
||||
['uid', '!=', null]
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'user.nickname',
|
||||
'avatar' => 'user.headimg',
|
||||
'info' => 'user.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('title', '剧本名称', [
|
||||
'props' => [
|
||||
'minWidth' => '200px'
|
||||
]
|
||||
]);
|
||||
$builder->add('description', '剧本简介', [
|
||||
'props' => [
|
||||
'minWidth' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('cover', '封面', [
|
||||
'component' => [
|
||||
'name' => 'image',
|
||||
'props' => [
|
||||
'style' => 'width: 100px; height: 100px;',
|
||||
'fit' => 'cover'
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '133px'
|
||||
]
|
||||
]);
|
||||
$builder->add('state', '状态', [
|
||||
'component' => [
|
||||
'name' => 'switch',
|
||||
'api' => '/app/shortplay/control/Drama/indexUpdateState',
|
||||
'props' => [
|
||||
'active-value' => State::YES['value'],
|
||||
'inactive-value' => State::NO['value']
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$where[] = ['channels_uid', '=', $request->channels_uid];
|
||||
$title = $request->get('title');
|
||||
if ($title) {
|
||||
$where[] = ['title', 'like', "%{$title}%"];
|
||||
}
|
||||
$uid = $request->get('uid');
|
||||
if ($uid) {
|
||||
$where[] = ['uid', '=', $uid];
|
||||
}
|
||||
$list = PluginShortplayDrama::where($where)
|
||||
->order('id desc')->paginate($limit);
|
||||
return $this->resData($list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\control\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\ActionBuilder;
|
||||
use app\expose\build\builder\ComponentBuilder;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use app\expose\enum\Action;
|
||||
use app\expose\enum\State;
|
||||
use plugin\shortplay\app\model\PluginShortplayDrama;
|
||||
use plugin\shortplay\app\model\PluginShortplayDramaEpisode;
|
||||
use plugin\shortplay\utils\enum\StyleClassify;
|
||||
use support\Request;
|
||||
|
||||
class DramaEpisodeController extends Basic
|
||||
{
|
||||
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$list=PluginShortplayDrama::field('id as value,title as label')->select();
|
||||
$builder = new TableBuilder( );
|
||||
$builder->addHeader();
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
$formBuilder->add('drama_id', '剧本', 'select', '', [
|
||||
'options' => $list,
|
||||
'props' => [
|
||||
'placeholder' => '剧本搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('title', '分集名称', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '分集名称搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
|
||||
$formBuilder->add('uid', '用户ID', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '用户ID搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('user', '用户', [
|
||||
'where' => [
|
||||
['uid', '!=', null]
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'user.nickname',
|
||||
'avatar' => 'user.headimg',
|
||||
'info' => 'user.mobile',
|
||||
'tags' => [
|
||||
[
|
||||
'field' => 'uid',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('drama.title', '剧本名称', [
|
||||
'props' => [
|
||||
'minWidth' => '200px',
|
||||
]
|
||||
]);
|
||||
$builder->add('title', '分集名称', [
|
||||
'props' => [
|
||||
'minWidth' => '200px',
|
||||
]
|
||||
]);
|
||||
$builder->add('content', '分集内容', [
|
||||
'props' => [
|
||||
'minWidth' => '300px',
|
||||
'show-overflow-tooltip'=>true
|
||||
]
|
||||
]);
|
||||
$builder->add('cover', '封面', [
|
||||
'component' => [
|
||||
'name' => 'image',
|
||||
'props' => [
|
||||
'style' => 'width: 100px; height: 100px;',
|
||||
'fit' => 'cover'
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '133px'
|
||||
]
|
||||
]);
|
||||
$builder->add('state', '状态', [
|
||||
'component' => [
|
||||
'name' => 'switch',
|
||||
'api' => '/app/shortplay/control/Drama/indexUpdateState',
|
||||
'props' => [
|
||||
'active-value' => State::YES['value'],
|
||||
'inactive-value' => State::NO['value']
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$where[] = ['channels_uid', '=', $request->channels_uid];
|
||||
$title = $request->get('title');
|
||||
if ($title) {
|
||||
$where[] = ['title', 'like', "%{$title}%"];
|
||||
}
|
||||
$uid = $request->get('uid');
|
||||
if ($uid) {
|
||||
$where[] = ['uid', '=', $uid];
|
||||
}
|
||||
$drama_id = $request->get('drama_id');
|
||||
if ($drama_id) {
|
||||
$where[] = ['drama_id', '=', $drama_id];
|
||||
}
|
||||
$list = PluginShortplayDramaEpisode::where($where)
|
||||
->with(['drama'])
|
||||
->order('id desc')
|
||||
->paginate($limit);
|
||||
return $this->resData($list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\control\controller;
|
||||
|
||||
use app\Basic;
|
||||
use app\expose\build\builder\ActionBuilder;
|
||||
use app\expose\build\builder\ComponentBuilder;
|
||||
use app\expose\build\builder\FormBuilder;
|
||||
use app\expose\build\builder\TableBuilder;
|
||||
use app\expose\enum\Action;
|
||||
use app\expose\enum\State;
|
||||
use plugin\shortplay\app\model\PluginShortplayStyle;
|
||||
use plugin\shortplay\utils\enum\StyleClassify;
|
||||
use support\Request;
|
||||
|
||||
class StyleController extends Basic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new PluginShortplayStyle;
|
||||
}
|
||||
public function indexGetTable(Request $request)
|
||||
{
|
||||
$builder = new TableBuilder;
|
||||
$builder->addAction('操作', [
|
||||
'width' => '180px',
|
||||
'fixed' => 'right'
|
||||
]);
|
||||
$builder->addTableAction('编辑', [
|
||||
'model' => Action::DIALOG['value'],
|
||||
'path' => '/app/shortplay/control/Style/update',
|
||||
'props' => [
|
||||
'title' => '编辑《ID:{id}》风格'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'primary',
|
||||
'size' => 'small'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->addHeader();
|
||||
$builder->addHeaderAction('创建风格', [
|
||||
'model' => Action::DIALOG['value'],
|
||||
'path' => '/app/shortplay/control/Style/create',
|
||||
'props' => [
|
||||
'title' => '创建风格'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'success'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$formBuilder = new FormBuilder(null, null, [
|
||||
'inline' => true
|
||||
]);
|
||||
$formBuilder->add('name', '名称', 'input', '', [
|
||||
'props' => [
|
||||
'placeholder' => '名称搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$formBuilder->add('classify', '风格分类', 'select', '', [
|
||||
'options' => StyleClassify::getOptions(),
|
||||
'required' => true,
|
||||
'props' => [
|
||||
'placeholder' => '风格分类搜索',
|
||||
'clearable' => true
|
||||
]
|
||||
]);
|
||||
$builder->addScreen($formBuilder);
|
||||
$builder->add('id', 'ID', [
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('classify', '风格分类', [
|
||||
'component' => [
|
||||
'name' => 'tag',
|
||||
'options' => StyleClassify::getOptions(),
|
||||
],
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('styleinfo', '风格', [
|
||||
'component' => [
|
||||
'name' => 'table-userinfo',
|
||||
'props' => [
|
||||
'nickname' => 'name',
|
||||
'avatar' => 'image',
|
||||
'preview' => true
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('state', '状态', [
|
||||
'component' => [
|
||||
'name' => 'switch',
|
||||
'api' => '/app/shortplay/control/Style/indexUpdateState',
|
||||
'props' => [
|
||||
'active-value' => State::YES['value'],
|
||||
'inactive-value' => State::NO['value']
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'width' => '100px'
|
||||
]
|
||||
]);
|
||||
$builder->add('prompts', '提示词', [
|
||||
'props' => [
|
||||
'minWidth' => '300px'
|
||||
]
|
||||
]);
|
||||
$builder->add('create_time', '时间', [
|
||||
'props' => [
|
||||
'width' => '200px'
|
||||
],
|
||||
'component' => [
|
||||
'name' => 'table-times',
|
||||
'props' => [
|
||||
'group' => [
|
||||
[
|
||||
'field' => 'create_time',
|
||||
'label' => '创建'
|
||||
],
|
||||
[
|
||||
'field' => 'update_time',
|
||||
'label' => '更新'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder = $builder->builder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function query(Request $request)
|
||||
{
|
||||
$query = $request->post('query');
|
||||
if (empty($query)) {
|
||||
return $this->resData([]);
|
||||
}
|
||||
$where = [];
|
||||
$where[] = ['name|prompts', 'like', "%{$query}%"];
|
||||
return $this->resData(PluginShortplayStyle::options($where));
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->get('limit', 10);
|
||||
$where = [];
|
||||
$where[] = ['channels_uid', '=', $request->channels_uid];
|
||||
$name = $request->get('name');
|
||||
if ($name) {
|
||||
$where[] = ['name', 'like', "%{$name}%"];
|
||||
}
|
||||
$classify = $request->get('classify');
|
||||
if ($classify) {
|
||||
$where[] = ['classify', '=', $classify];
|
||||
}
|
||||
$list = PluginShortplayStyle::where($where)
|
||||
->order('id desc')->paginate($limit)->each(function ($item) {});
|
||||
return $this->resData($list);
|
||||
}
|
||||
public function create(Request $request)
|
||||
{
|
||||
if ($request->method() === 'POST') {
|
||||
$D = $request->post();
|
||||
try {
|
||||
$PluginShortplayStyle = new PluginShortplayStyle;
|
||||
$PluginShortplayStyle->channels_uid = $request->channels_uid;
|
||||
$PluginShortplayStyle->name = $D['name'];
|
||||
$PluginShortplayStyle->classify = $D['classify'];
|
||||
$PluginShortplayStyle->image = $D['image'];
|
||||
$PluginShortplayStyle->state = $D['state'];
|
||||
$PluginShortplayStyle->prompts = $D['prompts'];
|
||||
$PluginShortplayStyle->save();
|
||||
} catch (\Throwable $th) {
|
||||
return $this->exception($th);
|
||||
}
|
||||
return $this->success('创建成功');
|
||||
}
|
||||
$builder = $this->getFormBuilder();
|
||||
return $this->resData($builder);
|
||||
}
|
||||
public function update(Request $request)
|
||||
{
|
||||
if ($request->method() === 'POST') {
|
||||
$D = $request->post();
|
||||
try {
|
||||
$PluginShortplayStyle = PluginShortplayStyle::where(['id' => $D['id'], 'channels_uid' => $request->channels_uid])->find();
|
||||
$PluginShortplayStyle->name = $D['name'];
|
||||
$PluginShortplayStyle->classify = $D['classify'];
|
||||
$PluginShortplayStyle->image = $D['image'];
|
||||
$PluginShortplayStyle->state = $D['state'];
|
||||
$PluginShortplayStyle->prompts = $D['prompts'];
|
||||
$PluginShortplayStyle->save();
|
||||
} catch (\Throwable $th) {
|
||||
return $this->exception($th);
|
||||
}
|
||||
return $this->success('更新成功');
|
||||
}
|
||||
$id = $request->get('id');
|
||||
$Style = PluginShortplayStyle::where(['id' => $id, 'channels_uid' => $request->channels_uid])->find();
|
||||
$builder = $this->getFormBuilder();
|
||||
$builder->setData($Style->toArray());
|
||||
return $this->resData($builder);
|
||||
}
|
||||
private function getFormBuilder()
|
||||
{
|
||||
$builder = new FormBuilder(null, null, [
|
||||
'translations' => true,
|
||||
'size' => 'large',
|
||||
]);
|
||||
$Component = new ComponentBuilder;
|
||||
$builder->add('classify', '风格分类', 'radio', StyleClassify::ANIME['value'], [
|
||||
'options' => StyleClassify::getOptions(),
|
||||
'required' => true,
|
||||
'subProps' => [
|
||||
'border' => true
|
||||
],
|
||||
]);
|
||||
$builder->add('image', '风格图', 'bundle', '', [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 8,
|
||||
'xl' => 8
|
||||
],
|
||||
'prompt' => [
|
||||
$Component->add('text', ['default' => '支持jpg、png、jpeg格式,大小不超过2M'], ['type' => 'info', 'size' => 'small'])->builder()
|
||||
],
|
||||
'required' => true,
|
||||
'props' => [
|
||||
'accept' => 'image/jpeg,image/png,image/jpg',
|
||||
'multiple' => 1,
|
||||
'size' => 2,
|
||||
'customStyle' => '--el-upload-list-picture-card-height:200px;--el-upload-list-picture-card-width:160px;'
|
||||
]
|
||||
]);
|
||||
$actionBuilder = new ActionBuilder('', [
|
||||
'class' => 'mt-4'
|
||||
]);
|
||||
$actionBuilder->add('AI 生成风格图', [
|
||||
'model' => Action::REQUEST['value'],
|
||||
'path' => '/app/shortplay/control/Style/generateImage',
|
||||
'field' => '*',
|
||||
'component' => [
|
||||
'name' => 'button',
|
||||
'props' => [
|
||||
'type' => 'success',
|
||||
'size' => 'small',
|
||||
'bg' => true,
|
||||
'text' => true,
|
||||
'icon' => 'Refresh',
|
||||
]
|
||||
]
|
||||
]);
|
||||
$builder->add('prompt', 'AI 提示词', 'input', '', [
|
||||
'col' => [
|
||||
'xs' => 24,
|
||||
'sm' => 24,
|
||||
'md' => 12,
|
||||
'lg' => 16,
|
||||
'xl' => 16
|
||||
],
|
||||
'props' => [
|
||||
'type' => 'textarea',
|
||||
'autosize' => [
|
||||
'minRows' => 4,
|
||||
'maxRows' => 20
|
||||
]
|
||||
]
|
||||
], $actionBuilder);
|
||||
$builder->add('name', '名称', 'input', '', [
|
||||
'required' => true,
|
||||
'maxlength' => 30,
|
||||
'show-word-limit' => true,
|
||||
]);
|
||||
$builder->add('state', '状态', 'radio', State::YES['value'], [
|
||||
'options' => State::getOptions(),
|
||||
'subProps' => [
|
||||
'border' => true
|
||||
],
|
||||
'required' => true,
|
||||
]);
|
||||
$builder->add('prompts', '提示词', 'input', '', [
|
||||
'required' => true,
|
||||
'props' => [
|
||||
'type' => 'textarea',
|
||||
'autosize' => [
|
||||
'minRows' => 4,
|
||||
'maxRows' => 20
|
||||
]
|
||||
]
|
||||
]);
|
||||
return $builder;
|
||||
}
|
||||
public function generateImage(Request $request)
|
||||
{
|
||||
$prompt = $request->post('prompt');
|
||||
if (empty($prompt)) {
|
||||
return $this->fail('AI提示词不能为空');
|
||||
}
|
||||
$actionBuilder = new ActionBuilder();
|
||||
$image = 'https://' . $request->host() . '/uploads/default/20251122/5b8dcf4cbec3ba58057884929194349c_69217f42205c5.jfif';
|
||||
$actionBuilder->setData([
|
||||
'image' => $image
|
||||
]);
|
||||
$actionBuilder->setDataAction('append');
|
||||
return $this->success('生成成功', $actionBuilder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\controller;
|
||||
|
||||
use app\Basic;
|
||||
use support\Cache;
|
||||
use support\Request;
|
||||
|
||||
class DownloadController extends Basic
|
||||
{
|
||||
public function storyboard(Request $request)
|
||||
{
|
||||
$uuid = $request->get('uuid');
|
||||
$cacheData = Cache::get('downloadPackage_' . $uuid);
|
||||
if (!$cacheData) {
|
||||
return not_found();
|
||||
}
|
||||
return response()->download($cacheData['filepath'] . $cacheData['filename'], $cacheData['filename']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Here is your custom functions.
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use app\model\Basic;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\shortplay\utils\enum\ActorStatus;
|
||||
use plugin\user\app\model\PluginUser;
|
||||
use support\Request;
|
||||
use think\facade\Db;
|
||||
|
||||
class PluginShortplayActor extends Basic
|
||||
{
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'type' => [
|
||||
// 设置JSON字段的类型
|
||||
'voice' => 'json',
|
||||
]
|
||||
];
|
||||
}
|
||||
public function getThreeViewImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setThreeViewImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function getHeadimgAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setHeadimgAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function getOriginHeadimgAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $data['origin_headimg']);
|
||||
}
|
||||
public function getOriginThreeViewImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $data['origin_three_view_image']);
|
||||
}
|
||||
public function user()
|
||||
{
|
||||
return $this->hasOne(PluginUser::class, 'id', 'uid');
|
||||
}
|
||||
|
||||
public function channels()
|
||||
{
|
||||
return $this->hasOne(PluginChannelsUser::class, 'id', 'channels_uid');
|
||||
}
|
||||
public static function onAfterRead($model)
|
||||
{
|
||||
$model->status_enum = ActorStatus::get($model->status);
|
||||
if ($model->status != ActorStatus::GENERATED['value']) {
|
||||
$imageState = PluginModelTask::processing(['alias_id' => $model->id, 'scene' => ModelScene::ACTOR_IMAGE['value']]);
|
||||
$threeViewImageState = PluginModelTask::processing(['alias_id' => $model->id, 'scene' => ModelScene::ACTOR_THREE_VIEW_IMAGE['value']]);
|
||||
if ($imageState > 0 || $threeViewImageState > 0) {
|
||||
$model->status_enum = ActorStatus::PENDING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一查询构造器
|
||||
* @param array $params 包含 drama_id, episode_id, storyboard_id 的数组
|
||||
* @return PluginShortplayActor
|
||||
*/
|
||||
public static function actorQuery($params = [])
|
||||
{
|
||||
$query = (new PluginShortplayActor)->alias('actor');
|
||||
// 处理参数,统一为 0 或具体 ID
|
||||
$sid = !empty($params['storyboard_id']) ? (int)$params['storyboard_id'] : 0;
|
||||
$eid = !empty($params['episode_id']) ? (int)$params['episode_id'] : 0;
|
||||
$did = !empty($params['drama_id']) ? (int)$params['drama_id'] : 0;
|
||||
|
||||
$fields = ['actor.*,actor.headimg as origin_headimg,actor.three_view_image as origin_three_view_image'];
|
||||
$activeLevels = [];
|
||||
|
||||
/**
|
||||
* 1. 动态关联所有可能的层级 (全部使用 LEFT JOIN 保证回退链路通畅)
|
||||
*/
|
||||
if ($sid) {
|
||||
$query->leftJoin('php_plugin_shortplay_drama_storyboard_actor s_actor', "s_actor.actor_id = actor.id AND s_actor.storyboard_id = $sid");
|
||||
$activeLevels['s'] = 's_actor';
|
||||
$fields[] = 's_actor.id as storyboard_actor_id';
|
||||
}
|
||||
if ($eid) {
|
||||
$query->leftJoin('php_plugin_shortplay_drama_episode_actor e_actor', "e_actor.actor_id = actor.id AND e_actor.episode_id = $eid");
|
||||
$activeLevels['e'] = 'e_actor';
|
||||
$fields[] = 'e_actor.id as episode_actor_id';
|
||||
}
|
||||
if ($did) {
|
||||
$query->leftJoin('php_plugin_shortplay_drama_actor d_actor', "d_actor.actor_id = actor.id AND d_actor.drama_id = $did");
|
||||
$activeLevels['d'] = 'd_actor';
|
||||
$fields[] = 'd_actor.id as drama_actor_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* 2. 强制过滤:确保角色必须存在于你传入的最深层 ID 中
|
||||
* 对应你说的:“必须在这一集中出现的角色才显示”
|
||||
*/
|
||||
if ($sid) {
|
||||
$query->whereNotNull('s_actor.id'); // 必须在分镜表有记录
|
||||
$fields[] = 's_actor.character_look_id';
|
||||
} elseif ($eid) {
|
||||
$query->whereNotNull('e_actor.id'); // 必须在分集表有记录
|
||||
$fields[] = 'e_actor.character_look_id';
|
||||
} elseif ($did) {
|
||||
$query->whereNotNull('d_actor.id'); // 必须在短剧表有记录
|
||||
$fields[] = 'd_actor.character_look_id';
|
||||
}
|
||||
if ($sid || $eid || $did) {
|
||||
/**
|
||||
* 3. 字段组独立判定 (Image Group & Voice Group)
|
||||
*/
|
||||
$groupConfigs = [
|
||||
'img' => ['check' => 'headimg', 'fields' => ['headimg', 'three_view_image']],
|
||||
'voice' => ['check' => 'voice', 'fields' => ['voice']],
|
||||
];
|
||||
|
||||
foreach ($groupConfigs as $config) {
|
||||
$c = $config['check'];
|
||||
|
||||
// 动态构建层级判定逻辑 (按优先级顺序遍历 activeLevels)
|
||||
$winnerSql = "CASE ";
|
||||
foreach ($activeLevels as $key => $alias) {
|
||||
$winnerSql .= "WHEN $alias.$c IS NOT NULL AND $alias.$c != '' THEN '$key' ";
|
||||
}
|
||||
$winnerSql .= "ELSE 'b' END";
|
||||
|
||||
// 应用到该组所有字段
|
||||
foreach ($config['fields'] as $f) {
|
||||
$caseSql = "CASE ($winnerSql) ";
|
||||
foreach ($activeLevels as $key => $alias) {
|
||||
$caseSql .= "WHEN '$key' THEN $alias.$f ";
|
||||
}
|
||||
$caseSql .= "ELSE actor.$f END AS $f";
|
||||
$fields[] = \think\facade\Db::raw($caseSql);
|
||||
}
|
||||
}
|
||||
}
|
||||
$query->field($fields);
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\shortplay\utils\enum\ActorStatus;
|
||||
|
||||
class PluginShortplayActorCharacterLook extends Basic
|
||||
{
|
||||
public function getHeadimgAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setHeadimgAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function getThreeViewImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setThreeViewImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function characterLook()
|
||||
{
|
||||
return $this->hasOne(PluginShortplayCharacterLook::class, 'id', 'character_look_id');
|
||||
}
|
||||
public static function processing($where = [])
|
||||
{
|
||||
return self::where($where)->whereIn('status', [ActorStatus::INITIALIZING['value'], ActorStatus::PENDING['value']])->count();
|
||||
}
|
||||
public static function onAfterRead($model)
|
||||
{
|
||||
$model->status_enum = ActorStatus::get($model->status);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\shortplay\utils\enum\ActorStatus;
|
||||
|
||||
class PluginShortplayCharacterLook extends Basic
|
||||
{
|
||||
public function getCostumeUrlAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setCostumeUrlAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public static function onAfterRead($model)
|
||||
{
|
||||
$model->status_enum = ActorStatus::get($model->status);
|
||||
if ($model->status != ActorStatus::GENERATED['value']) {
|
||||
$imageState = PluginModelTask::processing(['alias_id' => $model->id, 'scene' => ModelScene::CHARACTER_LOOK_COSTUME['value']]);
|
||||
if ($imageState > 0) {
|
||||
$model->status_enum = ActorStatus::PENDING;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use app\model\Basic;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
|
||||
class PluginShortplayDrama extends Basic
|
||||
{
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'type' => [
|
||||
// 设置JSON字段的类型
|
||||
'voice' => 'json',
|
||||
]
|
||||
];
|
||||
}
|
||||
public function style()
|
||||
{
|
||||
return $this->hasOne(PluginShortplayStyle::class, 'id', 'style_id');
|
||||
}
|
||||
public function episodes()
|
||||
{
|
||||
return $this->hasMany(PluginShortplayDramaEpisode::class, 'drama_id', 'id');
|
||||
}
|
||||
public function getCoverAttr($value,$data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setCoverAttr($value,$data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function channels()
|
||||
{
|
||||
return $this->hasOne(PluginChannelsUser::class, 'id', 'channels_uid');
|
||||
}
|
||||
public static function onAfterRead($model)
|
||||
{
|
||||
$model->cover_state = PluginModelTask::processing(['alias_id' => $model->id, 'scene' => ModelScene::DRAMA_COVER['value']]);
|
||||
$model->continue_episode_state = PluginModelTask::processing(['alias_id' => $model->id, 'scene' => ModelScene::CREATIVE_EPISODE['value']]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
|
||||
class PluginShortplayDramaActor extends Basic
|
||||
{
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'type' => [
|
||||
// 设置JSON字段的类型
|
||||
'voice' => 'json',
|
||||
]
|
||||
];
|
||||
}
|
||||
public function actor()
|
||||
{
|
||||
return $this->hasOne(PluginShortplayActor::class, 'id', 'actor_id');
|
||||
}
|
||||
public function getThreeViewImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setThreeViewImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function getHeadimgAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setHeadimgAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use app\model\Basic;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
|
||||
class PluginShortplayDramaEpisode extends Basic
|
||||
{
|
||||
public function scenes()
|
||||
{
|
||||
return $this->hasMany(PluginShortplayDramaScene::class, 'episode_id', 'id');
|
||||
}
|
||||
public function storyboards()
|
||||
{
|
||||
return $this->hasMany(PluginShortplayDramaStoryboard::class, 'episode_id', 'id')->with(['actors', 'sceneFind', 'props', 'dialogues']);
|
||||
}
|
||||
public function actors()
|
||||
{
|
||||
return $this->hasMany(PluginShortplayDramaEpisodeActor::class, 'episode_id', 'id')->with('actor');
|
||||
}
|
||||
public function getCoverAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setCoverAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function getVideoPathAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setVideoPathAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function channels()
|
||||
{
|
||||
return $this->hasOne(PluginChannelsUser::class, 'id', 'channels_uid');
|
||||
}
|
||||
public function drama()
|
||||
{
|
||||
return $this->hasOne(PluginShortplayDrama::class, 'id', 'drama_id');
|
||||
}
|
||||
public static function onAfterRead($model)
|
||||
{
|
||||
$model->init_scene_state = PluginModelTask::processing(['alias_id' => $model->id, 'scene' => ModelScene::CREATIVE_SCENES['value']]);
|
||||
$model->init_storyboard_state = PluginModelTask::processing(['alias_id' => $model->id, 'scene' => ModelScene::CREATIVE_STORYBOARDS['value']]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
|
||||
class PluginShortplayDramaEpisodeActor extends Basic
|
||||
{
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'type' => [
|
||||
// 设置JSON字段的类型
|
||||
'voice' => 'json',
|
||||
]
|
||||
];
|
||||
}
|
||||
public function actor()
|
||||
{
|
||||
return $this->hasOne(PluginShortplayActor::class, 'id', 'actor_id');
|
||||
}
|
||||
public function getThreeViewImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setThreeViewImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function getHeadimgAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setHeadimgAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
|
||||
class PluginShortplayDramaScene extends Basic
|
||||
{
|
||||
public function getImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public static function onAfterRead($model)
|
||||
{
|
||||
$model->image_state = PluginModelTask::processing(['alias_id' => $model->id, 'scene' => ModelScene::SCENE_IMAGE['value']]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
|
||||
class PluginShortplayDramaStoryboard extends Basic
|
||||
{
|
||||
public function actors()
|
||||
{
|
||||
return $this->hasMany(PluginShortplayDramaStoryboardActor::class, 'storyboard_id', 'id')->with('actor');
|
||||
}
|
||||
public function sceneFind()
|
||||
{
|
||||
return $this->hasOne(PluginShortplayDramaScene::class, 'id', 'scene_id');
|
||||
}
|
||||
public function props()
|
||||
{
|
||||
return $this->hasMany(PluginShortplayDramaStoryboardProp::class, 'storyboard_id', 'id')->with('prop');
|
||||
}
|
||||
public function dialogues()
|
||||
{
|
||||
return $this->hasMany(PluginShortplayDramaStoryboardDialogue::class, 'storyboard_id', 'id')->with('actor');
|
||||
}
|
||||
public function getImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function getVideoAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setVideoAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function getNarrationAudioAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setNarrationAudioAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public static function onAfterRead($model)
|
||||
{
|
||||
$model->image_state = PluginModelTask::processing(['alias_id' => $model->id, 'scene' => ModelScene::STORYBOARD_IMAGE['value']]);
|
||||
$model->video_state = PluginModelTask::processing(['alias_id' => $model->id, 'scene' => ModelScene::STORYBOARD_VIDEO['value']]);
|
||||
$model->narration_state = PluginModelTask::processing(['alias_id' => $model->id, 'scene' => ModelScene::STORYBOARD_NARRATION_VOICE['value']]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
|
||||
class PluginShortplayDramaStoryboardActor extends Basic
|
||||
{
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'type' => [
|
||||
// 设置JSON字段的类型
|
||||
'voice' => 'json',
|
||||
]
|
||||
];
|
||||
}
|
||||
public function actor()
|
||||
{
|
||||
return $this->hasOne(PluginShortplayActor::class, 'id', 'actor_id');
|
||||
}
|
||||
public function getThreeViewImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setThreeViewImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function getHeadimgAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setHeadimgAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public static function onAfterRead($model)
|
||||
{
|
||||
|
||||
$model->character_look_state = 0;
|
||||
if ($model->character_look_id) {
|
||||
$params['drama_id'] = $model->drama_id;
|
||||
$params['episode_id'] = $model->episode_id;
|
||||
$params['storyboard_id'] = $model->storyboard_id;
|
||||
$params['actor_id'] = $model->actor_id;
|
||||
$model->character_look_state = PluginShortplayActorCharacterLook::processing($params);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
|
||||
class PluginShortplayDramaStoryboardDialogue extends Basic
|
||||
{
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'type' => [
|
||||
// 设置JSON字段的类型
|
||||
'prosody_speed' => 'float',
|
||||
'prosody_volume' => 'float',
|
||||
'voice' => 'json',
|
||||
]
|
||||
];
|
||||
}
|
||||
public function getAudioAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setAudioAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function actor()
|
||||
{
|
||||
return $this->hasOne(PluginShortplayActor::class, 'id', 'actor_id');
|
||||
}
|
||||
public function storyboard()
|
||||
{
|
||||
return $this->hasOne(PluginShortplayDramaStoryboard::class, 'id', 'storyboard_id');
|
||||
}
|
||||
public static function onAfterRead($model)
|
||||
{
|
||||
$model->voice_state = PluginModelTask::processing(['alias_id' => $model->id, 'scene' => ModelScene::DIALOGUE_VOICE['value']]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
|
||||
class PluginShortplayDramaStoryboardProp extends Basic
|
||||
{
|
||||
public function prop()
|
||||
{
|
||||
return $this->hasOne(PluginShortplayProp::class, 'id', 'prop_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use app\model\Basic;
|
||||
use plugin\model\app\model\PluginModelTask;
|
||||
use plugin\model\utils\enum\ModelScene;
|
||||
use plugin\shortplay\utils\enum\PropStatus;
|
||||
|
||||
class PluginShortplayProp extends Basic
|
||||
{
|
||||
public function getThreeViewImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setThreeViewImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function getImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public static function onAfterRead($model)
|
||||
{
|
||||
$model->status_enum =PropStatus::get($model->status);
|
||||
if ($model->status != PropStatus::GENERATED['value']) {
|
||||
$imageState = PluginModelTask::processing(['alias_id' => $model->id, 'scene' => ModelScene::PROP_IMAGE['value']]);
|
||||
$threeViewImageState = PluginModelTask::processing(['alias_id' => $model->id, 'scene' => ModelScene::PROP_THREE_VIEW_IMAGE['value']]);
|
||||
if ($imageState > 0 || $threeViewImageState > 0) {
|
||||
$model->status_enum = PropStatus::PENDING;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
use plugin\user\app\model\PluginUser;
|
||||
|
||||
class PluginShortplayShare extends Basic
|
||||
{
|
||||
public function channels()
|
||||
{
|
||||
return $this->hasOne(PluginChannelsUser::class, 'id', 'channels_uid');
|
||||
}
|
||||
public function user()
|
||||
{
|
||||
return $this->hasOne(PluginUser::class, 'id', 'uid');
|
||||
}
|
||||
public function drama()
|
||||
{
|
||||
return $this->hasOne(PluginShortplayDrama::class, 'id', 'drama_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
|
||||
class PluginShortplayShareEpisode extends Basic
|
||||
{
|
||||
public function channels()
|
||||
{
|
||||
return $this->hasOne(PluginChannelsUser::class, 'id', 'channels_uid');
|
||||
}
|
||||
public function drama()
|
||||
{
|
||||
return $this->hasOne(PluginShortplayDrama::class, 'id', 'drama_id');
|
||||
}
|
||||
public function episode()
|
||||
{
|
||||
return $this->hasOne(PluginShortplayDramaEpisode::class, 'id', 'episode_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use app\model\Basic;
|
||||
|
||||
class PluginShortplayShareLikes extends Basic
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use app\model\Basic;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
|
||||
class PluginShortplayStyle extends Basic
|
||||
{
|
||||
public function getImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setImageAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function channels()
|
||||
{
|
||||
return $this->hasOne(PluginChannelsUser::class, 'id', 'channels_uid');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\shortplay\app\model;
|
||||
|
||||
use plugin\control\expose\helper\Uploads;
|
||||
use app\model\Basic;
|
||||
use plugin\control\app\model\PluginChannelsUser;
|
||||
|
||||
class PluginShortplayVoice extends Basic
|
||||
{
|
||||
public function getHeadimgAttr($value, $data)
|
||||
{
|
||||
return Uploads::url($data['channels_uid'], $value);
|
||||
}
|
||||
public function setHeadimgAttr($value, $data)
|
||||
{
|
||||
return Uploads::path($data['channels_uid'], $value);
|
||||
}
|
||||
public function channels()
|
||||
{
|
||||
return $this->hasOne(PluginChannelsUser::class, 'id', 'channels_uid');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user