GameMainLogic.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | saiadmin [ saiadmin快速开发框架 ]
  4. // +----------------------------------------------------------------------
  5. // | Author: your name
  6. // +----------------------------------------------------------------------
  7. namespace app\v1\logic\center;
  8. use plugin\saiadmin\basic\BaseLogic;
  9. use plugin\saiadmin\exception\ApiException;
  10. use app\v1\model\center\GameMain;
  11. use plugin\saiadmin\app\model\system\SystemUser;
  12. /**
  13. * 主包管理逻辑层
  14. */
  15. class GameMainLogic extends BaseLogic
  16. {
  17. /**
  18. * 构造函数
  19. */
  20. public function __construct()
  21. {
  22. $this->model = new GameMain();
  23. }
  24. /**
  25. * 获取主游戏options列表
  26. * @param int $userId
  27. * @return array
  28. */
  29. public function getMainGameOptions()
  30. {
  31. $list = $this->model->field('id,name')->where('status', 1)->order('sort', 'desc')->select()->toArray();
  32. $list = array_map(function ($item) {
  33. return [
  34. 'label' => $item['name'],
  35. 'value' => $item['id']
  36. ];
  37. }, $list);
  38. return $list;
  39. }
  40. /**
  41. * 根据主包ID获取主包名称
  42. * @param int $mainId
  43. * @return string
  44. */
  45. public function getMainGameNameById($mainId)
  46. {
  47. return $this->model->where('id', $mainId)->value('name');
  48. }
  49. /**
  50. * 获取主包map
  51. * @return array
  52. */
  53. public function getMainGameMap()
  54. {
  55. return $this->model->column('name', 'id');
  56. }
  57. }