123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace app\common\model;
- use think\Db;
- use tools\Phptree;
- class Monitor extends Base
- {
- public $table = 'monitor';
- public function updates(){
- $data = request()->post();
- $data['org_id'] = cur_org_id();
- $result = validate('Monitor')->check($data,[],'');
- if(true !== $result){
- $this->error = validate('Monitor')->getError();
- return false;
- }
- $id = $data['id'];
- unset($data['id']);
- if($id > 0){
- $data['update_time'] = date('Y-m-d H:i:s');
- $ret = $this->allowField(true)->save($data,['id'=>$id]);
- }else{
- $data['create_time'] = date('Y-m-d H:i:s');
- $ret = $this->allowField(true)->save($data);
- }
- if(!$ret){
- $this->error = '操作失败';
- return false;
- }
- return true;
- }
- // 获取组织的监控设备及播放地址
- public function getMonitors($orgId,$limit=10){
- $map[] = ['org_id','=',$orgId];
- $map[] = ['del','=',0];
- $map[] = ['enable','=',1];
- $lists = Db::name("monitor")->where($map)->field('id,title,url,img')->limit($limit)->order('id desc')->select();
- foreach ($lists as $k=>$v){
- $lists[$k]['url'] = url("h5/Index/monitor",['id'=>think_encrypt($v['id'])],false,true);
- }
- return $lists;
- }
- }
|