TrainingController.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <?php
  2. namespace app\workerapi\controller;
  3. use app\adminapi\logic\goods_category\GoodsCategoryLogic;
  4. use app\common\logic\MasterWorkerExamineLogic;
  5. use app\common\model\dict\DictData;
  6. use app\workerapi\lists\MasterWorkerLists;
  7. use app\workerapi\lists\ServiceWorkLists;
  8. use app\workerapi\lists\TeamServiceWorkLists;
  9. use app\workerapi\lists\TrainingCourseLists;
  10. use app\workerapi\logic\LoginLogic;
  11. use app\workerapi\logic\MasterWorkerInfoLogic;
  12. use app\workerapi\logic\MasterWorkerLogic;
  13. use app\workerapi\logic\MasterWorkerTeamLogic;
  14. use app\workerapi\logic\TenantAgreeLogic;
  15. use app\workerapi\logic\TrainingLogic;
  16. use app\workerapi\validate\BankAccountValidate;
  17. use app\workerapi\validate\MasterWokerInfoValidate;
  18. use app\workerapi\validate\MasterWokerTeamValidate;
  19. use app\workerapi\validate\MasterWokerValidate;
  20. use app\workerapi\validate\MasterWorkerAgreeValidate;
  21. class TrainingController extends BaseApiController
  22. {
  23. /**
  24. * 获取培训信息
  25. * @return \think\response\Json
  26. */
  27. public function getTrainingInfo()
  28. {
  29. $result = TrainingLogic::getDetail($this->userId);
  30. return $this->data($result);
  31. }
  32. /**
  33. * 获取免费的课程列表
  34. * @return \think\response\Json
  35. */
  36. public function getFreeCourseList()
  37. {
  38. return $this->dataLists(new TrainingCourseLists());
  39. }
  40. /**
  41. * 获取工程师的课程列表
  42. * @return \think\response\Json
  43. */
  44. public function getCourseList()
  45. {
  46. $params = request()->get();
  47. return $this->data(TrainingLogic::getCourseList($this->userId,$params));
  48. }
  49. /**
  50. * 获取工程师的课程详情
  51. * @return \think\response\Json
  52. */
  53. public function getCourseDetail()
  54. {
  55. $params = request()->get();
  56. return $this->data(TrainingLogic::getCourseDetail($this->userId,$params));
  57. }
  58. /**
  59. * 修改学习视频记录状态
  60. * @return \think\response\Json
  61. */
  62. public function upWorkerVideoCourse()
  63. {
  64. $params = request()->post();
  65. $result = TrainingLogic::upWorkerCourse($params);
  66. if($result === false){
  67. return $this->fail(TrainingLogic::getError());
  68. }
  69. return $this->success('', [], 1, 1);
  70. }
  71. /**
  72. * 获取考试列表(即开始考试)
  73. * @return \think\response\Json
  74. */
  75. public function getQuestionList()
  76. {
  77. try {
  78. $params = request()->get();
  79. $result = TrainingLogic::getQuestionList($params);
  80. return $this->data($result);
  81. } catch (\Exception $e) {
  82. return $this->fail($e->getMessage());
  83. }
  84. }
  85. /**
  86. * 提交考试(即结束考试)
  87. * @return \think\response\Json
  88. */
  89. public function submitExam()
  90. {
  91. $params = request()->post();
  92. $result = TrainingLogic::submitExam($params);
  93. if($result === false){
  94. return $this->fail(TrainingLogic::getError());
  95. }
  96. return $this->success('', [], 1, 1);
  97. }
  98. /**
  99. * 考试结果统计
  100. * @return \think\response\Json
  101. */
  102. public function examStatistics()
  103. {
  104. $params = request()->get();
  105. $result = TrainingLogic::examStatistics($params);
  106. return $this->data($result);
  107. }
  108. /**
  109. * 获取团队协议详情
  110. * @return \think\response\Json
  111. */
  112. public function agreement_detail()
  113. {
  114. $result = TenantAgreeLogic::getAgreeByType('tenant_cooperate',$this->userId);
  115. return $this->data($result);
  116. }
  117. /**
  118. * 签署团队协议
  119. * @return \think\response\Json
  120. */
  121. public function agreeSign()
  122. {
  123. $params = (new MasterWorkerAgreeValidate())->post()->goCheck('sign', [
  124. 'user_id' => $this->userId,
  125. 'user_info' => $this->userInfo
  126. ]);
  127. $result = TenantAgreeLogic::sign($params);
  128. if (false === $result) {
  129. return $this->fail(TenantAgreeLogic::getError());
  130. }
  131. return $this->success('签名成功', [], 1, 1);
  132. }
  133. /**
  134. * 获取所有分类
  135. * @return \think\response\Json
  136. */
  137. public function getCategory()
  138. {
  139. $result = GoodsCategoryLogic::getTreeData();
  140. return $this->data($result);
  141. }
  142. /**
  143. * 提交三级ID分类
  144. * @return \think\response\Json
  145. */
  146. public function submitCategory()
  147. {
  148. $params = request()->post();
  149. $params['user_id'] = $this->userId;
  150. $params['user_info'] = $this->userInfo;
  151. $result = TrainingLogic::submitCategory($params);
  152. if($result === false){
  153. return $this->fail(TrainingLogic::getError());
  154. }
  155. return $this->success('', [], 1, 1);
  156. }
  157. /**
  158. * 获取类目分类
  159. * @return \think\response\Json
  160. */
  161. public function getTrainingCategory()
  162. {
  163. $params = request()->get();
  164. $params['user_id'] = $this->userId;
  165. $params['user_info'] = $this->userInfo;
  166. $result = TrainingLogic::getTrainingCategory($params);
  167. return $this->data($result);
  168. }
  169. /**
  170. * 获取某类目课程列表任务ID
  171. * @return \think\response\Json
  172. */
  173. public function getCategoryTaskId()
  174. {
  175. $params = request()->get();
  176. $params['user_id'] = $this->userId;
  177. $params['user_info'] = $this->userInfo;
  178. $result = TrainingLogic::getCategoryCourse($params);
  179. if($result === false){
  180. return $this->fail(TrainingLogic::getError());
  181. }
  182. return $this->success('', ['training_task_id'=>$result], 1, 1);
  183. }
  184. }