From 365edd445205f1cbcf6aa57254e03743435358ad Mon Sep 17 00:00:00 2001 From: Chenx221 Date: Tue, 30 Apr 2024 15:02:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=94=B6=E9=9B=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=BC=BA=E5=8C=96=EF=BC=8C=E6=94=AF=E6=8C=81=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=96=87=E4=BB=B6=E6=97=B6=E6=B7=BB=E5=8A=A0=E5=A4=87?= =?UTF-8?q?=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/CollectionController.php | 3 ++- models/CollectionUploaded.php | 5 ++++- models/CollectionUploadedSearch.php | 9 ++++++--- views/admin/collection_up_log.php | 1 + views/collection/access.php | 1 + views/collection/view.php | 1 + 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/controllers/CollectionController.php b/controllers/CollectionController.php index 2e60abf..c81fa70 100644 --- a/controllers/CollectionController.php +++ b/controllers/CollectionController.php @@ -226,7 +226,7 @@ class CollectionController extends Controller // 获取POST请求中的参数 $taskId = $request->post('CollectionTasks')['id']; $subfolderName = $request->post('CollectionUploaded')['subfolder_name']; - + $note = $request->post('CollectionUploaded')['note']; // 获取发送POST请求的用户的IP地址 $uploaderIp = $request->userIP; @@ -245,6 +245,7 @@ class CollectionController extends Controller $model->uploaded_at = date('Y-m-d H:i:s'); // 设置上传时间为当前时间 $model->subfolder_name = $subfolderName; $model->user_agent = $request->userAgent; + $model->note = $note; if ($model->validate()) { // 进行文件上传 $targetDirectory = Yii::getAlias(Yii::$app->params['dataDirectory']) . '/' . $userId . '/' . $folderPath . '/' . $subfolderName; diff --git a/models/CollectionUploaded.php b/models/CollectionUploaded.php index b9f0df0..11826f4 100644 --- a/models/CollectionUploaded.php +++ b/models/CollectionUploaded.php @@ -15,6 +15,7 @@ use yii\db\ActiveRecord; * @property string $uploaded_at 上传时间 * @property string $subfolder_name 对应的子文件夹名 * @property string $user_agent 浏览器UA信息 + * @property string|null $note 用户设置的备注 * * @property CollectionTasks $task * @property User $user @@ -39,7 +40,8 @@ class CollectionUploaded extends ActiveRecord [['user_id', 'task_id'], 'integer'], [['uploaded_at'], 'safe'], [['uploader_ip'], 'string', 'max' => 45], - [['subfolder_name'], 'string', 'max' => 255], + [['subfolder_name', 'user_agent'], 'string', 'max' => 255], + [['note'], 'string', 'max' => 100], [['task_id'], 'exist', 'skipOnError' => true, 'targetClass' => CollectionTasks::class, 'targetAttribute' => ['task_id' => 'id']], [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::class, 'targetAttribute' => ['user_id' => 'id']], ]; @@ -58,6 +60,7 @@ class CollectionUploaded extends ActiveRecord 'uploaded_at' => '上传时间', 'subfolder_name' => '所在位置', 'user_agent' => '浏览器UA信息', + 'note' => '用户设置的备注', ]; } diff --git a/models/CollectionUploadedSearch.php b/models/CollectionUploadedSearch.php index 8b4483b..d794b57 100644 --- a/models/CollectionUploadedSearch.php +++ b/models/CollectionUploadedSearch.php @@ -16,8 +16,8 @@ class CollectionUploadedSearch extends CollectionUploaded public function rules(): array { return [ - [['id', 'task_id'], 'integer'], - [['uploader_ip', 'uploaded_at', 'subfolder_name'], 'safe'], + [['id', 'user_id', 'task_id'], 'integer'], + [['uploader_ip', 'uploaded_at', 'subfolder_name', 'user_agent', 'note'], 'safe'], ]; } @@ -58,12 +58,15 @@ class CollectionUploadedSearch extends CollectionUploaded // grid filtering conditions $query->andFilterWhere([ 'id' => $this->id, + 'user_id' => $this->user_id, 'task_id' => $this->task_id, 'uploaded_at' => $this->uploaded_at, ]); $query->andFilterWhere(['like', 'uploader_ip', $this->uploader_ip]) - ->andFilterWhere(['like', 'subfolder_name', $this->subfolder_name]); + ->andFilterWhere(['like', 'subfolder_name', $this->subfolder_name]) + ->andFilterWhere(['like', 'user_agent', $this->user_agent]) + ->andFilterWhere(['like', 'note', $this->note]); return $dataProvider; } diff --git a/views/admin/collection_up_log.php b/views/admin/collection_up_log.php index a75256a..ea9570e 100644 --- a/views/admin/collection_up_log.php +++ b/views/admin/collection_up_log.php @@ -52,6 +52,7 @@ $this->params['breadcrumbs'][] = $this->title; 'attribute' => 'user_agent', 'label' => 'User Agent', ], + 'note' ], 'pager' => [ 'class' => LinkPager::class, diff --git a/views/collection/access.php b/views/collection/access.php index 52af2dd..cbe256f 100644 --- a/views/collection/access.php +++ b/views/collection/access.php @@ -30,6 +30,7 @@ $this->params['breadcrumbs'][] = $this->title; + field($model2, 'note')->textInput(['maxlength' => true]) ?> field($model, 'id')->hiddenInput()->label(false) ?> diff --git a/views/collection/view.php b/views/collection/view.php index 6e17ea5..9e446a1 100644 --- a/views/collection/view.php +++ b/views/collection/view.php @@ -55,6 +55,7 @@ $dataProvider->query->andWhere(['task_id' => $model->id]); 'id', 'uploader_ip', 'uploaded_at', + 'note', [ 'attribute' => 'subfolder_name', 'format' => 'raw',