|
@@ -43,6 +43,7 @@ use App\Model\AdPlace;
|
|
|
use App\Model\WebsiteImg;
|
|
|
use App\Model\SectorComponent;
|
|
|
use App\Model\ComponentImg;
|
|
|
+use App\Model\TemplateRule;
|
|
|
|
|
|
#[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
|
class PublicRpcService implements PublicRpcServiceInterface
|
|
@@ -913,8 +914,12 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
if (!empty($web_template)) {
|
|
|
return Result::error("此皮肤已被绑定网站,不可删除", 0);
|
|
|
}
|
|
|
- if ($template->type == 1) {
|
|
|
- return Result::error("默认皮肤不能删除", 0);
|
|
|
+ // if ($template->type == 1) {
|
|
|
+ // return Result::error("默认皮肤不能删除", 0);
|
|
|
+ // }
|
|
|
+ $component_img = ComponentImg::where('template_id',$template['template_id'])->get();
|
|
|
+ if(!empty($component_img)){
|
|
|
+ return Result::error('此皮肤已绑定组件预览图,不可删除!');
|
|
|
}
|
|
|
$result = Template::where('id', $data['id'])->delete();
|
|
|
var_dump($result, '-------------------delete');
|
|
@@ -1656,11 +1661,20 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ $component_img = ComponentImg::where('component_id',$component['id'])->get();
|
|
|
+ if(!empty($component_img)){
|
|
|
+ $component_img = ComponentImg::where('component_id',$component['id'])->delete();
|
|
|
+ if(empty($component_img)){
|
|
|
+ Db::rollBack();
|
|
|
+ return Result::error('删除组件预览图失败!');
|
|
|
+ }
|
|
|
+ }
|
|
|
$result = Component::where('id',$data['id'])->delete();
|
|
|
if(empty($result)){
|
|
|
Db::rollBack();
|
|
|
return Result::error('删除失败!');
|
|
|
}
|
|
|
+
|
|
|
Db::commit();
|
|
|
return Result::success($result);
|
|
|
}catch(\Exception $e){
|
|
@@ -2587,6 +2601,10 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
if(empty($component_img)){
|
|
|
return Result::error('组件预览图不存在!');
|
|
|
}
|
|
|
+ $component_img = [
|
|
|
+ 'data' => $component_img,
|
|
|
+ 'total' => $component_img['total'],
|
|
|
+ ];
|
|
|
return Result::success($component_img);
|
|
|
}
|
|
|
/**
|
|
@@ -2637,7 +2655,33 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
}
|
|
|
return Result::success($component_img);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 自助建站-随机生成模板
|
|
|
+ */
|
|
|
+ public function randomWebTemplate(array $data): array
|
|
|
+ {
|
|
|
+ // $where['website_id'] = $data['website_id'];
|
|
|
+ $web = Website::where('id',$data['website_id'])->first();
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ if(empty($web)){
|
|
|
+ return Result::error('网站不存在!');
|
|
|
+ }
|
|
|
+ $where['template_id'] = $data['template_id'];
|
|
|
+ $template = Template::where($where)->first();
|
|
|
+ if(empty($template)){
|
|
|
+ return Result::error('模板不存在!');
|
|
|
+ }
|
|
|
+ $rule = TemplateRule::first();
|
|
|
+ if(empty($rule)){
|
|
|
+ return Result::error('模板规则不存在!');
|
|
|
+ }
|
|
|
+ $index_rule = json_decode($rule->index_rule,true);
|
|
|
+ $index = $this->getRandomIndex($index_rule,$template);
|
|
|
+ return Result::success($index);
|
|
|
+ }
|
|
|
+ public function getRandomIndex($index_rule,$template){
|
|
|
+ // $where = ['page_type','like','%'.1.'%'];
|
|
|
+ $index = Sector::where('template_id',$template->template_id)->where('page_type','like','%1%')->limit(10)->get();
|
|
|
+ return $index;
|
|
|
+ }
|
|
|
}
|