gorden hace 1 año
padre
commit
2bc520d0b8

+ 55 - 0
app/admin/controller/medical/ShopController.php

@@ -0,0 +1,55 @@
+<?php
+
+namespace app\admin\controller\medical;
+
+use app\admin\validate\medical\ShopValidate;
+use app\controller\Curd;
+use app\model\MedicalShop;
+use support\Request;
+use support\Response;
+
+class ShopController extends Curd
+{
+    public function __construct()
+    {
+        $this->model = new MedicalShop();
+        $this->validate = true;
+        $this->validateClass = new ShopValidate();
+    }
+
+    /**
+     * @Desc 删除
+     * @Author Gorden
+     * @Date 2024/3/1 9:15
+     *
+     * @param Request $request
+     * @return Response
+     * @throws \support\exception\BusinessException
+     */
+    public function select(Request $request): Response
+    {
+        [$where, $format, $limit, $field, $order] = $this->selectInput($request);
+        $order = $request->get('order', 'desc');
+        $field = $field ?? 'shop_sort';
+        $where['shop_is_del'] = 0;
+        $query = $this->doSelect($where, $field, $order);
+        return $this->doFormat($query, $format, $limit);
+    }
+
+    /**
+     * @Desc 删除
+     * @Author Gorden
+     * @Date 2024/3/1 9:14
+     *
+     * @param Request $request
+     * @return Response
+     * @throws \support\exception\BusinessException
+     */
+    public function delete(Request $request): Response
+    {
+        $ids = $this->deleteInput($request);
+        $this->doSoftDelete($ids, ['shop_is_del' => 1]);
+
+        return json_success('success');
+    }
+}

+ 35 - 0
app/admin/validate/medical/ShopValidate.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace app\admin\validate\medical;
+
+use think\Validate;
+
+class ShopValidate extends Validate
+{
+    protected $rule = [
+        'shop_id' => 'require|integer',
+        'shop_name' => 'require|chsDash',
+        'shop_real_name' => 'require|chsDash',
+        'shop_logo' => 'regex:/^[0-9a-zA-Z\/\.]+$/',
+        'shop_img' => 'regex:/^[0-9a-zA-Z\.\/]+$/',
+        'shop_label' => '/^[\x{4e00}-\x{9fa5}a-zA-Z0-9\_\-\,\s]+$/u',
+        'shop_category_id' => 'require|integer',
+        'shop_score' => 'require|float',
+        'shop_type' => 'require|in:1,2,3,4,5',
+        'shop_is_audit' => 'require|in:0,1',
+        'shop_lat' => 'regex:/^[0-9a-zA-Z\.]+$/',
+        'shop_lng' => 'regex:/^[0-9a-zA-Z\.]+$/',
+        'shop_phone' => 'mobile',
+        'shop_sort' => 'require|integer',
+        'shop_status' => 'require|in:0,1'
+    ];
+
+    protected $message = [];
+
+    protected $scene = [
+        'add' => ['shop_name', 'shop_real_name', 'shop_logo', 'shop_img', 'shop_label', 'shop_category_id', 'shop_score', 'shop_type',
+            'shop_is_audit', 'shop_lat', 'shop_lng', 'shop_phone', 'shop_sort', 'shop_status'],
+        'update' => ['shop_id', 'shop_name', 'shop_real_name', 'shop_logo', 'shop_img', 'shop_label', 'shop_category_id', 'shop_score',
+            'shop_type', 'shop_is_audit', 'shop_lat', 'shop_lng', 'shop_phone', 'shop_sort', 'shop_status'],
+    ];
+}

+ 26 - 0
app/model/MedicalShop.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace app\model;
+
+use support\Model;
+
+class MedicalShop extends Model
+{
+    protected $table = 'medical_shop';
+
+    protected $primaryKey = 'shop_id';
+
+    protected $dateFormat = 'U';
+
+    public const CREATED_AT = 'shop_addTime';
+
+    public const UPDATED_AT = 'shop_updateTime';
+
+    public static $shopType = [
+        1 => '医疗',
+        2 => '健康',
+        3 => '养老',
+        4 => '居家',
+        5 => '悦活'
+    ];
+}

+ 9 - 0
route/admin.php

@@ -213,5 +213,14 @@ Route::group('/admin', function () {
         })->middleware([
             \app\middleware\AdminAuthCheck::class
         ]);
+        /* 店铺管理 */
+        Route::group('/shop', function () {
+            Route::get('/list', [\app\admin\controller\medical\ShopController::class, 'select']);
+            Route::post('/add', [\app\admin\controller\medical\ShopController::class, 'insert']);
+            Route::post('/update', [\app\admin\controller\medical\ShopController::class, 'update']);
+            Route::delete('/delete', [\app\admin\controller\medical\ShopController::class, 'delete']);
+        })->middleware([
+            \app\middleware\AdminAuthCheck::class
+        ]);
     });
 });