input('id/d',0), 'name' => input('name','','trim'), 'enable' => input('enable/d',0) ]; $result = validate('AppIconCate')->check($data,[],''); if(true !== $result){ HelpHander::error(validate('AppIconCate')->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('操作失败'); } 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(){ $lists = $this ->where('del',0) ->order('id asc') ->select(); return $lists?$lists->toArray():[]; } public function listDetail(){ $lists = $this ->where('del',0) ->order('id asc') ->select(); $lists = $lists ? $lists->toArray() : []; $lists[] = [ 'id' => 0, 'name' => '其他', 'createTime' => '', 'enable' => 1 ]; foreach ($lists as $k=>$v){ $apps = Db::name('app_icon') ->where('del',0) ->where('cate_id',$v['id']) ->order('id asc') ->select(); $lists[$k]['appIconList'] = $apps?$apps:[]; } return $lists; } public function del($id){ $ret = $this->where('id',$id)->setField('del',1); if(!$ret){ Db::name('app_icon')->where('cate_id',$id)->setField('cate_id',0); // 下属模块移到其他模块 HelpHander::error('删除失败'); } return true; } public function changeStatus($id,$enable){ $ret = $this->where('id',$id)->setField('enable',$enable); if(!$ret){ HelpHander::error('操作失败'); } return true; } }