|
@@ -24,7 +24,8 @@ use App\Model\WebsiteTemplate;
|
|
|
use App\Model\WebsiteTemplateInfo;
|
|
|
use App\Model\Sector;
|
|
|
use App\Model\Component;
|
|
|
-
|
|
|
+use App\Model\Link;
|
|
|
+use App\Model\FooterCategory;
|
|
|
#[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
|
class PublicRpcService implements PublicRpcServiceInterface
|
|
|
{
|
|
@@ -805,11 +806,9 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
->select('template.*', 'template_class.name as template_class_name')
|
|
|
->orderBy('template.id', 'desc')
|
|
|
->paginate($data['page_size'], ['*'], 'mypage_name', $data['page']);
|
|
|
- // 使用 items 方法获取分页数据
|
|
|
- // $items = collect($result->items());
|
|
|
- // $items->each(function ($item) {
|
|
|
- // $item['template_content'] = json_decode($item['template_content'], true);
|
|
|
- // });
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error("暂无皮肤", 0);
|
|
|
+ }
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
public function getTemplateInfo(array $data): array
|
|
@@ -818,6 +817,9 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
->leftJoin('template_class', 'template.template_class_id', 'template_class.id')
|
|
|
->select('template.*', 'template_class.name as template_class_name')
|
|
|
->first();
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error("暂无皮肤", 0);
|
|
|
+ }
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
/**
|
|
@@ -836,6 +838,8 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
return Result::error("皮肤名称或者皮肤编号已存在,不可添加!", 0);
|
|
|
}
|
|
|
$data['template_keyword'] = json_encode($data['template_keyword']) ?? '';
|
|
|
+ $page_type = json_decode($data['page_type'], true);
|
|
|
+ $data['page_type'] = json_encode(array_values(array_unique($page_type)));
|
|
|
$result = Template::insertGetId($data);
|
|
|
if(empty($result)){
|
|
|
return Result::error("创建失败", 0);
|
|
@@ -881,6 +885,8 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
return Result::error("皮肤名称或者皮肤编号已存在,不可编辑!", 0);
|
|
|
}
|
|
|
$data['template_keyword'] = json_encode($data['template_keyword']) ?? '';
|
|
|
+ $page_type = json_decode($data['page_type'], true);
|
|
|
+ $data['page_type'] = json_encode(array_values(array_unique($page_type)));
|
|
|
$result = Template::where('id', $data['id'])->update($data);
|
|
|
var_dump($result, '-------------------update');
|
|
|
if (!$result) {
|
|
@@ -1084,37 +1090,153 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
$result = Component::where('id', $data['id'])->update($data);
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
- public function getWebsiteTemplateList(array $data): array
|
|
|
+
|
|
|
+ public function getWebsiteTemplateInfo(array $data)
|
|
|
{
|
|
|
$where = [];
|
|
|
-
|
|
|
+ if (isset($data['id'])) {
|
|
|
+ $where[] = ['id', '=', $data['id']];
|
|
|
+ }
|
|
|
$result = WebsiteTemplateInfo::where($where)
|
|
|
->leftJoin('website', 'website_template_info.website_id', '=', 'website.id')
|
|
|
+ ->leftJoin('website_template', 'website_template_info.template_id', '=', 'website_template.id')
|
|
|
->select('website_template_info.*', 'website.website_name')
|
|
|
- ->orderBy('website_template_info.id', 'desc')
|
|
|
- ->paginate($data['page_size'], ['*'], 'page', $data['page']);
|
|
|
+ ->get();
|
|
|
if ($result) {
|
|
|
return Result::success($result);
|
|
|
} else {
|
|
|
return Result::error('暂无数据');
|
|
|
}
|
|
|
}
|
|
|
- public function getWebsiteTemplateInfo(array $data)
|
|
|
+ /**
|
|
|
+ * 自助建站----1.获取页面类型回显
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getWebPageType(array $data): array
|
|
|
{
|
|
|
- $where = [];
|
|
|
- if (isset($data['id'])) {
|
|
|
- $where[] = ['id', '=', $data['id']];
|
|
|
+ // 1:图片 2:文字 3:底部
|
|
|
+ $friend_link = Link::where('website_id', $data['website_id'])->where('type',3)->get();
|
|
|
+ if(empty($friend_link->toArray())){
|
|
|
+ return Result::error('暂无友情链接数据!');
|
|
|
}
|
|
|
- $result = WebsiteTemplateInfo::where($where)
|
|
|
- ->leftJoin('website', 'website_template_info.website_id', '=', 'website.id')
|
|
|
- ->leftJoin('website_template', 'website_template_info.template_id', '=', 'website_template.id')
|
|
|
- ->select('website_template_info.*', 'website.website_name')
|
|
|
- ->get();
|
|
|
+ $footer_category = FooterCategory::where('website_id', $data['website_id'])->get();
|
|
|
+ if(empty($footer_category->toArray())){
|
|
|
+ return Result::error('暂无底部导航数据!');
|
|
|
+ }
|
|
|
+ $result = [
|
|
|
+ 'friend_link' => $friend_link,
|
|
|
+ 'footer_category' => $footer_category,
|
|
|
+ ];
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 自助建站----2.添加页面类型
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function addWebPageType(array $data): array
|
|
|
+ {
|
|
|
+ // 1:首页 2:频道页 3:列表页 4:详情页 5:搜索页 6:特殊列表 7:特殊详情页'
|
|
|
+ if($data['is_search'] == 1){
|
|
|
+ $page_type = json_encode([1,2,3,4,5,6,7]);
|
|
|
+ }else{
|
|
|
+ $page_type = json_encode([1,2,3,4,6,7]);
|
|
|
+ }
|
|
|
+ // 0:未构建;1:已填写基础信息;2:已选择模板; action_id
|
|
|
+ $result = WebsiteTemplateInfo::where('website_id', $data['website_id'])->update(['page_type' => $page_type],['action_id' => 1]);
|
|
|
if ($result) {
|
|
|
return Result::success($result);
|
|
|
} else {
|
|
|
- return Result::error('暂无数据');
|
|
|
+ return Result::error('添加失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 自助建站---流程---3.选择皮肤列表
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getWebsiteTemplateList(array $data): array
|
|
|
+ {
|
|
|
+ $where = [];
|
|
|
+ if(isset($data['template_class_id']) && $data['template_class_id']){
|
|
|
+ $where[] = ['template_class_id', '=', $data['template_class_id']];
|
|
|
+ }
|
|
|
+ // 0:未构建 1:未应用 2:已应用 status
|
|
|
+ $templste_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
|
+ if(empty($templste_info)){
|
|
|
+ return Result::error('请先填写网站基础信息!');
|
|
|
+ }
|
|
|
+ if($templste_info['status'] == 2){
|
|
|
+ return Result::error('网站已应用,不可再次修改!');
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($data['keyword']) && !empty($data['keyword'])){
|
|
|
+ if (is_array($data['keyword'])) {
|
|
|
+ // 拼接多个模糊查询条件
|
|
|
+ $query = Template::query();
|
|
|
+ foreach ($data['keyword'] as $kw) {
|
|
|
+ $escapedKw = addcslashes($kw, '%_'); // 转义通配符
|
|
|
+ $query->WhereRaw("JSON_EXTRACT(template_keyword, '$[*]') LIKE ?", ["%$escapedKw%"]);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $escapedKeyword = addcslashes($data['keyword'], '%_'); // 转义通配符
|
|
|
+ $where[] = [DB::raw("JSON_EXTRACT(template_keyword, '$[*]') LIKE ?"), "%$escapedKeyword%"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // $template_id = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first(['template_id', 'page_type']);
|
|
|
+ if(!empty($template_id['page_type']) && $templste_info['page_type'] != '[]' && is_string($templste_info['page_type'])){
|
|
|
+ $template_page = is_string($templste_info['page_type']) ? json_decode($templste_info['page_type'], true) : [];
|
|
|
+ }else{
|
|
|
+ $template_page = [];
|
|
|
+ }
|
|
|
+ if(!empty($template_id['template_id'])){
|
|
|
+ $result['template_id'] = $templste_info['template_id'];
|
|
|
+ }
|
|
|
+ // 确保 $template_page 为有效数据,避免 SQL 注入风险,这里使用参数绑定
|
|
|
+ $template_page_str = json_encode($template_page);
|
|
|
+ if (isset($query)) {
|
|
|
+ $result['template'] = $query->where($where)
|
|
|
+ ->whereRaw("JSON_CONTAINS(template.page, ?)", [$template_page_str])
|
|
|
+ ->paginate($data['page_size'], ['*'], 'page', $data['page']);
|
|
|
+ } else {
|
|
|
+ $result['template'] = Template::where($where)
|
|
|
+ ->whereRaw("JSON_CONTAINS(template.page, ?)", [$template_page_str])
|
|
|
+ ->paginate($data['page_size'], ['*'], 'page', $data['page']);
|
|
|
+ }
|
|
|
+ if (!empty($result['template']['data'])) {
|
|
|
+ return Result::success($result);
|
|
|
+ } else {
|
|
|
+ $result['template'] = Template::orderBy('updated_at','desc')
|
|
|
+ ->paginate($data['page_size'], ['*'], 'page', $data['page']);
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 自助建站---流程---4.选择皮肤
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function chooseWebsiteTemplate(array $data): array
|
|
|
+ {
|
|
|
+ $website_template_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
|
+ if(empty($website_template_info)){
|
|
|
+ return Result::error('请先填写网站基础信息!');
|
|
|
+ }
|
|
|
+ // 0:未构建 1:未应用 2:已应用 status
|
|
|
+ if($website_template_info['status'] == 2){
|
|
|
+ return Result::error('网站已应用,不可再次修改!');
|
|
|
+ }
|
|
|
+ $template = Template::where('id', $data['template_id'])->first();
|
|
|
+ if(empty($template)){
|
|
|
+ return Result::error('未查询到皮肤!');
|
|
|
+ }
|
|
|
+ // 0:未构建;1:已填写基础信息;2:已选择模板; action_id
|
|
|
+ $web_template = WebsiteTemplateInfo::where('website_id', $data['website_id'])->update(['template_id' => $data['template_id'],'action_id' => 2]);
|
|
|
+ if ($web_template) {
|
|
|
+ return Result::success($web_template);
|
|
|
+ } else {
|
|
|
+ return Result::error('选择皮肤失败!');
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|