|
@@ -42,6 +42,10 @@ class Exclusive extends Base
|
|
|
if($name==""){
|
|
|
return error_show(1004,"参数name不能为空");
|
|
|
}
|
|
|
+ $rename = Db::name('exclusive')->where(['is_del' => 0, 'name' => $name])->find();
|
|
|
+ if (!empty($rename)) {
|
|
|
+ return error_show(1002, "专属类型名称已存在");
|
|
|
+ }
|
|
|
$pid =isset($this->post['pid'])&&$this->post['pid']!=="" ? intval($this->post['pid']):0;
|
|
|
$level=1;
|
|
|
$search = $name;
|
|
@@ -137,47 +141,47 @@ class Exclusive extends Base
|
|
|
return app_show(0,"获取成功",$vmp);
|
|
|
}
|
|
|
|
|
|
-// public function edit(){
|
|
|
-// $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']):"";
|
|
|
-// if($id==""){
|
|
|
-// return error_show(1004,"参数id不能为空");
|
|
|
-// }
|
|
|
-// $info = Db::name('exclusive')->where(['id'=>$id,'is_del'=>0])->find();
|
|
|
-// if($info==""){
|
|
|
-// return error_show(1002,"未找到数据");
|
|
|
-// }
|
|
|
-// $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,"编辑失败");
|
|
|
-// }
|
|
|
-// }
|
|
|
+ public function edit(){
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']):"";
|
|
|
+ if($id==""){
|
|
|
+ return error_show(1004,"参数id不能为空");
|
|
|
+ }
|
|
|
+ $info = Db::name('exclusive')->where(['id'=>$id,'is_del'=>0])->find();
|
|
|
+ if($info==""){
|
|
|
+ return error_show(1002,"未找到数据");
|
|
|
+ }
|
|
|
+ $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,"编辑失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
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();
|