getPage(); $where = $this->request->params(['classify']); $query=Db::name('share_posters') -> alias("sp") -> join("share_posters_classify spc","sp.classify = spc.id","left") -> where('sp.mer_id',0) -> when(!empty($where['classify']),function ($query) use ($where){ $query -> where("sp.classify",$where['classify']); })->field("sp.sort,sp.name,spc.name as classify_name,sp.time,sp.type,sp.status,sp.id"); $count = $query -> count(); $list = $query ->order("sp.sort desc,sp.id desc")->page($page,$limit)->select()->toArray(); return app('json')->success(compact("list","count")); } public function classify_list(){ $list = Db::name("share_posters_classify") ->where('mer_id',0)->where('is_del',0)->order("sort desc,id asc")-> select() -> toArray(); return app("json") -> success($list); } public function classify_del(){ $id=$this->request->params(['id']); Db::name('share_posters_classify')->where('mer_id',0)->where('id',$id['id'])->update(['is_del'=>1]); return app("json") -> success('删除成功'); } public function del(){ $id=$this->request->params(['id']); Db::name('share_posters')->where('id',$id['id'])->delete(); return app("json") -> success('删除成功'); } public function get_one(){ $id=$this->request->params(['id']); if(empty($id['id'])){ return app('json')->fail('id不存在'); } $data=Db::name('share_posters')->where('id',$id['id'])->find(); return app("json") -> success($data); } public function save_share(){ $data = $this -> request -> params([ 'name', 'image', 'classify', 'qr_coordinate', 'head_coordinate', 'nickname_coordinate', 'head_size', 'qr_size', 'nickname_size', 'image_fake', 'type', 'status', 'sort', 'id' ]); $id = $data['id'] ?? 0; unset($data['id']); if ($id == 0){ //新增 $res = Db::name("share_posters") -> insert($data); }else{ // $res = Db::name("share_posters") -> where("id",$id) -> update($data); return app("json") -> success("成功"); } if ($res)return app("json") -> success("成功"); return app("json") -> fail('出错'); } public function save_share_classify(){ $data = $this -> request -> params([ 'name', 'sort', "id" ]); $id = $data['id'] ?? 0; unset($data['id']); if ($id == 0 ){ $res = Db::name("share_posters_classify") -> insert($data); }else{ $res = Db::name("share_posters_classify") -> where("id",$id) -> update($data); return app("json") -> success("成功"); } if ($res)return app("json") -> success("成功"); return app("json") -> fail('出错'); } }