|
@@ -102,24 +102,87 @@ class Exclusive extends Base
|
|
|
}
|
|
|
|
|
|
public function query(){
|
|
|
- $where =[["is_del","=",0]];
|
|
|
- $cat_name=isset($this->post['name']) && $this->post['name'] !==""? trim($this->post['name']) :"";
|
|
|
- if($cat_name!==""){
|
|
|
- $where[]=['name',"like","%$cat_name%"];
|
|
|
+// $where =[["is_del","=",0]];
|
|
|
+// $cat_name=isset($this->post['name']) && $this->post['name'] !==""? trim($this->post['name']) :"";
|
|
|
+// if($cat_name!==""){
|
|
|
+// $where[]=['name',"like","%$cat_name%"];
|
|
|
+// }
|
|
|
+// $pid=isset($this->post['pid']) && $this->post['pid'] !==""? intval($this->post['pid']) :"";
|
|
|
+// if($pid!==""){
|
|
|
+// $where[]=['pid',"=",$pid];
|
|
|
+// }
|
|
|
+// $status=isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']) :"";
|
|
|
+// if($status!==""){
|
|
|
+// $where[]=['status',"=",$status];
|
|
|
+// }
|
|
|
+// $level=isset($this->post['level']) && $this->post['level'] !==""? intval($this->post['level']) :"";
|
|
|
+// if($level!==""){
|
|
|
+// $where[]=['level',"=",$level];
|
|
|
+// }
|
|
|
+// $list = Db::name("exclusive")->where($where)->select();
|
|
|
+// return app_show(0,"获取成功",$list);
|
|
|
+// $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
|
|
|
+// if($id==""){
|
|
|
+// return error_show(1002,"参数id不能为空");
|
|
|
+// }
|
|
|
+// $idinfo = Db::name('exclusive')->where(['id'=>$id])->find();
|
|
|
+// if($idinfo==""){
|
|
|
+// return error_show(1002,"未找到数据");
|
|
|
+// }
|
|
|
+// return app_show(0,"获取成功",$idinfo);
|
|
|
+ }
|
|
|
+ public function edit(){
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']):"";
|
|
|
+ if($id==""){
|
|
|
+ return error_show(1004,"参数id不能为空");
|
|
|
}
|
|
|
- $pid=isset($this->post['pid']) && $this->post['pid'] !==""? intval($this->post['pid']) :"";
|
|
|
- if($pid!==""){
|
|
|
- $where[]=['pid',"=",$pid];
|
|
|
+ $info = Db::name('exclusive')->where(['id'=>$id,'is_del'=>0])->find();
|
|
|
+ if($info==""){
|
|
|
+ return error_show(1002,"未找到数据");
|
|
|
}
|
|
|
- $status=isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']) :"";
|
|
|
- if($status!==""){
|
|
|
- $where[]=['status',"=",$status];
|
|
|
+ $name = isset($this->post['name'])&&$this->post['name']!=""? trim($this->post['name']):"";
|
|
|
+ if($name==""){
|
|
|
+ return error_show(1004,"参数name不能为空");
|
|
|
+ }
|
|
|
+ $pid =isset($this->post['pid'])&&$this->post['pid']!=="" ? intval($this->post['pid']):0;
|
|
|
+ $level=1;
|
|
|
+ $search = $name;
|
|
|
+ if($pid!==0){
|
|
|
+ $parent= Db::name("exclusive")->where(["id"=>$pid,"is_del"=>0])->find();
|
|
|
+ if($parent==false){
|
|
|
+ return error_show(1003,"父级数据未找到");
|
|
|
+ }
|
|
|
+ $search=$parent['search']."/".$name;
|
|
|
+ $level=$parent['level']+1;
|
|
|
+ }
|
|
|
+ $data=[
|
|
|
+ "id"=>$id,
|
|
|
+ "name"=>$name,
|
|
|
+ "pid"=>$pid,
|
|
|
+ "level"=>$level,
|
|
|
+ "search"=>$search,
|
|
|
+ "status"=>0,
|
|
|
+ "is_del"=>0,
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $in =Db::name("exclusive")->save($data);
|
|
|
+ if($in){
|
|
|
+ return app_show(0,"编辑成功");
|
|
|
+ }else{
|
|
|
+ return error_show(1003,"编辑失败");
|
|
|
}
|
|
|
- $level=isset($this->post['level']) && $this->post['level'] !==""? intval($this->post['level']) :"";
|
|
|
- if($level!==""){
|
|
|
- $where[]=['level',"=",$level];
|
|
|
+ }
|
|
|
+ public function delete(){
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']) :"";
|
|
|
+ $info = Db::name('exclusive')->where(["is_del"=>0,'id'=>$id])->find();
|
|
|
+ if($info==false){
|
|
|
+ return error_show(1002,"未找到数据");
|
|
|
+ }
|
|
|
+ $supp= Db::name('exclusive')->update(['id'=>$id,'is_del'=>1,"updatetime"=>date("Y-m-d H:i:s")]);
|
|
|
+ if($supp){
|
|
|
+ return error_show(0,"删除成功");
|
|
|
+ }else{
|
|
|
+ return error_show(1002,"删除失败");
|
|
|
}
|
|
|
- $list = Db::name("exclusive")->where($where)->select();
|
|
|
- return app_show(0,"获取成功",$list);
|
|
|
}
|
|
|
}
|