Actor.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Db;
  4. use app\common\util\Pinyin;
  5. class Actor extends Base
  6. {
  7. public function __construct()
  8. {
  9. parent::__construct();
  10. }
  11. public function data()
  12. {
  13. $param = input();
  14. $param['page'] = intval($param['page']) < 1 ? 1 : $param['page'];
  15. $param['limit'] = intval($param['limit']) < 1 ? $this->_pagesize : $param['limit'];
  16. $where = [];
  17. if (!empty($param['type'])) {
  18. $where['type_id|type_id_1'] = ['eq', $param['type']];
  19. }
  20. if (!empty($param['level'])) {
  21. $where['actor_level'] = ['eq', $param['level']];
  22. }
  23. if (in_array($param['status'], ['0', '1'])) {
  24. $where['actor_status'] = ['eq', $param['status']];
  25. }
  26. if(!empty($param['pic'])){
  27. if($param['pic'] == '1'){
  28. $where['actor_pic'] = ['eq',''];
  29. }
  30. elseif($param['pic'] == '2'){
  31. $where['actor_pic'] = ['like','http%'];
  32. }
  33. elseif($param['pic'] == '3'){
  34. $where['actor_pic'] = ['like','%#err%'];
  35. }
  36. }
  37. if(!empty($param['wd'])){
  38. $param['wd'] = htmlspecialchars(urldecode($param['wd']));
  39. $where['actor_name'] = ['like','%'.$param['wd'].'%'];
  40. }
  41. $order='actor_time desc';
  42. $res = model('Actor')->listData($where,$order,$param['page'],$param['limit']);
  43. $this->assign('list', $res['list']);
  44. $this->assign('total', $res['total']);
  45. $this->assign('page', $res['page']);
  46. $this->assign('limit', $res['limit']);
  47. $param['page'] = '{page}';
  48. $param['limit'] = '{limit}';
  49. $this->assign('param', $param);
  50. $type_tree = model('Type')->getCache('type_tree');
  51. $this->assign('type_tree', $type_tree);
  52. $this->assign('title', lang('admin/actor/title'));
  53. return $this->fetch('admin@actor/index');
  54. }
  55. public function info()
  56. {
  57. if (Request()->isPost()) {
  58. $param = input('post.');
  59. $res = model('Actor')->saveData($param);
  60. if($res['code']>1){
  61. return $this->error($res['msg']);
  62. }
  63. return $this->success($res['msg']);
  64. }
  65. $id = input('id');
  66. $where=[];
  67. $where['actor_id'] = ['eq',$id];
  68. $res = model('Actor')->infoData($where);
  69. $info = $res['info'];
  70. $this->assign('info',$info);
  71. $type_tree = model('Type')->getCache('type_tree');
  72. $this->assign('type_tree', $type_tree);
  73. $this->assign('title',lang('admin/actor/title'));
  74. return $this->fetch('admin@actor/info');
  75. }
  76. public function del()
  77. {
  78. $param = input();
  79. $ids = $param['ids'];
  80. if(!empty($ids)){
  81. $where=[];
  82. $where['actor_id'] = ['in',$ids];
  83. $res = model('Actor')->delData($where);
  84. if($res['code']>1){
  85. return $this->error($res['msg']);
  86. }
  87. return $this->success($res['msg']);
  88. }
  89. return $this->error(lang('param_err'));
  90. }
  91. public function field()
  92. {
  93. $param = input();
  94. $ids = $param['ids'];
  95. $col = $param['col'];
  96. $val = $param['val'];
  97. $start = $param['start'];
  98. $end = $param['end'];
  99. if(!empty($ids) && in_array($col,['actor_status','actor_lock','actor_level','type_id','actor_hits'])){
  100. $where=[];
  101. $update = [];
  102. $where['actor_id'] = ['in',$ids];
  103. if(empty($start)){
  104. $update[$col] = $val;
  105. if($col == 'type_id'){
  106. $type_list = model('Type')->getCache();
  107. $id1 = intval($type_list[$val]['type_pid']);
  108. $update['type_id_1'] = $id1;
  109. }
  110. $res = model('Actor')->fieldData($where, $update);
  111. }
  112. else{
  113. if(empty($end)){$end = 9999;}
  114. $ids = explode(',',$ids);
  115. foreach($ids as $k=>$v){
  116. $val = rand($start,$end);
  117. $where['actor_id'] = ['eq',$v];
  118. $update[$col] = $val;
  119. $res = model('Actor')->fieldData($where, $update);
  120. }
  121. }
  122. if($res['code']>1){
  123. return $this->error($res['msg']);
  124. }
  125. return $this->success($res['msg']);
  126. }
  127. return $this->error(lang('param_err'));
  128. }
  129. }