wzq %!s(int64=5) %!d(string=hai) anos
pai
achega
412710d22b

+ 2 - 2
app/Http/Controllers/MessageRuleController.php

@@ -77,9 +77,9 @@ class MessageRuleController extends Controller
             'notice_groups' => 'required|string|max:31',
             'message_type' => ['required',Rule::in('star', 'system')],
             'show_type' => ['required',Rule::in('only_show', 'user', 'post', 'activity', 'topic')],
-            'activity_url' => 'required_unless:type,only_show|string|max:64',
+            'activity_url' => 'required_unless:show_type,only_show|string|max:64',
             'cover' => 'required|url',
-            'send_time' => 'nullable|datetime'
+            'send_time' => 'nullable|date'
         ]);
         if ($validator->fails()) {
             return $this->response->error($validator->errors()->first(), 500);

+ 14 - 8
app/Repositories/MessageRuleRepository.php

@@ -49,15 +49,21 @@ class MessageRuleRepository
      */
     public function create($request)
     {
-        return 2223;
-        //验证小号
-        $userInfo = $this->getUserInfo($request['uid']);
-        if(!$userInfo || $userInfo['type'] != 1){
-            return Response::create([
-                'message'  => '所选小号信息有误',
-                'status_code'   => 500
-            ]);
+        $noticeGroups = explode(',', $request['notice_groups']);
+
+        if(in_array(0, $noticeGroups)){
+            $noticeGroups = 0;
+        } else {
+            if(array_diff($noticeGroups, [1,2])){
+                return Response::create([
+                    'message'  => '通知群体参数有误',
+                    'status_code'   => 500
+                ]);
+            }
+            $noticeGroups = implode(',', array_unique($noticeGroups));
         }
+
+        return $noticeGroups;
         //验证话题
         $topicIds = $this->topic->whereIn('id', explode(',', $request['topic_ids']))->pluck('id')->toArray();
         $topicCount = count($topicIds);