|
@@ -12,7 +12,16 @@ public $post = "";
|
|
|
public function __construct(App $app){
|
|
|
parent::__construct($app);
|
|
|
$this->post = $this->request->post();
|
|
|
+ $token = isset($this->post['token']) ? trim($this->post['token']) : "";
|
|
|
+ if($token==""){
|
|
|
+ return error_show(101,'token不能为空');
|
|
|
+ }
|
|
|
+ $effetc = VerifyTokens($token);
|
|
|
+ if(!empty($effetc) && $effetc['code']!=0){
|
|
|
+ return error_show($effetc['code'],$effetc['message']);
|
|
|
+ }
|
|
|
}
|
|
|
+/*列表*/
|
|
|
public function list(){
|
|
|
$page = isset($this->post['page']) && $this->post['page'] != "" ? intval($this->post['page']) : 1;
|
|
|
$size = isset($this->post['size']) && $this->post['size'] != "" ? intval($this->post['size']) : 10;
|
|
@@ -55,6 +64,7 @@ public function list(){
|
|
|
$list = Db::name('supplier')->where($where)->page($page,$size)->select();
|
|
|
return app_show(0,"获取成功",["list"=>$list,'count'=>$count]);
|
|
|
}
|
|
|
+/*新建*/
|
|
|
public function create(){
|
|
|
$name = isset($this->post['name']) && $this->post['name'] !=="" ? trim($this->post['name']) :"";
|
|
|
if($name==""){
|
|
@@ -110,6 +120,7 @@ public function create(){
|
|
|
$join = Db::name('supplier')->insert($data);
|
|
|
return $join? error_show(0,"添加成功") :error_show(1002,"添加失败");
|
|
|
}
|
|
|
+/*编辑*/
|
|
|
public function edit(){
|
|
|
$id = isset($this->post['id']) && $this->post['id'] !==""? trim($this->post['id']):"";
|
|
|
$ion = Db::name('supplier')->where(['id'=>$id,'is_del'=>0])->find();
|
|
@@ -148,6 +159,7 @@ public function edit(){
|
|
|
if($legaler==""){
|
|
|
return error_show(1002,"法人不能为空");
|
|
|
}
|
|
|
+
|
|
|
$addr = isset($this->post['addr']) && $this->post['addr']!==""? trim($this->post['addr']) :"";
|
|
|
if($addr==""){
|
|
|
return error_show(1002,"地址不能为空");
|
|
@@ -163,6 +175,7 @@ public function edit(){
|
|
|
$ed = Db::name('supplier')->where(['is_del'=>0,'id'=>$id])->save($vmp);
|
|
|
return $ed ? error_show(0,"编辑成功") : error_show(1002,"编辑失败");
|
|
|
}
|
|
|
+/*查询*/
|
|
|
public function selec(){
|
|
|
$id= isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']) :"";
|
|
|
if($id==""){
|
|
@@ -171,5 +184,18 @@ public function selec(){
|
|
|
$se = Db::name('supplier')->where(['id'=>$id,'is_del'=>0])->find();
|
|
|
return app_show(0,"获取成功",$se);
|
|
|
}
|
|
|
-
|
|
|
+/*删除*/
|
|
|
+ public function del(){
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']) :"";
|
|
|
+ $sup = Db::name('supplier')->where(["is_del"=>0,'id'=>$id])->find();
|
|
|
+ if($sup==false){
|
|
|
+ return error_show(1002,"供应商信息不存在");
|
|
|
+ }
|
|
|
+ $supp= Db::name('supplier')->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,"供应商信息删除失败");
|
|
|
+ }
|
|
|
+}
|
|
|
}
|