input('id/d',0), 'title' => input('title','','trim'), 'remark' => input('remark','','trim'), 'org_id' => input('orgId/d',0), 'user_id' => input('uid/d',0), 'end_time' => input('endTime','','trim'), 'status' => input('status/d',1) ]; $logdata = json_encode($data); $result = validate('Certificate')->check($data,[],''); if(true !== $result){ HelpHander::error(validate('Certificate')->getError()); } $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){ HelpHander::error('操作失败'); } if($id > 0){ $content = '修改证件'; }else{ $content = '添加证件'; } model('ActionLog')->add(8,$content,0,$logdata); return true; } public function info($id){ $info = $this->where('id',$id)->find(); if(!$info){ HelpHander::error('数据不存在'); } return $info->toArray(); } public function lists($page,$size,$title,$userName){ $map[] = ['c.del','=',0]; if($title){ $map[] = ['c.title','like','%'.$title.'%']; } if($userName){ $map[] = ['ui.name','like','%'.$userName.'%']; } $lists = Db::name('certificate') ->alias('c') ->join('user_info ui','ui.user_id = c.user_id') ->field('c.*,ui.name as userName') ->where($map) ->page($page,$size) ->order('c.id desc') ->select(); $total = Db::name('certificate') ->alias('c') ->join('user_info ui','ui.user_id = c.user_id') ->where($map)->count(); $data = [ 'total' => $total, 'list' => $lists?$lists:[] ]; return $data; } public function del($id){ $ret = $this->where('id',$id)->setField('del',1); if(!$ret){ HelpHander::error('删除失败'); } $logdata = json_encode(['id' => $id]); model('ActionLog')->add(8,'删除证件',0,$logdata); return true; } }