|
|
@@ -0,0 +1,129 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Module\UrsPromotion\AdminControllers;
|
|
|
+
|
|
|
+use UCore\DcatAdmin\AdminController;
|
|
|
+use Spatie\RouteAttributes\Attributes\Resource;
|
|
|
+use App\Module\UrsPromotion\Models\UrsUserMapping;
|
|
|
+use App\Module\UrsPromotion\Repositorys\UrsUserMappingRepository;
|
|
|
+
|
|
|
+use Dcat\Admin\Grid;
|
|
|
+use Dcat\Admin\Show;
|
|
|
+use Dcat\Admin\Form;
|
|
|
+
|
|
|
+/**
|
|
|
+ * URS用户映射关系管理控制器
|
|
|
+ *
|
|
|
+ * @route /admin/urs-promotion/user-mappings
|
|
|
+ */
|
|
|
+#[Resource('urs-promotion/user-mappings', names: 'dcat.admin.urs-promotion.user-mappings')]
|
|
|
+class UrsUserMappingController extends AdminController
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * 页面标题
|
|
|
+ */
|
|
|
+ protected $title = 'URS用户绑定关系';
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 模型类
|
|
|
+ */
|
|
|
+ protected $model = UrsUserMapping::class;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 仓库类
|
|
|
+ */
|
|
|
+ protected $repository = UrsUserMappingRepository::class;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 列表页面
|
|
|
+ */
|
|
|
+ protected function grid(): Grid
|
|
|
+ {
|
|
|
+ return Grid::make(new UrsUserMappingRepository(), function (Grid $grid) {
|
|
|
+ $grid->column('id', 'ID')->sortable();
|
|
|
+ $grid->column('urs_user_id', 'URS用户ID')->sortable();
|
|
|
+ $grid->column('user_id', '农场用户ID')->sortable();
|
|
|
+ $grid->column('mapping_time', '绑定时间')->sortable();
|
|
|
+ $grid->column('status', '状态')->using([
|
|
|
+ UrsUserMapping::STATUS_INVALID => '无效',
|
|
|
+ UrsUserMapping::STATUS_VALID => '有效',
|
|
|
+ ])->label([
|
|
|
+ UrsUserMapping::STATUS_INVALID => 'danger',
|
|
|
+ UrsUserMapping::STATUS_VALID => 'success',
|
|
|
+ ]);
|
|
|
+ $grid->column('created_at', '创建时间')->sortable();
|
|
|
+
|
|
|
+ // 禁用创建按钮(映射关系通过系统自动创建)
|
|
|
+ $grid->disableCreateButton();
|
|
|
+
|
|
|
+ // 禁用编辑(映射关系不允许手动修改)
|
|
|
+ $grid->disableActions();
|
|
|
+
|
|
|
+ // 只保留查看详情
|
|
|
+ $grid->actions(function (Grid\Displayers\Actions $actions) {
|
|
|
+ $actions->disableEdit();
|
|
|
+ $actions->disableDelete();
|
|
|
+ });
|
|
|
+
|
|
|
+ // 设置过滤器
|
|
|
+ $grid->filter(function (Grid\Filter $filter) {
|
|
|
+ $filter->equal('urs_user_id', 'URS用户ID');
|
|
|
+ $filter->equal('user_id', '农场用户ID');
|
|
|
+ $filter->equal('status', '状态')->select([
|
|
|
+ UrsUserMapping::STATUS_INVALID => '无效',
|
|
|
+ UrsUserMapping::STATUS_VALID => '有效',
|
|
|
+ ]);
|
|
|
+ $filter->between('mapping_time', '绑定时间')->datetime();
|
|
|
+ $filter->between('created_at', '创建时间')->datetime();
|
|
|
+ });
|
|
|
+
|
|
|
+ // 设置默认排序
|
|
|
+ $grid->model()->orderBy('id', 'desc');
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 详情页面
|
|
|
+ */
|
|
|
+ protected function detail($id): Show
|
|
|
+ {
|
|
|
+ return Show::make($id, new UrsUserMappingRepository(), function (Show $show) {
|
|
|
+ $show->field('id', 'ID');
|
|
|
+ $show->field('urs_user_id', 'URS用户ID');
|
|
|
+ $show->field('user_id', '农场用户ID');
|
|
|
+ $show->field('mapping_time', '绑定时间');
|
|
|
+ $show->field('status', '状态')->using([
|
|
|
+ UrsUserMapping::STATUS_INVALID => '无效',
|
|
|
+ UrsUserMapping::STATUS_VALID => '有效',
|
|
|
+ ]);
|
|
|
+ $show->field('created_at', '创建时间');
|
|
|
+ $show->field('updated_at', '更新时间');
|
|
|
+
|
|
|
+ // 禁用编辑和删除按钮
|
|
|
+ $show->disableEditButton();
|
|
|
+ $show->disableDeleteButton();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 表单页面(禁用)
|
|
|
+ */
|
|
|
+ protected function form(): Form
|
|
|
+ {
|
|
|
+ return Form::make(new UrsUserMappingRepository(), function (Form $form) {
|
|
|
+ // 映射关系不允许手动创建或编辑
|
|
|
+ $form->display('id', 'ID');
|
|
|
+ $form->display('urs_user_id', 'URS用户ID');
|
|
|
+ $form->display('user_id', '农场用户ID');
|
|
|
+ $form->display('mapping_time', '绑定时间');
|
|
|
+ $form->display('status', '状态');
|
|
|
+ $form->display('created_at', '创建时间');
|
|
|
+ $form->display('updated_at', '更新时间');
|
|
|
+
|
|
|
+ // 禁用所有操作
|
|
|
+ $form->disableCreatingCheck();
|
|
|
+ $form->disableEditingCheck();
|
|
|
+ $form->disableViewCheck();
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|