|
@@ -53,6 +53,7 @@ public function plist(){
|
|
|
$list = Db::name('cat')->where($where)->page($page, $size)->select();
|
|
|
return app_show(0, "获取成功", ['list' => $list, 'count' => $count]);
|
|
|
}
|
|
|
+
|
|
|
public function title(){
|
|
|
$where =[["is_del","=",0]];
|
|
|
$cat_name=isset($this->post['cat_name']) && $this->post['cat_name'] !==""? trim($this->post['cat_name']) :"";
|
|
@@ -70,16 +71,43 @@ public function title(){
|
|
|
$list = Db::name('cat')->where($where)->select();
|
|
|
return app_show(0, "获取成功",$list);
|
|
|
}
|
|
|
+ public function tlist(){
|
|
|
+ $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";
|
|
|
+ $where =[['is_del',"=",0]];
|
|
|
+ $cat_name=isset($this->post['cat_name']) && $this->post['cat_name'] !==""? trim($this->post['cat_name']) :"";
|
|
|
+ if($cat_name!==""){
|
|
|
+ $where[]=['cat_name',"like","%$cat_name%"];
|
|
|
+ }
|
|
|
+ $status=isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']) :"";
|
|
|
+ if($status!==""){
|
|
|
+ $where[]=['status',"=",$status];
|
|
|
+ }
|
|
|
+ $creater=isset($this->post['creater']) && $this->post['creater'] !==""? trim($this->post['creater']) :"";
|
|
|
+ if($creater!==""){
|
|
|
+ $where[]=['creater',"like","%$creater%"];
|
|
|
+ }
|
|
|
+
|
|
|
+ $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
|
|
|
+ if($start!==""){
|
|
|
+ $where[]=['addtime',">=",$start];
|
|
|
+ }
|
|
|
+ $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
|
|
|
+ if($end !==""){
|
|
|
+ $where[]=['addtime',"<=",$end];
|
|
|
+ }
|
|
|
+ $count = Db::name('cat')->where($where)->count();
|
|
|
+ $total = ceil($count / $size);
|
|
|
+ $page = $page >= $total ? $total : $page;
|
|
|
+ $list = Db::name('cat')->where($where)->page($page, $size)->select();
|
|
|
+ return app_show(0, "获取成功", ['list' => $list, 'count' => $count]);
|
|
|
+ }
|
|
|
public function create()
|
|
|
{
|
|
|
$cat_name = isset($this->post['cat_name']) && $this->post['cat_name'] !== "" ? trim($this->post['cat_name']) : "";
|
|
|
if ($cat_name == "") {
|
|
|
return error_show(1002, "参数cat_name不能为空");
|
|
|
}
|
|
|
- $repeat_name = Db::name("cat")->where(["is_del"=>0,"cat_name"=>$cat_name])->find();
|
|
|
- if(!empty($repeat_name)){
|
|
|
- return error_show(1004,"分类名称已存在");
|
|
|
- }
|
|
|
$pid = isset($this->post['pid']) && $this->post['pid'] !== "" ? intval($this->post['pid']) : "";
|
|
|
if ($pid === "") {
|
|
|
return error_show(1002, "参数pid不能为空");
|
|
@@ -94,7 +122,10 @@ public function create()
|
|
|
}
|
|
|
$level =$levl['level']+1;
|
|
|
}
|
|
|
-
|
|
|
+ $repeat_name = Db::name("cat")->where(["is_del"=>0,"cat_name"=>$cat_name])->find();
|
|
|
+ if(!empty($repeat_name)){
|
|
|
+ return error_show(1004,"分类名称已在第{$level}组织存在");
|
|
|
+ }
|
|
|
$specs_id = isset($this->post['specs_id']) && $this->post['specs_id'] !== "" ? $this->post['specs_id'] : [];
|
|
|
if (empty($specs_id)) {
|
|
|
return error_show(1002, "参数specs_id不能为空");
|
|
@@ -123,9 +154,11 @@ public function create()
|
|
|
"status" => $status,
|
|
|
"cat_desc"=>$cat_desc,
|
|
|
"fund_code"=>$fund_code,
|
|
|
+ "creater"=>$creater,
|
|
|
+ "createrid"=>$createrid,
|
|
|
"is_del"=>0,
|
|
|
"addtime" => date("Y-m-d H:i:s"),
|
|
|
- "updatetime" => date("Y-m-d H:i:s")
|
|
|
+ "updatetime" => date("Y-m-d H:i:s"),
|
|
|
];
|
|
|
$datainfo = Db::name('cat')->insert($data,true);
|
|
|
$vat =[];
|