Browse Source

启用分组时,对主题进行判断

wufeng 2 years ago
parent
commit
c0811bf4da

+ 1 - 1
app/admin/controller/OrderService.php

@@ -5,9 +5,9 @@ namespace app\admin\controller;
 use app\admin\logic\OrderServiceLogic;
 use app\BaseController;
 use think\exception\ValidateException;
-use think\facade\Config;
 use think\facade\Validate;
 
+//服务订单
 class OrderService extends BaseController
 {
 

+ 7 - 1
app/admin/logic/GroupLogic.php

@@ -6,6 +6,7 @@ use app\model\CardModel;
 use app\model\CommonModel;
 use app\model\CompanyModel;
 use app\model\GroupModel;
+use app\model\ThemeModel;
 use think\Exception;
 use think\exception\ValidateException;
 use think\facade\Db;
@@ -128,9 +129,14 @@ class GroupLogic extends BaseLogic
     //启禁用
     public static function status(array $data = []): Json
     {
-        if($data['status'] == CommonModel::$status_normal){
+        if ($data['status'] == CommonModel::$status_normal) {
             //启用组合时,要验证组合下是否有启用的手机主题
+            $rs = ThemeModel::field('id')
+                ->where(['is_del' => CommonModel::$del_normal, 'status' => CommonModel::$status_normal])
+                ->findOrEmpty()
+                ->isEmpty();
 
+            if ($rs) return json_show(CommonModel::$error_param, '该分组没有启用的手机主题,无法启用');
         }
         $res = GroupModel::where('id', $data['id'])
             ->where('status', '<>', $data['status'])

+ 1 - 1
app/admin/middleware.php

@@ -3,5 +3,5 @@
 //中间件定义
 
 return [
-    app\admin\middleware\apiMiddleware::class
+    app\admin\middleware\adminMiddleware::class
 ];

+ 1 - 1
app/admin/middleware/apiMiddleware.php → app/admin/middleware/adminMiddleware.php

@@ -12,7 +12,7 @@ use think\Response;
 use app\model\ActionLogModel;
 
 //中间件
-class apiMiddleware
+class adminMiddleware
 {
 
     //白名单