|
@@ -23,6 +23,7 @@ class CmsContentTemplateSetRepository {
|
|
|
*/
|
|
|
public function bannerSet($request)
|
|
|
{
|
|
|
+ $banner_id = $request['id']??'';
|
|
|
$rules = json_decode($request['rule'],true);
|
|
|
if (is_array($rules)){
|
|
|
if (count($rules)>10) {
|
|
@@ -38,9 +39,17 @@ class CmsContentTemplateSetRepository {
|
|
|
'area_type' => $request['area_type'],
|
|
|
'status' => 0,
|
|
|
];
|
|
|
- if (!$this->cmsContentTemplateSet->create($subject)) {
|
|
|
- throw new HttpException(500, '添加失败');
|
|
|
+ if ($banner_id){
|
|
|
+ $banners = $this->cmsContentTemplateSet->where('id',$banner_id)->update($subject);
|
|
|
+ if (!$banners) {
|
|
|
+ throw new HttpException(500, '更新失败');
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if (!$this->cmsContentTemplateSet->create($subject)) {
|
|
|
+ throw new HttpException(500, '添加失败');
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
@@ -54,6 +63,7 @@ class CmsContentTemplateSetRepository {
|
|
|
*/
|
|
|
public function advertisementSet($request)
|
|
|
{
|
|
|
+ $advertisement_id = $request['id']??'';
|
|
|
$subject = [
|
|
|
'tpl_id' => $request['tpl_id'],
|
|
|
'rule' => $request['rule'],
|
|
@@ -61,10 +71,18 @@ class CmsContentTemplateSetRepository {
|
|
|
'status' => 0,
|
|
|
];
|
|
|
|
|
|
- if (!$this->cmsContentTemplateSet->create($subject)) {
|
|
|
- throw new HttpException(500, '添加失败');
|
|
|
+ if ($advertisement_id){
|
|
|
+ $advertisement_ids = $this->cmsContentTemplateSet->where('id',$advertisement_id)->update($subject);
|
|
|
+ if (!$advertisement_ids) {
|
|
|
+ throw new HttpException(500, '更新失败');
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if (!$this->cmsContentTemplateSet->create($subject)) {
|
|
|
+ throw new HttpException(500, '添加失败');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -72,16 +90,23 @@ class CmsContentTemplateSetRepository {
|
|
|
*/
|
|
|
public function floorSet($request)
|
|
|
{
|
|
|
+ $floor_id = $request['id']??'';
|
|
|
$subject = [
|
|
|
'tpl_id' => $request['tpl_id'],
|
|
|
'rule' => $request['rule'],
|
|
|
'area_type' => $request['area_type'],
|
|
|
'status' => 0,
|
|
|
];
|
|
|
-
|
|
|
+ if ($floor_id){
|
|
|
+ $floor_ids = $this->cmsContentTemplateSet->where('id',$floor_id)->update($subject);
|
|
|
+ if (!$floor_ids) {
|
|
|
+ throw new HttpException(500, '更新失败');
|
|
|
+ }
|
|
|
+ }else {
|
|
|
if (!$this->cmsContentTemplateSet->create($subject)) {
|
|
|
throw new HttpException(500, '添加失败');
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -90,16 +115,23 @@ class CmsContentTemplateSetRepository {
|
|
|
*/
|
|
|
public function categorySet($request)
|
|
|
{
|
|
|
+ $category_id = $request['id']??'';
|
|
|
$subject = [
|
|
|
'tpl_id' => $request['tpl_id'],
|
|
|
'rule' => $request['rule'],
|
|
|
'area_type' => $request['area_type'],
|
|
|
'status' => 0,
|
|
|
];
|
|
|
-
|
|
|
+ if ($category_id){
|
|
|
+ $category_ids = $this->cmsContentTemplateSet->where('id',$category_id)->update($subject);
|
|
|
+ if (!$category_ids) {
|
|
|
+ throw new HttpException(500, '更新失败');
|
|
|
+ }
|
|
|
+ }else {
|
|
|
if (!$this->cmsContentTemplateSet->create($subject)) {
|
|
|
throw new HttpException(500, '添加失败');
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|