Region.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * 区服管理控制器
  4. */
  5. namespace app\admin\controller;
  6. use think\Db;
  7. class Region extends Admin
  8. {
  9. public function index()
  10. {
  11. $where = [];
  12. if (input('request.game_id') != '') {
  13. $where['gs.game_id'] = input('request.game_id', '', 'trim');
  14. }
  15. /* if (input('request.game_name') != '') {
  16. $where['gs.game_id'] = input('request.game_name', '', 'trim');
  17. }*/
  18. //游戏名称
  19. if (input('request.game_name') != '') {
  20. $where['g.name'] = ['like', '%' . input('request.game_name') . '%'];
  21. }
  22. if (input('request.serverid') != '') {
  23. $where['gs.serverid'] = input('request.serverid', '', 'trim');
  24. }
  25. if (input('request.servername') != '') {
  26. $where['gs.servername'] = input('request.servername', '', 'trim');
  27. }
  28. if (input('request.status') != '') {
  29. $where['gs.status'] = input('request.status', '', 'trim');
  30. }
  31. //查询参数
  32. $param = input('get.');
  33. $list = Db::name('nw_game_server gs')
  34. ->join('cy_game g', 'gs.game_id = g.id', 'left')
  35. ->field('gs.id,gs.servername,gs.serverid,gs.status,gs.create_time,g.name')
  36. ->where($where)
  37. ->order('id desc')
  38. ->paginate(20, false, array('query' => $param));
  39. $this->assign('list', $list);
  40. $gameList = $this->cyModel('game')->field('id,name')->select();
  41. $this->assign('gameList', $gameList);
  42. $this->assign('page', $list->render());
  43. return $this->fetch();
  44. }
  45. /**
  46. *是否显示
  47. */
  48. public function show()
  49. {
  50. $id = $this->request->param('id', '', 'intval');
  51. $status = $this->request->param('is_show', '', 'intval');
  52. $data['status'] = $status;
  53. if (empty($id)) {
  54. $this->error('参数错误!');
  55. }
  56. $result = $this->validate($data, [
  57. ['is_show', 'in:0,1', '状态参数错误'],
  58. ]);
  59. if (true !== $result) {
  60. $this->error($result);
  61. }
  62. $gameServerModel = model("GameServer");
  63. if (!$gameServerModel->find($id)) {
  64. $this->error('参数错误,不存在该数据');
  65. }
  66. if ($gameServerModel->update($data, ['id' => $id])) {
  67. $msg = $status ? '显示' : '隐藏';
  68. $this->insertLog($this->current_node, $msg . '游戏:' . get_game_name($id), 11);
  69. $this->success('修改成功');
  70. }
  71. $error = $gameServerModel->getError();
  72. $this->error($error ?: '修改失败');
  73. }
  74. }