ソースを参照

fix(api-v13): 修正 channel 与 task 的三处字段/参数错误

ChannelController@patch:config 的值被写进了 status 列。channels 表确有 config
列(2023_08_06_125849 迁移),应写入 config。

ChannelController@index:$chapter 只在 view=user-in-chapter 分支赋值,其余口径
带 progress 参数会取到未定义变量。补初始化与判断。

TaskController@index:assignees_id_not-includes 与 participants_id_not-includes
两个分支读的都是对应 _includes 的值,导致排除条件失效。同文件 executor_id_*
是正确写法,照其修正。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
visuddhinanda 3 週間 前
親
コミット
f63206a153

+ 5 - 3
api-v13/app/Http/Controllers/ChannelController.php

@@ -30,6 +30,8 @@ class ChannelController extends Controller
     {
         //
         $result = false;
+        // $chapter 只有 view=user-in-chapter 会赋值,下面按进度取数时要先判断
+        $chapter = null;
         $indexCol = [
             'channels.uid',
             'name',
@@ -229,7 +231,7 @@ class ChannelController extends Controller
         $result = $table->get();
         // TODO 将下面代码转移到resource
         if ($result) {
-            if ($request->has('progress')) {
+            if ($request->has('progress') && $chapter) {
                 // 获取进度
                 // 获取单句长度
                 $sentLen = PaliSentence::where('book', $request->input('book'))
@@ -239,7 +241,7 @@ class ChannelController extends Controller
                     ->get();
             }
             foreach ($result as $key => $value) {
-                if ($request->has('progress')) {
+                if ($request->has('progress') && $chapter) {
                     // 获取进度
                     $finalTable = Sentence::where('book_id', $request->input('book'))
                         ->whereBetween('paragraph', $chapter)
@@ -692,7 +694,7 @@ class ChannelController extends Controller
             $channel->status = $request->input('status');
         }
         if ($request->has('config')) {
-            $channel->status = $request->input('config');
+            $channel->config = $request->input('config');
         }
         $channel->save();
 

+ 2 - 2
api-v13/app/Http/Controllers/TaskController.php

@@ -68,7 +68,7 @@ class TaskController extends Controller
             $table = $table->whereIn('id', $assigneesTasks);
         }
         if ($request->has('assignees_id_not-includes')) {
-            $assigneesId = explode(',', $request->input('assignees_id_includes'));
+            $assigneesId = explode(',', $request->input('assignees_id_not-includes'));
             $assigneesTasks = TaskAssignee::whereIn('assignee_id', $assigneesId)
                 ->select('task_id')->get();
             $table = $table->whereNotIn('id', $assigneesTasks);
@@ -96,7 +96,7 @@ class TaskController extends Controller
         }
 
         if ($request->has('participants_id_not-includes')) {
-            $id = explode(',', $request->input('participants_id_includes'));
+            $id = explode(',', $request->input('participants_id_not-includes'));
             $tasks_id = TaskAssignee::whereIn('assignee_id', $id)->select('task_id')->get();
             $table = $table->where(function ($query) use ($id, $tasks_id) {
                 $query->whereNotIn('executor_id', $id)