FastMovieAI AI短剧创作平台 二开基线

- 源码: xhadmincn/FastMovieAI (Apache 2.0)
- 二开: Docker部署, Swoole改Select, route.php修复, 补update/VERSION
- vendor/示例资源已gitignore
This commit is contained in:
李建琦
2026-08-26 18:37:36 +08:00
commit eae151fd57
888 changed files with 105571 additions and 0 deletions
@@ -0,0 +1,10 @@
<?php
namespace plugin\article\app;
use app\Basic as AppBasic;
class Basic extends AppBasic
{
public $plugin = '/app/article/';
}
@@ -0,0 +1,287 @@
<?php
namespace plugin\notification\app\admin\controller;
use app\Basic;
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\notification\app\model\PluginNotificationMessage;
use plugin\notification\expose\helper\Message;
use plugin\notification\utils\enum\MessageScene;
use support\Request;
class MessageController extends Basic
{
public function __construct()
{
$this->model = new PluginNotificationMessage();
}
public function indexGetTable(Request $request)
{
$builder = new TableBuilder();
$builder->addHeader();
$builder->addHeaderAction('推送测试', [
'model' => Action::DIALOG['value'],
'path' => '/app/notification/admin/Message/pushTest',
'props' => [
'title' => '推送测试'
],
'component' => [
'name' => 'button',
'props' => [
'type' => 'success'
]
]
]);
$channelList = PluginChannelsUser::options();
$formBuilder = new FormBuilder(null, null, [
'inline' => true
]);
$formBuilder->add('channels_uid', '渠道', 'select', '', [
'options' => $channelList,
'props' => [
'placeholder' => '渠道搜索',
'clearable' => true
]
]);
$formBuilder->add('uid', 'UID', 'input', '', [
'props' => [
'placeholder' => 'UID搜索',
]
]);
$formBuilder->add('scene', '场景', 'select', '', [
'options' => MessageScene::getOptions(),
'props' => [
'placeholder' => '场景搜索',
'clearable' => true
]
]);
$formBuilder->add('state', '状态', 'select', '', [
'options' => State::getOptions(),
'props' => [
'placeholder' => '状态搜索',
'clearable' => true
]
]);
$builder->addScreen($formBuilder);
// $builder->addAction('操作', [
// 'width' => '200px',
// 'fixed' => 'right'
// ]);
$builder->add('id', 'ID', [
'props' => [
'width' => '100px'
]
]);
$builder->add('channels', '渠道', [
'where' => [
['channels_uid', '!=', null]
],
'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' => [
'width' => '200px'
]
]);
$builder->add('scene', '场景', [
'component' => [
'name' => 'tag',
'options' => MessageScene::getOptions()
],
'props' => [
'width' => '120px'
]
]);
$builder->add('state', '状态', [
'component' => [
'name' => 'switch',
'api' => '/app/notification/admin/Message/indexUpdateState',
'props' => [
'active-value' => State::YES['value'],
'inactive-value' => State::NO['value']
]
],
'props' => [
'width' => '120px'
]
]);
$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 = [];
$channels_uid = $request->get('channels_uid');
if ($channels_uid) {
$where[] = ['channels_uid', '=', $channels_uid];
}
$title = $request->get('title');
if ($title) {
$where[] = ['title', 'like', "%{$title}%"];
}
$scene = $request->get('scene');
if ($scene) {
$where[] = ['scene', '=', $scene];
}
$state = $request->get('state');
if ($state) {
$where[] = ['state', '=', $state];
}
$uid = $request->get('uid');
if ($uid) {
$where[] = ['uid', '=', $uid];
}
$list = PluginNotificationMessage::with(['user' => function ($query) {
$query->field('id,nickname,headimg,mobile,channels_uid');
}, 'channels' => function ($query) {
$query->field('id,nickname,headimg,mobile');
}])
->where($where)
->order('id desc')
->paginate($limit);
return $this->resData($list);
}
public function pushTest(Request $request)
{
if ($request->method() === 'POST') {
$D = $request->post();
$Message = new Message();
if ($D['channels_uid']) {
$Message->setChannelsUid($D['channels_uid']);
}
if ($D['uid']) {
$Message->setUid($D['uid']);
}
if ($D['scene']) {
$Message->setScene($D['scene']);
}
if ($D['title']) {
$Message->setTitle($D['title']);
}
if ($D['content']) {
$Message->setContent($D['content']);
}
$Message->save();
return $this->success('推送成功');
}
$formBuilder = new FormBuilder(null, null, [
'labelPosition' => 'right',
'label-width' => "200px",
'class' => 'w-80 mx-auto',
'size' => 'large'
]);
$channelList = PluginChannelsUser::options();
$formBuilder->add('channels_uid', '渠道', 'select', '', [
'options' => $channelList,
'props' => [
'placeholder' => '渠道',
'clearable' => true
]
]);
$formBuilder->add('uid', 'UID', 'input', '', [
'props' => [
'placeholder' => '推送指定UID',
'clearable' => true
]
]);
$formBuilder->add('state', '状态', 'switch', State::YES['value'], [
'props' => [
'active-value' => State::YES['value'],
'inactive-value' => State::NO['value']
]
]);
$formBuilder->add('scene', '场景', 'select', '', [
'required' => true,
'options' => MessageScene::getOptions()
]);
$formBuilder->add('title', '标题', 'input', '', [
'required' => true,
'props' => [
'placeholder' => '标题'
]
]);
$formBuilder->add('content', '内容', 'input', '', [
'required' => true,
'props' => [
'type' => 'textarea',
'autosize' => [
'minRows' => 4,
'maxRows' => 20
],
'placeholder' => '内容'
]
]);
return $this->resData($formBuilder);
}
}
@@ -0,0 +1,28 @@
<?php
namespace plugin\notification\app\admin\controller;
use app\Basic;
use app\expose\trait\Config;
use support\Request;
class SystemController extends Basic
{
use Config;
public function strategy(Request $request)
{
return $this->builder();
}
public function push(Request $request)
{
return $this->builder();
}
public function wechat_template(Request $request)
{
return $this->builder();
}
public function sms_template(Request $request)
{
return $this->builder();
}
}
@@ -0,0 +1,31 @@
<?php
namespace plugin\notification\app\admin\controller;
use app\Basic;
use app\expose\helper\Wechat;
use GuzzleHttp\Client;
use support\Request;
class WechatTemplateController extends Basic
{
public function getTemplateId(Request $request)
{
$field=$request->post('field');
$access_token = Wechat::getAccessToken();
$url = "https://api.weixin.qq.com/cgi-bin/template/api_add_template?access_token=" . $access_token;
$params = [
'template_id_short' => $request->post('template_id_short'),
'keyword_name_list' => $request->post('keywords'),
];
$client = new Client([
'content_type' => 'application/json',
]);
$response = $client->post($url, ['body' => json_encode($params, JSON_UNESCAPED_UNICODE)]);
$data = json_decode($response->getBody()->getContents(), true);
if (empty($data['template_id'])) {
throw new \Exception("[{$data['errcode']}]" . $data['errmsg']);
}
return $this->success('获取成功',[$field=>$data['template_id']]);
}
}
@@ -0,0 +1,71 @@
<?php
namespace plugin\notification\app\api\controller;
use app\Basic;
use app\expose\enum\State;
use plugin\developer\utils\enum\InviteState;
use plugin\notification\app\model\PluginNotificationMessage;
use plugin\notification\utils\enum\MessageScene;
use support\Request;
class MessageController extends Basic
{
public function index(Request $request)
{
return $this->resData([
'unread' => PluginNotificationMessage::where(['uid' => $request->uid, 'read_state' => State::NO['value']])->count(),
'read' => PluginNotificationMessage::where(['uid' => $request->uid, 'read_state' => State::YES['value']])->count(),
]);
}
public function list(Request $request)
{
$limit = $request->get('limit', 10);
$where = [];
$title = $request->get('title');
if ($title) {
$where[] = ['title', 'like', "%{$title}%"];
}
$read=$request->get('read', 'all');
if($read !== 'all'){
$where[] = ['read_state', '=', $read == 'read' ? State::YES['value'] : State::NO['value']];
}
$where[] = ['uid', '=', $request->uid];
$model = PluginNotificationMessage::where($where);
$list = $model->order('id desc')->paginate($limit)->each(function ($item) {
if($item->effect=='danger'){
$item->effect = 'error';
}
$item->scene_enum = MessageScene::get($item->scene);
// switch($item->scene){
// case MessageScene::INVITE_JOIN_TEAM['value']:
// $item->state_enum = InviteState::get($item->state);
// break;
// default:
// $item->state_enum = State::get($item->state);
// if($item->state==State::YES['value']){
// $item->effect = 'info';
// }
// break;
// }
});
return $this->resData($list);
}
/**
* 详情
* @author:1950781041@qq.com
* @Date:2026-01-22
*/
public function detail(Request $request)
{
$id = $request->get('id');
$message = PluginNotificationMessage::with('content')->where(['id' => $id])->find();
$message->read_state=1;
$message->save();
if($message){
return $this->resData($message);
}
return $this->fail('消息不存在');
}
}
@@ -0,0 +1,60 @@
<?php
namespace plugin\notification\app\api\controller;
use app\Basic;
use app\expose\enum\State;
use plugin\finance\app\model\PluginFinanceOrders;
use plugin\notification\utils\Api;
use plugin\shortplay\app\model\PluginShortplayDrama;
use plugin\user\app\model\PluginUser;
use plugin\notification\utils\enum\AuthType;
use support\Request;
class PushController extends Basic
{
public function auth(Request $request)
{
$pusher = new Api(str_replace('0.0.0.0', '127.0.0.1', config('plugin.webman.push.app.api')), config('plugin.webman.push.app.app_key'), config('plugin.webman.push.app.app_secret'));
$channel_name = $request->post('channel_name');
$authType = AuthType::getValues();
$match = preg_match('/^private-(' . implode('|', $authType) . ')-(.+)$/', $channel_name, $matches);
if (!$match) {
return $this->fail('Forbidden');
}
$header = $matches[1];
$AuthTypeAction = AuthType::get($header);
$hash = $matches[2];
$has_authority = false;
switch ($AuthTypeAction['action']) {
case 'user':
$uid = PluginUser::getUidByUser($hash);
if ($uid != $request->uid) {
return $this->fail('Forbidden');
}
$PluginUser = PluginUser::where('id', $request->uid)->find();
$has_authority = $PluginUser && $PluginUser->state == State::YES['value'];
break;
case 'orders':
$PluginFinanceOrders = PluginFinanceOrders::where('trade_no', $hash)->find();
if (!$PluginFinanceOrders) {
return $this->fail('Forbidden');
}
$has_authority = $PluginFinanceOrders->uid == $request->uid;
break;
case 'drama':
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $hash, 'uid' => $request->uid])->find();
if (!$PluginShortplayDrama) {
return $this->fail('Forbidden');
}
$has_authority = true;
break;
}
if ($has_authority) {
return $this->resData(json_decode($pusher->socketAuth($channel_name, $request->post('socket_id')), true));
} else {
return $this->fail('Forbidden');
}
}
}
@@ -0,0 +1,101 @@
<?php
namespace plugin\notification\app\controller;
use app\Basic;
use plugin\finance\app\model\PluginFinanceOrders;
use plugin\notification\app\model\PluginNotificationOnline;
use plugin\notification\utils\enum\AuthType;
use plugin\shortplay\app\model\PluginShortplayDrama;
use plugin\user\app\model\PluginUser;
use support\Request;
class PushController extends Basic
{
public function hook(Request $request)
{
// 没有x-pusher-signature头视为伪造请求
if (!$webhook_signature = $request->header('x-pusher-signature')) {
return response('401 Not authenticated', 401);
}
$body = $request->rawBody();
// 计算签名,$app_secret 是双方使用的密钥,是保密的,外部无从得知
$expected_signature = hash_hmac('sha256', $body, config('plugin.webman.push.app.app_secret'), false);
// 安全校验,如果签名不一致可能是伪造的请求,返回401状态码
if ($webhook_signature !== $expected_signature) {
return response('401 Not authenticated', 401);
}
// 这里存储这上线 下线的channel数据
$payload = json_decode($body, true);
$channels_online = $channels_offline = [];
foreach ($payload['events'] as $event) {
if ($event['name'] === 'channel_added') {
$channels_online[] = $event['channel'];
} else if ($event['name'] === 'channel_removed') {
$channels_offline[] = $event['channel'];
}
}
// 业务根据需要处理上下线的channel,例如将在线状态写入数据库,通知其它channel等
// 上线的所有channel
// echo 'online channels: ' . implode(',', $channels_online) . "\n";
foreach ($channels_online as $channel) {
$PluginNotificationOnline = PluginNotificationOnline::where(['channel' => $channel])->find();
if ($PluginNotificationOnline) {
continue;
}
$authType = AuthType::getValues();
$match = preg_match('/^private-(' . implode('|', $authType) . ')-(.+)$/', $channel, $matches);
if (!$match) {
continue;
}
$header = $matches[1];
$hash = $matches[2];
$PluginNotificationOnline = new PluginNotificationOnline();
$PluginNotificationOnline->channel = $channel;
$PluginNotificationOnline->event = $header;
$PluginNotificationOnline->hash = $hash;
$AuthTypeAction = AuthType::get($header);
switch ($AuthTypeAction['action']) {
case 'user':
$PluginNotificationOnline->uid = PluginUser::getUidByUser($hash);
$PluginUser = PluginUser::where('id', $PluginNotificationOnline->uid)->find();
$PluginNotificationOnline->channels_uid = $PluginUser->channels_uid;
break;
case 'orders':
$PluginFinanceOrders = PluginFinanceOrders::where('trade_no', $hash)->find();
if (!$PluginFinanceOrders) {
break;
}
$PluginNotificationOnline->uid = $PluginFinanceOrders->uid;
$PluginNotificationOnline->channels_uid = $PluginFinanceOrders->channels_uid;
break;
case 'drama':
$PluginShortplayDrama = PluginShortplayDrama::where(['id' => $hash])->find();
if (!$PluginShortplayDrama) {
break;
}
$PluginNotificationOnline->uid = $PluginShortplayDrama->uid;
$PluginNotificationOnline->channels_uid = $PluginShortplayDrama->channels_uid;
break;
}
$PluginNotificationOnline->save();
}
// 下线的所有channel
// echo 'offline channels: ' . implode(',', $channels_offline) . "\n";
foreach ($channels_offline as $channel) {
$PluginNotificationOnline = PluginNotificationOnline::where(['channel' => $channel])->find();
if (!$PluginNotificationOnline) {
continue;
}
$PluginNotificationOnline->delete();
}
return 'OK';
}
}
@@ -0,0 +1,6 @@
<?php
/**
* Here is your custom functions.
*/
@@ -0,0 +1,32 @@
<?php
namespace plugin\notification\app\model;
use app\model\Basic;
use plugin\control\app\model\PluginChannelsUser;
use plugin\user\app\model\PluginUser;
class PluginNotificationMessage extends Basic
{
protected function getOptions(): array
{
return [
'type' => [
'extra' => 'json'
],
];
}
public function user()
{
return $this->hasOne(PluginUser::class, 'id', 'uid');
}
public function channels()
{
return $this->hasOne(PluginChannelsUser::class, 'id', 'channels_uid');
}
public function content()
{
return $this->hasOne(PluginNotificationMessageContent::class, 'message_id', 'id');
}
}
@@ -0,0 +1,11 @@
<?php
namespace plugin\notification\app\model;
use app\model\Basic;
use plugin\user\app\model\PluginUser;
class PluginNotificationMessageContent extends Basic
{
}
@@ -0,0 +1,8 @@
<?php
namespace plugin\notification\app\model;
use app\model\Basic;
class PluginNotificationOnline extends Basic {}