input('id/d',0), 'title' => input('title','','trim'), 'sn' => input('sn','','trim'), 'content' => input('content','','trim'), 'enable' => input('enable/d',1), 'org_id' => input('orgId/d',0), 'company_id' => input('companyId/d',0) ]; $logdata = json_encode($data); $result = validate('Program')->check($data,[],''); if(true !== $result){ HelpHander::error(validate('Program')->getError()); } $id = $data['id']; unset($data['id']); if($id > 0){ $ret = $this->allowField(true)->save($data,['id'=>$id]); }else{ $ret = $this->allowField(true)->save($data); } if(!$ret){ HelpHander::error('操作失败'); } if($id > 0){ $content = '修改项目'; }else{ $content = '添加项目'; } model('ActionLog')->add(3,$content,0,$logdata); return true; } public function info($id){ $info = $this->where('id',$id)->where('del',0)->find(); if(!$info){ HelpHander::error('数据不存在'); } return $info->toArray(); } public function lists($page,$size,$title,$companyId,$orgId){ $map[] = ['del','=',0]; $map[] = ['org_id','=',$orgId]; $map[] = ['company_id','=',$companyId]; if($title != ''){ $map[] = ['title','like','%'.$title.'%']; } $lists = $this ->where($map) ->page($page,$size) ->order('id desc') ->select(); $total = $this->where($map)->count(); $data = [ 'total' => $total, 'list' => $lists?$lists->toArray():[] ]; return $data; } public function allLists($orgId){ $map[] = ['org_id','=',$orgId]; $map[] = ['del','=',0]; $map[] = ['enable','=',1]; $lists = $this ->where($map) ->field('id,title,company_id') ->order('id desc') ->select(); return $lists?$lists->toArray():[]; } public function del($id){ $ret = $this->where('id',$id)->setField('del',1); if(!$ret){ HelpHander::error('删除失败'); } $logdata = json_encode(['id' => $id]); model('ActionLog')->add(3,'删除项目',0,$logdata); return true; } }