IndexController.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Module\Base;
  4. use Redirect;
  5. use DB;
  6. /**
  7. * 页面
  8. * Class IndexController
  9. * @package App\Http\Controllers
  10. */
  11. class IndexController extends Controller
  12. {
  13. public function __invoke($method, $action = '', $child = '')
  14. {
  15. $app = $method ? $method : 'main';
  16. if ($action) {
  17. $app .= "__" . $action;
  18. }
  19. if (!method_exists($this, $app)) {
  20. $app = 'main';
  21. }
  22. return $this->$app($child);
  23. }
  24. /**
  25. * 首页
  26. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  27. */
  28. public function main()
  29. {
  30. return view('main', ['version' => Base::getVersion()]);
  31. }
  32. /**
  33. * 接口文档
  34. * @return \Illuminate\Http\RedirectResponse
  35. */
  36. public function api()
  37. {
  38. return Redirect::to(Base::fillUrl('docs'), 301);
  39. }
  40. public function test(){
  41. $list = Base::DBC2A(DB::table("project_log")->where('taskid',640)->orderBy('id','asc')->get());
  42. $project = [];
  43. $task = [];
  44. foreach ($list as $item) {
  45. switch ($item['detail']){
  46. case '添加任务':
  47. $project = Base::DBC2A(DB::table("project_lists")->where('id',$item['projectid'])->first());
  48. $other = Base::string2array($item['other']);
  49. $task['createuser'] = $task['username'] = $item['username'];
  50. $task['title'] = $other['title'];
  51. $task['indate'] = $item['indate'];
  52. $task['sub_task'] = [];
  53. break;
  54. case '增加子任务':
  55. $other = Base::string2array($item['other']);
  56. $subtask = [
  57. 'taskid' => 640,
  58. 'uname' => $task['username'],
  59. 'indate' => $other['subtask'][0]['time'],
  60. 'status' => $other['subtask'][0]['status'],
  61. 'detail' => $other['subtask'][0]['detail']
  62. ];
  63. $task['sub_task'][$other['subtask'][0]['detail']] = $subtask;
  64. break;
  65. case '修改子任务负责人':
  66. case '修改子任务':
  67. $other = Base::string2array($item['other']);
  68. $subtask = Base::string2array($other['subtask']);
  69. $old_subtask = Base::string2array($other['old_subtask']);
  70. if(array_key_exists($old_subtask['detail'],$task['sub_task'])){
  71. $task['sub_task'][$old_subtask['id']] = $subtask[0];
  72. unset($task['sub_task'][$old_subtask['detail']]);
  73. }else{
  74. $task['sub_task'][$old_subtask['id']] = $subtask[0];
  75. }
  76. break;
  77. case '标记已完成':
  78. $task['complete'] = 1;
  79. $task['completedate'] = $item['indate'];
  80. break;
  81. case '上传文件':
  82. if(!array_key_exists('files',$task)){
  83. $task['files'] = [];
  84. }
  85. $task['files'][] = Base::string2array($item['other']);
  86. break;
  87. }
  88. }
  89. echo "<pre>";
  90. var_dump($task);
  91. }
  92. }