QuestionTemplateController.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace app\modules\client\controllers\v1;
  3. use app\modules\client\controllers\BaseController;
  4. use app\modules\client\models\v1\QAndAForm;
  5. use app\modules\client\models\v1\QuestionTemplateListForm;
  6. class QuestionTemplateController extends BaseController
  7. {
  8. public function behaviors()
  9. {
  10. return parent::behaviors();
  11. }
  12. public function actionIndex()
  13. {
  14. $form = new QuestionTemplateListForm();
  15. $form->attributes = post_params();
  16. $form->user = get_user();
  17. return $this->asJson($form->index());
  18. }
  19. /**
  20. * 列表
  21. */
  22. public function actionList()
  23. {
  24. $form = new QuestionTemplateListForm();
  25. $form->attributes = get_params();
  26. return $this->asJson($form->list());
  27. }
  28. /**
  29. * 获取热门问答
  30. */
  31. public function actionHotList()
  32. {
  33. $form = new QuestionTemplateListForm();
  34. $form->attributes = get_params();
  35. return $this->asJson($form->hot_list());
  36. }
  37. /**
  38. * 获取模版页列表
  39. */
  40. public function actionTemplateList($id = null)
  41. {
  42. $form = new QuestionTemplateListForm();
  43. $form->attributes = get_params();
  44. return $this->asJson($form->template_list());
  45. }
  46. /**
  47. * 提问
  48. */
  49. public function actionQuestion()
  50. {
  51. $form = new QAndAForm();
  52. $form->attributes = post_params();
  53. $form->user = get_user();
  54. return $this->asJson($form->save());
  55. }
  56. public function actionQuestionList()
  57. {
  58. $form = new QuestionTemplateListForm();
  59. $form->attributes = get_params();
  60. $form->user = get_user();
  61. return $this->asJson($form->question_list());
  62. }
  63. public function actionDelQuestion()
  64. {
  65. $form = new QuestionTemplateListForm();
  66. $id = post_params('id');
  67. return $this->asJson($form->del_question($id));
  68. }
  69. public function actionAddIntegral()
  70. {
  71. $form = new QuestionTemplateListForm();
  72. return $this->asJson($form->add_integral());
  73. }
  74. }