Monitor.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. use tools\Phptree;
  5. class Monitor extends Base
  6. {
  7. public $table = 'monitor';
  8. public function updates(){
  9. $data = request()->post();
  10. $data['org_id'] = cur_org_id();
  11. $result = validate('Monitor')->check($data,[],'');
  12. if(true !== $result){
  13. $this->error = validate('Monitor')->getError();
  14. return false;
  15. }
  16. $id = $data['id'];
  17. unset($data['id']);
  18. if($id > 0){
  19. $data['update_time'] = date('Y-m-d H:i:s');
  20. $ret = $this->allowField(true)->save($data,['id'=>$id]);
  21. }else{
  22. $data['create_time'] = date('Y-m-d H:i:s');
  23. $ret = $this->allowField(true)->save($data);
  24. }
  25. if(!$ret){
  26. $this->error = '操作失败';
  27. return false;
  28. }
  29. return true;
  30. }
  31. // 获取组织的监控设备及播放地址
  32. public function getMonitors($orgId,$limit=10){
  33. $map[] = ['org_id','=',$orgId];
  34. $map[] = ['del','=',0];
  35. $map[] = ['enable','=',1];
  36. $lists = Db::name("monitor")->where($map)->field('id,title,url,img')->limit($limit)->order('id desc')->select();
  37. foreach ($lists as $k=>$v){
  38. $lists[$k]['url'] = url("h5/Index/monitor",['id'=>think_encrypt($v['id'])],false,true);
  39. }
  40. return $lists;
  41. }
  42. }