正在显示
12 个修改的文件
包含
118 行增加
和
125 行删除
| @@ -440,27 +440,6 @@ if (!function_exists('getImageUrl')) { | @@ -440,27 +440,6 @@ if (!function_exists('getImageUrl')) { | ||
| 440 | } | 440 | } |
| 441 | } | 441 | } |
| 442 | 442 | ||
| 443 | -if (!function_exists('getImageUrl')) { | ||
| 444 | - /** | ||
| 445 | - * @name :(获取当前登录用户域名并通知更新)projectUrl | ||
| 446 | - * @author :lyh | ||
| 447 | - * @method :post | ||
| 448 | - * @time :2023/6/6 14:09 | ||
| 449 | - */ | ||
| 450 | - function updateNotify($domain,$data) | ||
| 451 | - { | ||
| 452 | - $param = [ | ||
| 453 | - 'project_id'=>$data['project_id'], | ||
| 454 | - 'type'=>$data['type'], | ||
| 455 | - 'route'=>$data['route'], | ||
| 456 | - 'created_at'=>date('Y-m-d H:i:s'), | ||
| 457 | - 'updated_at'=>date('Y-m-d H:i:s') | ||
| 458 | - ]; | ||
| 459 | - $id = (new UpdateNotify())->insertGetId($data); | ||
| 460 | - $urlStr = $domain.'api/updateHtmlNotify?id=' . $id; | ||
| 461 | - return http_get($urlStr); | ||
| 462 | - } | ||
| 463 | -} | ||
| 464 | /** | 443 | /** |
| 465 | * @remark :字符串截取 | 444 | * @remark :字符串截取 |
| 466 | * @name :characterTruncation | 445 | * @name :characterTruncation |
| @@ -7,6 +7,7 @@ use App\Models\Blog\BlogCategory; | @@ -7,6 +7,7 @@ use App\Models\Blog\BlogCategory; | ||
| 7 | use App\Models\News\NewsCategory; | 7 | use App\Models\News\NewsCategory; |
| 8 | use App\Models\Product\Category; | 8 | use App\Models\Product\Category; |
| 9 | use App\Models\Product\Product; | 9 | use App\Models\Product\Product; |
| 10 | +use App\Models\RouteMap; | ||
| 10 | use App\Models\Service\Service as ServiceSettingModel; | 11 | use App\Models\Service\Service as ServiceSettingModel; |
| 11 | use App\Models\Template\ModuleSetting; | 12 | use App\Models\Template\ModuleSetting; |
| 12 | use App\Models\Template\Template; | 13 | use App\Models\Template\Template; |
| @@ -186,10 +187,32 @@ class BTemplateLogic extends BaseLogic | @@ -186,10 +187,32 @@ class BTemplateLogic extends BaseLogic | ||
| 186 | if($rs === false){ | 187 | if($rs === false){ |
| 187 | $this->fail('error'); | 188 | $this->fail('error'); |
| 188 | } | 189 | } |
| 190 | + //通知更新 | ||
| 191 | + $this->homeOrProduct($this->param['source'],$this->param['source_id']); | ||
| 189 | return $this->success(); | 192 | return $this->success(); |
| 190 | } | 193 | } |
| 191 | 194 | ||
| 192 | /** | 195 | /** |
| 196 | + * @remark :通知首页更新 | ||
| 197 | + * @name :IsHome | ||
| 198 | + * @author :lyh | ||
| 199 | + * @method :post | ||
| 200 | + * @time :2023/7/31 16:05 | ||
| 201 | + */ | ||
| 202 | + public function homeOrProduct($source,$source_id = ''){ | ||
| 203 | + if($source == BTemplate::SOURCE_HOME){ | ||
| 204 | + $type = 'index'; | ||
| 205 | + $route = ''; | ||
| 206 | + }elseif($source == BTemplate::SOURCE_PRODUCT){ | ||
| 207 | + $type = RouteMap::SOURCE_PRODUCT; | ||
| 208 | + $productModel = new Product(); | ||
| 209 | + $info = $productModel->read(['id'=>$source_id]); | ||
| 210 | + $route = $info['route']; | ||
| 211 | + } | ||
| 212 | + return $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>$type, 'route'=>$route]); | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + /** | ||
| 193 | * @remark :处理保存模版数据 | 216 | * @remark :处理保存模版数据 |
| 194 | * @name :templateParam | 217 | * @name :templateParam |
| 195 | * @author :lyh | 218 | * @author :lyh |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Http\Logic\Bside\BTemplate; | 3 | namespace App\Http\Logic\Bside\BTemplate; |
| 4 | 4 | ||
| 5 | use App\Http\Logic\Bside\BaseLogic; | 5 | use App\Http\Logic\Bside\BaseLogic; |
| 6 | +use App\Models\RouteMap; | ||
| 6 | use App\Models\Service\Service as ServiceSettingModel; | 7 | use App\Models\Service\Service as ServiceSettingModel; |
| 7 | use App\Models\Template\BCustomTemplate; | 8 | use App\Models\Template\BCustomTemplate; |
| 8 | use App\Models\Template\BSetting; | 9 | use App\Models\Template\BSetting; |
| @@ -70,6 +71,13 @@ class CustomTemplateLogic extends BaseLogic | @@ -70,6 +71,13 @@ class CustomTemplateLogic extends BaseLogic | ||
| 70 | if($rs === false){ | 71 | if($rs === false){ |
| 71 | $this->fail('error'); | 72 | $this->fail('error'); |
| 72 | } | 73 | } |
| 74 | + //TODO::通知网站更新 | ||
| 75 | + $data = [ | ||
| 76 | + 'project_id'=>$this->user['project_id'], | ||
| 77 | + 'type'=>RouteMap::SOURCE_PAGE, | ||
| 78 | + 'route'=>$this->param['url'], | ||
| 79 | + ]; | ||
| 80 | + updateNotify($this->user['domain'],$data); | ||
| 73 | return $this->success(); | 81 | return $this->success(); |
| 74 | } | 82 | } |
| 75 | 83 |
| @@ -167,4 +167,21 @@ class BaseLogic extends Logic | @@ -167,4 +167,21 @@ class BaseLogic extends Logic | ||
| 167 | return ''; | 167 | return ''; |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | + /** | ||
| 171 | + * @name :(通知更新)projectUrl | ||
| 172 | + * @author :lyh | ||
| 173 | + * @method :post | ||
| 174 | + * @time :2023/6/6 14:09 | ||
| 175 | + */ | ||
| 176 | + function updateNotify($data) | ||
| 177 | + { | ||
| 178 | + $param = [ | ||
| 179 | + 'project_id'=>$data['project_id'], | ||
| 180 | + 'type'=>$data['type'], | ||
| 181 | + 'route'=>$data['route'], | ||
| 182 | + 'created_at'=>date('Y-m-d H:i:s'), | ||
| 183 | + 'updated_at'=>date('Y-m-d H:i:s') | ||
| 184 | + ]; | ||
| 185 | + return (new UpdateNotify())->insertGetId($param); | ||
| 186 | + } | ||
| 170 | } | 187 | } |
| @@ -47,7 +47,7 @@ class BlogCategoryLogic extends BaseLogic | @@ -47,7 +47,7 @@ class BlogCategoryLogic extends BaseLogic | ||
| 47 | */ | 47 | */ |
| 48 | public function add_blog_category(){ | 48 | public function add_blog_category(){ |
| 49 | //验证名称是否存在 | 49 | //验证名称是否存在 |
| 50 | - $this->verifyParamName(); | 50 | + $this->verifyParamName($this->param['name']); |
| 51 | //拼接参数 | 51 | //拼接参数 |
| 52 | $this->param = $this->addParamProcessing($this->param); | 52 | $this->param = $this->addParamProcessing($this->param); |
| 53 | DB::beginTransaction(); | 53 | DB::beginTransaction(); |
| @@ -61,13 +61,8 @@ class BlogCategoryLogic extends BaseLogic | @@ -61,13 +61,8 @@ class BlogCategoryLogic extends BaseLogic | ||
| 61 | DB::rollBack(); | 61 | DB::rollBack(); |
| 62 | $this->fail('error'); | 62 | $this->fail('error'); |
| 63 | } | 63 | } |
| 64 | - //TODO::通知网站更新 | ||
| 65 | - $data = [ | ||
| 66 | - 'project_id'=>$this->user['project_id'], | ||
| 67 | - 'type'=>RouteMap::SOURCE_BLOG_CATE, | ||
| 68 | - 'route'=>$route, | ||
| 69 | - ]; | ||
| 70 | - updateNotify($this->user['domain'],$data); | 64 | + //通知更新 |
| 65 | + $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG_CATE, 'route'=>$route]); | ||
| 71 | return $this->success(); | 66 | return $this->success(); |
| 72 | } | 67 | } |
| 73 | 68 | ||
| @@ -79,33 +74,41 @@ class BlogCategoryLogic extends BaseLogic | @@ -79,33 +74,41 @@ class BlogCategoryLogic extends BaseLogic | ||
| 79 | */ | 74 | */ |
| 80 | public function edit_blog_category(){ | 75 | public function edit_blog_category(){ |
| 81 | //验证名称是否存在 | 76 | //验证名称是否存在 |
| 82 | - $this->verifyParamName(); | ||
| 83 | - $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 84 | - if($info['id'] == $this->param['pid']){ | 77 | + $this->verifyParamName($this->param['name'],$this->param['id']); |
| 78 | + //验证参数是否可编辑 | ||
| 79 | + $this->verifyParamEdit($this->param['id'],$this->param['pid']); | ||
| 80 | + $this->param['operator_id'] = $this->user['id']; | ||
| 81 | + $this->edit($this->param,['id'=>$this->param['id']]); | ||
| 82 | + $route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_BLOG_CATE, $this->param['id'], $this->user['project_id']); | ||
| 83 | + //通知更新 | ||
| 84 | + $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG_CATE, 'route'=>$route]); | ||
| 85 | + return $this->success(); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + /** | ||
| 89 | + * @remark :查看参数是否可编辑 | ||
| 90 | + * @name :verifyParamEdit | ||
| 91 | + * @author :lyh | ||
| 92 | + * @method :post | ||
| 93 | + * @time :2023/7/31 16:31 | ||
| 94 | + */ | ||
| 95 | + public function verifyParamEdit($id,$pid){ | ||
| 96 | + $info = $this->model->read(['id'=>$id]); | ||
| 97 | + if($info['id'] == $pid){ | ||
| 85 | $this->fail('不能成为自己的上级'); | 98 | $this->fail('不能成为自己的上级'); |
| 86 | } | 99 | } |
| 87 | - if($info['pid'] != $this->param['pid']){ | ||
| 88 | - $info = $this->model->read(['pid'=>$this->param['id']]); | 100 | + if($info['pid'] != $pid){ |
| 101 | + $info = $this->model->read(['pid'=>$id]); | ||
| 89 | if($info !== false){ | 102 | if($info !== false){ |
| 90 | $this->fail('当前分类拥有子分类不允许修改父级'); | 103 | $this->fail('当前分类拥有子分类不允许修改父级'); |
| 91 | } | 104 | } |
| 92 | //查询当前分类下是否有商品 | 105 | //查询当前分类下是否有商品 |
| 93 | $blogModel = new BlogModel(); | 106 | $blogModel = new BlogModel(); |
| 94 | - $info = $blogModel->read(['id'=>['like','%,'.$this->param['id'].',%']]); | 107 | + $info = $blogModel->read(['id'=>['like','%,'.$id.',%']]); |
| 95 | if($info !== false){ | 108 | if($info !== false){ |
| 96 | $this->fail('当前分类下已存在博客,不允许修改上级'); | 109 | $this->fail('当前分类下已存在博客,不允许修改上级'); |
| 97 | } | 110 | } |
| 98 | } | 111 | } |
| 99 | - $this->param['operator_id'] = $this->user['id']; | ||
| 100 | - $this->edit($this->param,['id'=>$this->param['id']]); | ||
| 101 | - $route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_BLOG_CATE, $this->param['id'], $this->user['project_id']); | ||
| 102 | - //TODO::通知网站更新 | ||
| 103 | - $data = [ | ||
| 104 | - 'project_id'=>$this->user['project_id'], | ||
| 105 | - 'type'=>RouteMap::SOURCE_BLOG_CATE, | ||
| 106 | - 'route'=>$route, | ||
| 107 | - ]; | ||
| 108 | - updateNotify($this->user['domain'],$data); | ||
| 109 | return $this->success(); | 112 | return $this->success(); |
| 110 | } | 113 | } |
| 111 | 114 | ||
| @@ -198,15 +201,15 @@ class BlogCategoryLogic extends BaseLogic | @@ -198,15 +201,15 @@ class BlogCategoryLogic extends BaseLogic | ||
| 198 | * @method :post | 201 | * @method :post |
| 199 | * @time :2023/6/13 11:41 | 202 | * @time :2023/6/13 11:41 |
| 200 | */ | 203 | */ |
| 201 | - public function verifyParamName(){ | ||
| 202 | - if(isset($this->param['id'])){ | 204 | + public function verifyParamName($name,$id = ''){ |
| 205 | + if(isset($id) && !empty($id)){ | ||
| 203 | $condition = [ | 206 | $condition = [ |
| 204 | - 'id'=>['!=',$this->param['id']], | ||
| 205 | - 'name'=>$this->param['name'], | 207 | + 'id'=>['!=',$id], |
| 208 | + 'name'=>$name, | ||
| 206 | ]; | 209 | ]; |
| 207 | }else{ | 210 | }else{ |
| 208 | $condition = [ | 211 | $condition = [ |
| 209 | - 'name'=>$this->param['name'] | 212 | + 'name'=>$name |
| 210 | ]; | 213 | ]; |
| 211 | } | 214 | } |
| 212 | $info = $this->model->read($condition); | 215 | $info = $this->model->read($condition); |
| @@ -59,19 +59,14 @@ class BlogLogic extends BaseLogic | @@ -59,19 +59,14 @@ class BlogLogic extends BaseLogic | ||
| 59 | try { | 59 | try { |
| 60 | $this->param = $this->paramProcessing($this->param); | 60 | $this->param = $this->paramProcessing($this->param); |
| 61 | $rs = $this->model->insertGetId($this->param); | 61 | $rs = $this->model->insertGetId($this->param); |
| 62 | - $this->param['url'] = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']); | 62 | + $route = $this->param['url'] = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_BLOG, $rs, $this->user['project_id']); |
| 63 | DB::commit(); | 63 | DB::commit(); |
| 64 | }catch (\Exception $e){ | 64 | }catch (\Exception $e){ |
| 65 | DB::rollBack(); | 65 | DB::rollBack(); |
| 66 | $this->fail('error'); | 66 | $this->fail('error'); |
| 67 | } | 67 | } |
| 68 | - //TODO::通知网站更新 | ||
| 69 | - $data = [ | ||
| 70 | - 'project_id'=>$this->user['project_id'], | ||
| 71 | - 'type'=>RouteMap::SOURCE_BLOG, | ||
| 72 | - 'route'=>$this->param['url'], | ||
| 73 | - ]; | ||
| 74 | - updateNotify($this->user['domain'],$data); | 68 | + //通知更新 |
| 69 | + $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG, 'route'=>$route]); | ||
| 75 | return $this->success(); | 70 | return $this->success(); |
| 76 | } | 71 | } |
| 77 | 72 | ||
| @@ -86,20 +81,15 @@ class BlogLogic extends BaseLogic | @@ -86,20 +81,15 @@ class BlogLogic extends BaseLogic | ||
| 86 | $this->param = $this->paramProcessing($this->param); | 81 | $this->param = $this->paramProcessing($this->param); |
| 87 | DB::beginTransaction(); | 82 | DB::beginTransaction(); |
| 88 | try { | 83 | try { |
| 89 | - $this->param['url'] = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']); | 84 | + $route = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']); |
| 90 | $this->edit($this->param,['id'=>$this->param['id']]); | 85 | $this->edit($this->param,['id'=>$this->param['id']]); |
| 91 | DB::commit(); | 86 | DB::commit(); |
| 92 | }catch (\Exception $e){ | 87 | }catch (\Exception $e){ |
| 93 | DB::rollBack(); | 88 | DB::rollBack(); |
| 94 | $this->fail('error'); | 89 | $this->fail('error'); |
| 95 | } | 90 | } |
| 96 | - //TODO::通知网站更新 | ||
| 97 | - $data = [ | ||
| 98 | - 'project_id'=>$this->user['project_id'], | ||
| 99 | - 'type'=>RouteMap::SOURCE_BLOG, | ||
| 100 | - 'route'=>$this->param['url'], | ||
| 101 | - ]; | ||
| 102 | - updateNotify($this->user['domain'],$data); | 91 | + //通知更新 |
| 92 | + $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG, 'route'=>$route]); | ||
| 103 | return $this->success(); | 93 | return $this->success(); |
| 104 | } | 94 | } |
| 105 | /** | 95 | /** |
| @@ -56,7 +56,7 @@ class NewsCategoryLogic extends BaseLogic | @@ -56,7 +56,7 @@ class NewsCategoryLogic extends BaseLogic | ||
| 56 | */ | 56 | */ |
| 57 | public function add_news_category(){ | 57 | public function add_news_category(){ |
| 58 | //验证名称是否存在 | 58 | //验证名称是否存在 |
| 59 | - $this->verifyParamName(); | 59 | + $this->verifyParamName($this->param['name']); |
| 60 | //参数处理 | 60 | //参数处理 |
| 61 | $this->param = $this->addParamProcessing($this->param); | 61 | $this->param = $this->addParamProcessing($this->param); |
| 62 | DB::beginTransaction(); | 62 | DB::beginTransaction(); |
| @@ -70,13 +70,8 @@ class NewsCategoryLogic extends BaseLogic | @@ -70,13 +70,8 @@ class NewsCategoryLogic extends BaseLogic | ||
| 70 | DB::rollBack(); | 70 | DB::rollBack(); |
| 71 | $this->fail('error'); | 71 | $this->fail('error'); |
| 72 | } | 72 | } |
| 73 | - //TODO::通知网站更新 | ||
| 74 | - $data = [ | ||
| 75 | - 'project_id'=>$this->user['project_id'], | ||
| 76 | - 'type'=>RouteMap::SOURCE_NEWS_CATE, | ||
| 77 | - 'route'=>$route, | ||
| 78 | - ]; | ||
| 79 | - updateNotify($this->user['domain'],$data); | 73 | + //通知更新 |
| 74 | + $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$route]); | ||
| 80 | return $this->success(); | 75 | return $this->success(); |
| 81 | } | 76 | } |
| 82 | 77 | ||
| @@ -88,19 +83,14 @@ class NewsCategoryLogic extends BaseLogic | @@ -88,19 +83,14 @@ class NewsCategoryLogic extends BaseLogic | ||
| 88 | */ | 83 | */ |
| 89 | public function edit_news_category(){ | 84 | public function edit_news_category(){ |
| 90 | //验证名称是否存在 | 85 | //验证名称是否存在 |
| 91 | - $this->verifyParamName(); | 86 | + $this->verifyParamName($this->param['name'],$this->param['id']); |
| 92 | //验证是否可编辑 | 87 | //验证是否可编辑 |
| 93 | $this->verifyEditParam(); | 88 | $this->verifyEditParam(); |
| 94 | $this->param['operator_id'] = $this->user['id']; | 89 | $this->param['operator_id'] = $this->user['id']; |
| 95 | $this->edit($this->param,['id'=>$this->param['id']]); | 90 | $this->edit($this->param,['id'=>$this->param['id']]); |
| 96 | $route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $this->param['id'], $this->user['project_id']); | 91 | $route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $this->param['id'], $this->user['project_id']); |
| 97 | - //TODO::通知网站更新 | ||
| 98 | - $data = [ | ||
| 99 | - 'project_id'=>$this->user['project_id'], | ||
| 100 | - 'type'=>RouteMap::SOURCE_NEWS_CATE, | ||
| 101 | - 'route'=>$route, | ||
| 102 | - ]; | ||
| 103 | - updateNotify($this->user['domain'],$data); | 92 | + //通知更新 |
| 93 | + $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$route]); | ||
| 104 | return $this->success(); | 94 | return $this->success(); |
| 105 | } | 95 | } |
| 106 | 96 | ||
| @@ -111,19 +101,19 @@ class NewsCategoryLogic extends BaseLogic | @@ -111,19 +101,19 @@ class NewsCategoryLogic extends BaseLogic | ||
| 111 | * @method :post | 101 | * @method :post |
| 112 | * @time :2023/7/31 15:41 | 102 | * @time :2023/7/31 15:41 |
| 113 | */ | 103 | */ |
| 114 | - public function verifyEditParam(){ | ||
| 115 | - $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 116 | - if($info['id'] == $this->param['pid']){ | 104 | + public function verifyEditParam($id,$pid){ |
| 105 | + $info = $this->model->read(['id'=>$id]); | ||
| 106 | + if($info['id'] == $pid){ | ||
| 117 | $this->fail('不能成为自己的上级'); | 107 | $this->fail('不能成为自己的上级'); |
| 118 | } | 108 | } |
| 119 | - if($info['pid'] != $this->param['pid']){ | ||
| 120 | - $info = $this->model->read(['pid'=>$this->param['id']]); | 109 | + if($info['pid'] != $pid){ |
| 110 | + $info = $this->model->read(['pid'=>$id]); | ||
| 121 | if($info !== false){ | 111 | if($info !== false){ |
| 122 | $this->fail('当前分类拥有子分类不允许修改父级'); | 112 | $this->fail('当前分类拥有子分类不允许修改父级'); |
| 123 | } | 113 | } |
| 124 | //查询当前分类下是否有商品 | 114 | //查询当前分类下是否有商品 |
| 125 | $newsModel = new NewsModel(); | 115 | $newsModel = new NewsModel(); |
| 126 | - $info = $newsModel->read(['id'=>['like','%,'.$this->param['id'].',%']]); | 116 | + $info = $newsModel->read(['id'=>['like','%,'.$id.',%']]); |
| 127 | if($info !== false){ | 117 | if($info !== false){ |
| 128 | $this->fail('当前分类下已存在新闻,不允许修改上级'); | 118 | $this->fail('当前分类下已存在新闻,不允许修改上级'); |
| 129 | } | 119 | } |
| @@ -193,15 +183,15 @@ class NewsCategoryLogic extends BaseLogic | @@ -193,15 +183,15 @@ class NewsCategoryLogic extends BaseLogic | ||
| 193 | * @method :post | 183 | * @method :post |
| 194 | * @time :2023/6/13 11:41 | 184 | * @time :2023/6/13 11:41 |
| 195 | */ | 185 | */ |
| 196 | - public function verifyParamName(){ | ||
| 197 | - if(isset($this->param['id'])){ | 186 | + public function verifyParamName($name,$id = ''){ |
| 187 | + if(isset($id) && !empty($id)){ | ||
| 198 | $condition = [ | 188 | $condition = [ |
| 199 | - 'id'=>['!=',$this->param['id']], | ||
| 200 | - 'name'=>$this->param['name'], | 189 | + 'id'=>['!=',$id], |
| 190 | + 'name'=>$name, | ||
| 201 | ]; | 191 | ]; |
| 202 | }else{ | 192 | }else{ |
| 203 | $condition = [ | 193 | $condition = [ |
| 204 | - 'name'=>$this->param['name'] | 194 | + 'name'=>$name |
| 205 | ]; | 195 | ]; |
| 206 | } | 196 | } |
| 207 | $info = $this->model->read($condition); | 197 | $info = $this->model->read($condition); |
| @@ -59,19 +59,14 @@ class NewsLogic extends BaseLogic | @@ -59,19 +59,14 @@ class NewsLogic extends BaseLogic | ||
| 59 | try { | 59 | try { |
| 60 | $this->param = $this->paramProcessing($this->param); | 60 | $this->param = $this->paramProcessing($this->param); |
| 61 | $rs = $this->model->insertGetId($this->param); | 61 | $rs = $this->model->insertGetId($this->param); |
| 62 | - $this->param['url'] = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); | 62 | + $route = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); |
| 63 | DB::commit(); | 63 | DB::commit(); |
| 64 | }catch (\Exception $e){ | 64 | }catch (\Exception $e){ |
| 65 | DB::rollBack(); | 65 | DB::rollBack(); |
| 66 | $this->fail('添加失败'); | 66 | $this->fail('添加失败'); |
| 67 | } | 67 | } |
| 68 | - //TODO::通知网站更新 | ||
| 69 | - $data = [ | ||
| 70 | - 'project_id'=>$this->user['project_id'], | ||
| 71 | - 'type'=>RouteMap::SOURCE_NEWS, | ||
| 72 | - 'route'=>$this->param['url'], | ||
| 73 | - ]; | ||
| 74 | - updateNotify($this->user['domain'],$data); | 68 | + //通知更新 |
| 69 | + $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS, 'route'=>$route]); | ||
| 75 | return $this->success(); | 70 | return $this->success(); |
| 76 | } | 71 | } |
| 77 | 72 | ||
| @@ -87,20 +82,15 @@ class NewsLogic extends BaseLogic | @@ -87,20 +82,15 @@ class NewsLogic extends BaseLogic | ||
| 87 | DB::beginTransaction(); | 82 | DB::beginTransaction(); |
| 88 | try { | 83 | try { |
| 89 | //设置路由 | 84 | //设置路由 |
| 90 | - $this->param['url'] = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_NEWS, $this->param['id'], $this->user['project_id']); | 85 | + $route = RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_NEWS, $this->param['id'], $this->user['project_id']); |
| 91 | $this->edit($this->param,['id'=>$this->param['id']]); | 86 | $this->edit($this->param,['id'=>$this->param['id']]); |
| 92 | DB::commit(); | 87 | DB::commit(); |
| 93 | }catch (\exception $e){ | 88 | }catch (\exception $e){ |
| 94 | DB::rollBack(); | 89 | DB::rollBack(); |
| 95 | $this->fail('参数错误或其他服务器原因,编辑失败'); | 90 | $this->fail('参数错误或其他服务器原因,编辑失败'); |
| 96 | } | 91 | } |
| 97 | - //TODO::通知网站更新 | ||
| 98 | - $data = [ | ||
| 99 | - 'project_id'=>$this->user['project_id'], | ||
| 100 | - 'type'=>RouteMap::SOURCE_NEWS, | ||
| 101 | - 'route'=>$this->param['url'], | ||
| 102 | - ]; | ||
| 103 | - updateNotify($this->user['domain'],$data); | 92 | + //通知更新 |
| 93 | + $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS, 'route'=>$route]); | ||
| 104 | return $this->success(); | 94 | return $this->success(); |
| 105 | } | 95 | } |
| 106 | 96 |
| @@ -71,12 +71,8 @@ class CategoryLogic extends BaseLogic | @@ -71,12 +71,8 @@ class CategoryLogic extends BaseLogic | ||
| 71 | errorLog('产品分类保存失败', $param, $e); | 71 | errorLog('产品分类保存失败', $param, $e); |
| 72 | $this->fail('保存失败'); | 72 | $this->fail('保存失败'); |
| 73 | } | 73 | } |
| 74 | - $data = [ | ||
| 75 | - 'project_id'=>$this->user['project_id'], | ||
| 76 | - 'type'=>RouteMap::SOURCE_PRODUCT, | ||
| 77 | - 'route'=>$route, | ||
| 78 | - ]; | ||
| 79 | - updateNotify($this->user['domain'],$data); | 74 | + //通知更新 |
| 75 | + $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT_CATE, 'route'=>$route]); | ||
| 80 | return $this->success(); | 76 | return $this->success(); |
| 81 | } | 77 | } |
| 82 | 78 |
| @@ -48,13 +48,15 @@ class KeywordLogic extends BaseLogic | @@ -48,13 +48,15 @@ class KeywordLogic extends BaseLogic | ||
| 48 | try { | 48 | try { |
| 49 | $res = parent::save($param); | 49 | $res = parent::save($param); |
| 50 | //路由映射 | 50 | //路由映射 |
| 51 | - RouteMap::setRoute($param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $res['id'], $this->user['project_id']); | 51 | + $route = RouteMap::setRoute($param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $res['id'], $this->user['project_id']); |
| 52 | DB::commit(); | 52 | DB::commit(); |
| 53 | }catch (\Exception $e){ | 53 | }catch (\Exception $e){ |
| 54 | DB::rollBack(); | 54 | DB::rollBack(); |
| 55 | errorLog('产品关键词保存失败', $param, $e); | 55 | errorLog('产品关键词保存失败', $param, $e); |
| 56 | $this->fail('保存失败'); | 56 | $this->fail('保存失败'); |
| 57 | } | 57 | } |
| 58 | + //通知更新 | ||
| 59 | + $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT_KEYWORD, 'route'=>$route]); | ||
| 58 | return $this->success(); | 60 | return $this->success(); |
| 59 | } | 61 | } |
| 60 | 62 |
| @@ -74,7 +74,6 @@ class ProductLogic extends BaseLogic | @@ -74,7 +74,6 @@ class ProductLogic extends BaseLogic | ||
| 74 | DB::beginTransaction(); | 74 | DB::beginTransaction(); |
| 75 | try { | 75 | try { |
| 76 | $data = $param; | 76 | $data = $param; |
| 77 | - unset($data['route']); | ||
| 78 | $data['created_uid'] = $this->user['id']; | 77 | $data['created_uid'] = $this->user['id']; |
| 79 | $res = parent::save($data); | 78 | $res = parent::save($data); |
| 80 | //关联分类 | 79 | //关联分类 |
| @@ -82,19 +81,15 @@ class ProductLogic extends BaseLogic | @@ -82,19 +81,15 @@ class ProductLogic extends BaseLogic | ||
| 82 | //关联关键词 | 81 | //关联关键词 |
| 83 | KeywordRelated::saveRelated($res['id'], $data['keyword_id']); | 82 | KeywordRelated::saveRelated($res['id'], $data['keyword_id']); |
| 84 | //路由映射 | 83 | //路由映射 |
| 85 | - $param['route'] = RouteMap::setRoute($param['route'], RouteMap::SOURCE_PRODUCT, $res['id'], $this->user['project_id']); | 84 | + $route = RouteMap::setRoute($param['route'], RouteMap::SOURCE_PRODUCT, $res['id'], $this->user['project_id']); |
| 86 | DB::commit(); | 85 | DB::commit(); |
| 87 | }catch (\Exception $e){ | 86 | }catch (\Exception $e){ |
| 88 | DB::rollBack(); | 87 | DB::rollBack(); |
| 89 | errorLog('产品保存失败', $param, $e); | 88 | errorLog('产品保存失败', $param, $e); |
| 90 | $this->fail('保存失败'); | 89 | $this->fail('保存失败'); |
| 91 | } | 90 | } |
| 92 | - $data = [ | ||
| 93 | - 'project_id'=>$this->user['project_id'], | ||
| 94 | - 'type'=>RouteMap::SOURCE_PRODUCT, | ||
| 95 | - 'route'=>$param['route'], | ||
| 96 | - ]; | ||
| 97 | - updateNotify($this->user['domain'],$data); | 91 | + //通知更新 |
| 92 | + $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT, 'route'=>$route]); | ||
| 98 | return $this->success(); | 93 | return $this->success(); |
| 99 | } | 94 | } |
| 100 | 95 |
| @@ -22,7 +22,7 @@ class Product extends Base | @@ -22,7 +22,7 @@ class Product extends Base | ||
| 22 | const STATUS_ON = 1; | 22 | const STATUS_ON = 1; |
| 23 | const STATUS_RECYCLE = 2; | 23 | const STATUS_RECYCLE = 2; |
| 24 | 24 | ||
| 25 | - protected $appends = ['route']; | 25 | +// protected $appends = ['route']; |
| 26 | 26 | ||
| 27 | public static function statusMap(){ | 27 | public static function statusMap(){ |
| 28 | return [ | 28 | return [ |
-
请 注册 或 登录 后发表评论