FastMovieAI AI短剧创作平台 二开基线
- 源码: xhadmincn/FastMovieAI (Apache 2.0) - 二开: Docker部署, Swoole改Select, route.php修复, 补update/VERSION - vendor/示例资源已gitignore
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user