CommonController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. namespace app\v1\controller;
  3. use app\v1\logic\advert\AgentListLogic;
  4. use app\v1\logic\advert\MediaListLogic;
  5. use app\v1\logic\center\GameLogic;
  6. use plugin\saiadmin\basic\BaseController;
  7. use app\v1\logic\center\GameMainLogic;
  8. use plugin\saiadmin\app\logic\system\SystemUserLogic;
  9. use support\Request;
  10. use support\Response;
  11. /**
  12. * 公共接口管理控制器
  13. */
  14. class CommonController extends BaseController
  15. {
  16. protected $gameMainLogic;
  17. protected $gameLogic;
  18. protected $mediaListLogic;
  19. protected $agentListLogic;
  20. protected $systemUserLogic;
  21. /**
  22. * 构造函数
  23. */
  24. public function __construct()
  25. {
  26. parent::__construct();
  27. $this->gameMainLogic = new GameMainLogic();
  28. $this->gameLogic = new GameLogic();
  29. $this->mediaListLogic = new MediaListLogic();
  30. $this->agentListLogic = new AgentListLogic();
  31. $this->systemUserLogic = new SystemUserLogic();
  32. }
  33. /**
  34. * 获取主游戏options列表
  35. * @return Response
  36. */
  37. public function getMainGameOptions(Request $request): Response
  38. {
  39. $data = $this->gameMainLogic->getMainGameOptions();
  40. return $this->success($data);
  41. }
  42. /**
  43. * 获取子游戏options列表
  44. * @return Response
  45. */
  46. public function getGameOptions(Request $request): Response
  47. {
  48. $where = $request->get();
  49. $data = $this->gameLogic->getGameOptions($where);
  50. return $this->success($data);
  51. }
  52. /**
  53. * 获取树形游戏options列表
  54. * @return Response
  55. */
  56. public function getTreeGameOptions(Request $request): Response
  57. {
  58. $where = $request->get();
  59. $data = $this->gameLogic->getGameListByPermission($where);
  60. return $this->success($data);
  61. }
  62. /**
  63. * 查询媒体列表Options
  64. */
  65. public function getMediaOptions(Request $request): Response
  66. {
  67. $data = $this->mediaListLogic->getMediaOptions();
  68. $data = $data->toArray();
  69. $data = array_map(function ($item) {
  70. return [
  71. 'label' => $item['name'].'【' . $item['id'] . '】',
  72. 'value' => $item['id'],
  73. ];
  74. }, $data);
  75. return $this->success($data);
  76. }
  77. /**
  78. * 查询渠道列表Options
  79. */
  80. public function getAgentOptions(Request $request): Response
  81. {
  82. $data = $this->agentListLogic->getAgentOptions();
  83. return $this->success($data);
  84. }
  85. /**
  86. * 后台归属人列表Options
  87. */
  88. public function getAuthOptions(Request $request): Response
  89. {
  90. $data = $this->systemUserLogic->field('id as value, username as label')->select()->toArray();
  91. return $this->success($data);
  92. }
  93. }