Robot.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace app\index\controller;
  3. /**
  4. * 智能问答类
  5. */
  6. class Robot extends Common
  7. {
  8. /**
  9. * 热点智能问答筛选
  10. *
  11. * @access public
  12. * @return array JsonString
  13. */
  14. public function index()
  15. {
  16. $code = -2;
  17. $msg = '错误';
  18. try {
  19. // 获取查询条件.
  20. $groupsId = input('get.groups_id');
  21. $robotgroups_id = input('get.robotgroups_id');
  22. if ($groupsId) {
  23. $robotWhere['groups_id'] = $groupsId;
  24. }
  25. if ($robotgroups_id) {
  26. $robotWhere['robotgroups_id'] = $robotgroups_id;
  27. }
  28. $robotWhere['robot_status'] = 1;
  29. $robotWhere['robot_host'] = 1;
  30. // 获取符合条件数据.
  31. $robot = model('Robot')->select($robotWhere);
  32. return json(['code' => 200, 'data' => $robot, 'msg' => '成功']);
  33. } catch (\Exception $e) {
  34. return json(['code' => $code, 'data' => [], 'msg' => $msg]);
  35. }//end try
  36. }//end index()
  37. /**
  38. * 智能问答分组
  39. *
  40. * @access public
  41. * @return array JsonString
  42. */
  43. public function getRobotGroups()
  44. {
  45. $code = -2;
  46. $msg = '错误';
  47. try {
  48. $robotGroupsWhere['robotgroups_status'] = 1;
  49. // 获取符合条件数据.
  50. $robotGroups = model('Robotgroups')->select($robotGroupsWhere);
  51. return json(['code' => 200, 'data' => $robotGroups, 'msg' => '成功']);
  52. } catch (\Exception $e) {
  53. return json(['code' => $code, 'data' => [], 'msg' => $msg]);
  54. }
  55. }//end getRobotGroups()
  56. }