正在显示
4 个修改的文件
包含
44 行增加
和
1 行删除
| @@ -22,7 +22,7 @@ class UserController extends BaseController | @@ -22,7 +22,7 @@ class UserController extends BaseController | ||
| 22 | public function lists(UserModel $userModel){ | 22 | public function lists(UserModel $userModel){ |
| 23 | //TODO::搜索参数统一处理 | 23 | //TODO::搜索参数统一处理 |
| 24 | $this->map['project_id'] = $this->user['project_id']; | 24 | $this->map['project_id'] = $this->user['project_id']; |
| 25 | - $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at']); | 25 | + $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at','wechat','status']); |
| 26 | if(empty($lists)){ | 26 | if(empty($lists)){ |
| 27 | $this->response('error',Code::USER_ERROR,[]); | 27 | $this->response('error',Code::USER_ERROR,[]); |
| 28 | } | 28 | } |
| @@ -124,4 +124,23 @@ class BaseLogic extends Logic | @@ -124,4 +124,23 @@ class BaseLogic extends Logic | ||
| 124 | return $hash.$filename; | 124 | return $hash.$filename; |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | + /** | ||
| 128 | + * @name :自增或自减 | ||
| 129 | + * @return bool | ||
| 130 | + * @author :liyuhang | ||
| 131 | + * @method | ||
| 132 | + */ | ||
| 133 | + public function set_num($model,$data,$type = 'add',$num = 1){ | ||
| 134 | + if(is_array($data)){ | ||
| 135 | + foreach ($data as $v){ | ||
| 136 | + $this->set_num($model,$v,$type,$num); | ||
| 137 | + } | ||
| 138 | + } | ||
| 139 | + if($type == 'del'){ | ||
| 140 | + $model::where('id',$data)->decrement('num',$num); | ||
| 141 | + }else{ | ||
| 142 | + $model::where('id',$data)->increment('num',$num); | ||
| 143 | + } | ||
| 144 | + return true; | ||
| 145 | + } | ||
| 127 | } | 146 | } |
| @@ -75,6 +75,9 @@ class BlogLogic extends BaseLogic | @@ -75,6 +75,9 @@ class BlogLogic extends BaseLogic | ||
| 75 | $this->param['image'] = $data; | 75 | $this->param['image'] = $data; |
| 76 | } | 76 | } |
| 77 | $rs = $this->model->insertGetId($this->param); | 77 | $rs = $this->model->insertGetId($this->param); |
| 78 | + //分类计数 | ||
| 79 | + $category_data = explode(',',trim($this->param['category_id'],',')); | ||
| 80 | + $this->set_num(BlogCategoryModel::class,$category_data); | ||
| 78 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']); | 81 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']); |
| 79 | DB::commit(); | 82 | DB::commit(); |
| 80 | }catch (\Exception $e){ | 83 | }catch (\Exception $e){ |
| @@ -86,6 +89,21 @@ class BlogLogic extends BaseLogic | @@ -86,6 +89,21 @@ class BlogLogic extends BaseLogic | ||
| 86 | } | 89 | } |
| 87 | 90 | ||
| 88 | /** | 91 | /** |
| 92 | + * @param $category_id | ||
| 93 | + * @name :产品计数 | ||
| 94 | + * @return bool | ||
| 95 | + * @author :liyuhang | ||
| 96 | + * @method | ||
| 97 | + */ | ||
| 98 | + public function category_set_num($category_id){ | ||
| 99 | + $category_data = explode(',',trim($category_id,',')); | ||
| 100 | + foreach ($category_data as $v){ | ||
| 101 | + BlogCategoryModel::where('id',$v)->increment('num'); | ||
| 102 | + } | ||
| 103 | + return true; | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + /** | ||
| 89 | * @name : 编辑博客 | 107 | * @name : 编辑博客 |
| 90 | * @return void | 108 | * @return void |
| 91 | * @author :liyuhang | 109 | * @author :liyuhang |
| @@ -192,6 +210,7 @@ class BlogLogic extends BaseLogic | @@ -192,6 +210,7 @@ class BlogLogic extends BaseLogic | ||
| 192 | $ids = $this->param['id']; | 210 | $ids = $this->param['id']; |
| 193 | $this->param['id'] = ['in',$this->param['id']]; | 211 | $this->param['id'] = ['in',$this->param['id']]; |
| 194 | $this->del($this->param,$ids); | 212 | $this->del($this->param,$ids); |
| 213 | + $this->set_num(BlogCategoryModel::class,'id','del',count($ids)); | ||
| 195 | return $this->success(); | 214 | return $this->success(); |
| 196 | } | 215 | } |
| 197 | 216 |
| @@ -66,6 +66,9 @@ class NewsLogic extends BaseLogic | @@ -66,6 +66,9 @@ class NewsLogic extends BaseLogic | ||
| 66 | $this->param['image'] = $data; | 66 | $this->param['image'] = $data; |
| 67 | } | 67 | } |
| 68 | $rs = $this->model->insertGetId($this->param); | 68 | $rs = $this->model->insertGetId($this->param); |
| 69 | + //产品计数 | ||
| 70 | + $category_data = explode(',',trim($this->param['category_id'],',')); | ||
| 71 | + $this->_set_num(NewsCategoryModel::class,$category_data); | ||
| 69 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); | 72 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); |
| 70 | DB::commit(); | 73 | DB::commit(); |
| 71 | }catch (\Exception $e){ | 74 | }catch (\Exception $e){ |
| @@ -180,6 +183,8 @@ class NewsLogic extends BaseLogic | @@ -180,6 +183,8 @@ class NewsLogic extends BaseLogic | ||
| 180 | $ids = $this->param['id']; | 183 | $ids = $this->param['id']; |
| 181 | $this->param['id'] = ['in',$this->param['id']]; | 184 | $this->param['id'] = ['in',$this->param['id']]; |
| 182 | $this->del($this->param,$ids); | 185 | $this->del($this->param,$ids); |
| 186 | + //数量自减 | ||
| 187 | + $this->set_num(NewsCategoryModel::class,'id','del',count($ids)); | ||
| 183 | return $this->success(); | 188 | return $this->success(); |
| 184 | } | 189 | } |
| 185 | } | 190 | } |
-
请 注册 或 登录 后发表评论