post(); $data['org_id'] = cur_org_id(); $result = validate('GGoodsCate')->check($data,[],''); if(true !== $result){ $this->error = validate('GGoodsCate')->getError(); return false; } $id = $data['id']; unset($data['id']); if($id > 0){ $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 lists($orgId){ $ret=Db::name('g_goods_cate') ->field('id,title') ->where(['org_id'=>$orgId,'enable'=>1]) ->order(['sort'=>'asc','id'=>'desc']) ->select(); $data=[ [ 'id'=>0, 'title'=>'全部' ], ]; foreach ($ret as $k=>$v){ $data[] = $v; } return $data; } }