|
@@ -2598,12 +2598,12 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
->leftJoin('component','component_img.component_id','=','component.component_type')
|
|
|
->select('component_img.*','template.template_name','component.component_name')
|
|
|
->paginate($data['page_size'], ['*'], 'page', $data['page']);
|
|
|
- if(empty($component_img)){
|
|
|
+ if($component_img->isEmpty()){
|
|
|
return Result::error('组件预览图不存在!');
|
|
|
}
|
|
|
$component_img = [
|
|
|
- 'data' => $component_img,
|
|
|
- 'total' => $component_img['total'],
|
|
|
+ 'data' => $component_img->items(),
|
|
|
+ 'total' => $component_img->total(),
|
|
|
];
|
|
|
return Result::success($component_img);
|
|
|
}
|
|
@@ -2617,6 +2617,10 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
if(!empty($img)){
|
|
|
return Result::error('该组件已存在此皮肤的预览图!');
|
|
|
}
|
|
|
+ $component = ComponentImg::where('component_id',$data['component_id'])->where('img_id',$data['img_id'])->first();
|
|
|
+ if(!empty($component)){
|
|
|
+ return Result::error('组件预览图编号已存在!');
|
|
|
+ }
|
|
|
$component_img = ComponentImg::insertGetId($data);
|
|
|
if(empty($component_img)){
|
|
|
return Result::error('添加失败!');
|
|
@@ -2643,6 +2647,11 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
if(!empty($img)){
|
|
|
return Result::error('该组件已存在此皮肤的预览图!');
|
|
|
}
|
|
|
+ $component = ComponentImg::where('component_id',$data['component_id'])->where('id','!=',$data['id'])->where('img_id',$data['img_id'])->first();
|
|
|
+
|
|
|
+ if(!empty($component)){
|
|
|
+ return Result::error('组件预览图编号已存在!');
|
|
|
+ }
|
|
|
unset($data['user_id']);
|
|
|
// unset($data['updated_at']);
|
|
|
$id = $data['id'];
|
|
@@ -2658,30 +2667,30 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
/**
|
|
|
* 自助建站-随机生成模板
|
|
|
*/
|
|
|
- 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;
|
|
|
- }
|
|
|
+ // 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;
|
|
|
+ // }
|
|
|
}
|