管理端 文件分享管理后端实现
This commit is contained in:
parent
27fe5f2e75
commit
d73882afeb
@ -5,12 +5,15 @@ namespace app\controllers;
|
|||||||
use app\models\CollectionUploadedSearch;
|
use app\models\CollectionUploadedSearch;
|
||||||
use app\models\DownloadLogs;
|
use app\models\DownloadLogs;
|
||||||
use app\models\LoginLogs;
|
use app\models\LoginLogs;
|
||||||
|
use app\models\Share;
|
||||||
|
use app\models\ShareSearch;
|
||||||
use app\models\SiteConfig;
|
use app\models\SiteConfig;
|
||||||
use app\models\User;
|
use app\models\User;
|
||||||
use app\models\UserSearch;
|
use app\models\UserSearch;
|
||||||
use app\utils\AdminSword;
|
use app\utils\AdminSword;
|
||||||
use app\utils\FileSizeHelper;
|
use app\utils\FileSizeHelper;
|
||||||
use OTPHP\TOTP;
|
use OTPHP\TOTP;
|
||||||
|
use RuntimeException;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Exception;
|
use yii\base\Exception;
|
||||||
@ -19,6 +22,7 @@ use yii\filters\VerbFilter;
|
|||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\HttpException;
|
use yii\web\HttpException;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
|
use yii\web\Request;
|
||||||
use yii\web\Response;
|
use yii\web\Response;
|
||||||
|
|
||||||
class AdminController extends Controller
|
class AdminController extends Controller
|
||||||
@ -36,7 +40,7 @@ class AdminController extends Controller
|
|||||||
'rules' => [
|
'rules' => [
|
||||||
[
|
[
|
||||||
'allow' => true,
|
'allow' => true,
|
||||||
'actions' => ['index', 'system', 'user', 'info', 'user-view', 'user-create', 'user-update', 'user-delete', 'user-totpoff', 'user-pwdreset', 'login-log', 'access-log', 'collection-up-log'],
|
'actions' => ['index', 'system', 'user', 'info', 'user-view', 'user-create', 'user-update', 'user-delete', 'user-totpoff', 'user-pwdreset', 'login-log', 'access-log', 'collection-up-log', 'share-manage', 'share-manage-view', 'share-manage-delete', 'collection-manage', 'notice-manage', 'feedback-manage', 'sysinfo'],
|
||||||
'roles' => ['admin'], // only admin can do these
|
'roles' => ['admin'], // only admin can do these
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@ -57,6 +61,13 @@ class AdminController extends Controller
|
|||||||
'login-log' => ['GET'],
|
'login-log' => ['GET'],
|
||||||
'access-log' => ['GET'],
|
'access-log' => ['GET'],
|
||||||
'collection-up-log' => ['GET'],
|
'collection-up-log' => ['GET'],
|
||||||
|
'share-manage' => ['GET'],
|
||||||
|
'share-manage-view' => ['GET'],
|
||||||
|
'share-manage-delete' => ['POST'],
|
||||||
|
'collection-manage' => ['GET'],
|
||||||
|
'notice-manage' => ['GET'],
|
||||||
|
'feedback-manage' => ['GET'],
|
||||||
|
'sysinfo' => ['GET'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
@ -424,4 +435,81 @@ class AdminController extends Controller
|
|||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function actionShareManage(): string
|
||||||
|
{
|
||||||
|
$searchModel = new ShareSearch();
|
||||||
|
if ($this->request instanceof Request) {
|
||||||
|
$dataProvider = $searchModel->search($this->request->queryParams);
|
||||||
|
return $this->render('share_manage', [
|
||||||
|
'searchModel' => $searchModel,
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException('Invalid request type');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected function findShareModel(int $share_id): Share
|
||||||
|
{
|
||||||
|
if (($model = Share::findOne(['share_id' => $share_id])) !== null) {
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NotFoundHttpException('The requested page does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionShareManageView(int $share_id): string
|
||||||
|
{
|
||||||
|
return $this->render('share_manage_view', [
|
||||||
|
'model' => $this->findShareModel($share_id),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionShareManageDelete(int $share_id): Response
|
||||||
|
{
|
||||||
|
$model = $this->findShareModel($share_id);
|
||||||
|
$model->status = 0;
|
||||||
|
if ($model->save()) {
|
||||||
|
Yii::$app->session->setFlash('success', 'Share delete successfully.');
|
||||||
|
} else {
|
||||||
|
Yii::$app->session->setFlash('error', 'Failed to delete share.');
|
||||||
|
}
|
||||||
|
return $this->redirect(['share-manage']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function actionCollectionManage(): string
|
||||||
|
{
|
||||||
|
return $this->render('collection_manage');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function actionNoticeManage(): string
|
||||||
|
{
|
||||||
|
return $this->render('notice_manage');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function actionFeedbackManage(): string
|
||||||
|
{
|
||||||
|
return $this->render('feedback_manage');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function actionSysinfo(): string
|
||||||
|
{
|
||||||
|
return $this->render('sysinfo');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user