|
@@ -1,11 +1,12 @@
|
|
|
<?php
|
|
|
namespace App\JsonRpc;
|
|
|
+
|
|
|
use App\Model\Article;
|
|
|
use App\Model\Category;
|
|
|
use App\Model\FooterCategory;
|
|
|
use App\Model\FooterContent;
|
|
|
use App\Model\LetterOfComplaint;
|
|
|
-use App\Model\Sector;
|
|
|
+use App\Model\Link;
|
|
|
use App\Model\TemplateClass;
|
|
|
use App\Model\Template;
|
|
|
use App\Model\User;
|
|
@@ -13,16 +14,14 @@ use App\Model\WebsiteRole;
|
|
|
use App\Model\WebsiteRoleUser;
|
|
|
use App\Model\Website;
|
|
|
use App\Model\WebsiteColumn;
|
|
|
-use App\Model\WebsiteTemplate;
|
|
|
use Hyperf\DbConnection\Db;
|
|
|
use Hyperf\RpcServer\Annotation\RpcService;
|
|
|
use App\Tools\Result;
|
|
|
use App\Model\WebsiteCategory;
|
|
|
+use App\Model\WebsiteTemplate;
|
|
|
use App\Model\WebsiteTemplateInfo;
|
|
|
use function PHPUnit\Framework\isNull;
|
|
|
-use App\Model\Component;
|
|
|
-use App\Model\District;
|
|
|
-
|
|
|
+// use Illuminate\Support\Facades\DB;
|
|
|
#[RpcService(name: "WebsiteService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
|
class WebsiteService implements WebsiteServiceInterface
|
|
|
{
|
|
@@ -34,28 +33,30 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
*/
|
|
|
public function getWebsitetList(array $data): array
|
|
|
{
|
|
|
- $resultWwhere = Website::when($data,function ($query) use ($data){
|
|
|
- if(isset($data['keyword']) && !empty($data['keyword'])){
|
|
|
- $query->where('website.website_name','like','%'.$data['keyword'].'%');
|
|
|
- }
|
|
|
- if(isset($data['website_column_id']) && !empty($data['website_column_id'])){
|
|
|
- $query->whereJsonContains("website.website_column_arr_id", intval($data['website_column_id']));
|
|
|
- }
|
|
|
- if(isset($data['city_id']) && !empty($data['city_id'])){
|
|
|
- $query->whereJsonContains("website.city_arr_id", intval($data['city_id']));
|
|
|
- }
|
|
|
- });
|
|
|
- $result = $resultWwhere->leftJoin("website_column","website.website_column_id","website_column.id")
|
|
|
- ->leftJoin("district","district.id","website.city_id")
|
|
|
- ->select("website.*","website_column.column_name","district.name as city_name")
|
|
|
- ->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])->orderBy("website.id","desc")->get();
|
|
|
- $count = $resultWwhere->count();
|
|
|
+ $where = [];
|
|
|
+ if (isset($data['keyword']) && !empty($data['keyword'])) {
|
|
|
+ array_push($where, ['website.website_name', 'like', '%' . $data['keyword'] . '%']);
|
|
|
+ }
|
|
|
+ if (isset($data['website_column_id']) && !empty($data['website_column_id'])) {
|
|
|
+ array_push($where, ['website.website_column_id', '=', $data['website_column_id']]);
|
|
|
+ }
|
|
|
+ if (isset($data['city_id']) && !empty($data['city_id'])) {
|
|
|
+ array_push($where, ['website.city_id', '=', $data['city_id']]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $result = Website::where($where)
|
|
|
+ ->leftJoin("website_column", "website.website_column_id", "website_column.id")
|
|
|
+ ->leftJoin("district", "district.id", "website.city_id")
|
|
|
+ ->select("website.*", "website_column.column_name", "district.name as city_name")
|
|
|
+ ->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->orderBy("website.id", "desc")->get();
|
|
|
+
|
|
|
+ $count = Website::where($where)->count();
|
|
|
if (empty($result)) {
|
|
|
- return Result::error("没有数据",0);
|
|
|
+ return Result::error("没有数据", 0);
|
|
|
}
|
|
|
$data = [
|
|
|
- 'rows'=>$result->toArray(),
|
|
|
- 'count'=>$count
|
|
|
+ 'rows' => $result->toArray(),
|
|
|
+ 'count' => $count,
|
|
|
];
|
|
|
return Result::success($data);
|
|
|
}
|
|
@@ -71,14 +72,14 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
'website_name' => $data['website_name'],
|
|
|
'logo' => $data['logo'] ?? '',
|
|
|
'website_url' => $data['website_url'] ?? '',
|
|
|
-// 'city_id' => $data['city_id'] ?? 0,
|
|
|
+ 'city_id' => $data['city_id'] ?? 0,
|
|
|
'website_column_id' => $data['website_column_id'],
|
|
|
'title' => $data['title'] ?? '',
|
|
|
'keywords' => $data['keywords'] ?? '',
|
|
|
'description' => $data['description'] ?? '',
|
|
|
'status' => $data['status'] ?? 0,
|
|
|
'website_column_arr_id' => $data['website_column_arr_id'],
|
|
|
-// 'city_arr_id' => $data['city_arr_id'] ?? [0],
|
|
|
+ 'city_arr_id' => $data['city_arr_id'] ?? [0],
|
|
|
'template_id' => $data['template_id'] ?? 0,
|
|
|
];
|
|
|
$result = Website::insertGetId($insertData);
|
|
@@ -100,14 +101,14 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
'website_name' => $data['website_name'],
|
|
|
'logo' => $data['logo'] ?? '',
|
|
|
'website_url' => $data['website_url'] ?? '',
|
|
|
-// 'city_id' => $data['city_id'] ?? 0,
|
|
|
+ 'city_id' => $data['city_id'] ?? 0,
|
|
|
'website_column_id' => $data['website_column_id'],
|
|
|
'title' => $data['title'] ?? '',
|
|
|
'keywords' => $data['keywords'] ?? '',
|
|
|
'description' => $data['description'] ?? '',
|
|
|
'status' => $data['status'] ?? 0,
|
|
|
'website_column_arr_id' => $data['website_column_arr_id'],
|
|
|
-// 'city_arr_id' => $data['city_arr_id'] ?? [0],
|
|
|
+ 'city_arr_id' => $data['city_arr_id'] ?? [0],
|
|
|
'template_id' => $data['template_id'] ?? 0,
|
|
|
];
|
|
|
$result = Website::where('id', $id)->update($insertData);
|
|
@@ -141,32 +142,11 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
{
|
|
|
|
|
|
$where = [
|
|
|
- ['website.id', '=', $id]
|
|
|
+ ['website.id', '=', $id],
|
|
|
];
|
|
|
$result = Website::where($where)
|
|
|
- ->leftJoin("website_template_info", "website_template_info.website_id", "website.id")
|
|
|
- ->select("website.*",
|
|
|
- "website_template_info.template_id",
|
|
|
- "website_template_info.page_type",
|
|
|
- "website_template_info.statement",
|
|
|
- "website_template_info.organizer",
|
|
|
- "website_template_info.copyright_information",
|
|
|
- "website_template_info.contact_number",
|
|
|
- "website_template_info.company_address",
|
|
|
- "website_template_info.project_logo",
|
|
|
- "website_template_info.project_name",
|
|
|
- "website_template_info.project_url",
|
|
|
- "website_template_info.company_logo",
|
|
|
- "website_template_info.company_name",
|
|
|
- "website_template_info.company_url",
|
|
|
- "website_template_info.record_number",
|
|
|
- "website_template_info.record_number_url",
|
|
|
- "website_template_info.icp_number",
|
|
|
- "website_template_info.icp_number_url",
|
|
|
- "website_template_info.customer_service_qq",
|
|
|
- "website_template_info.communications",
|
|
|
- "website_template_info.status",
|
|
|
- )
|
|
|
+ ->leftJoin("template", "template.id", "website.template_id")
|
|
|
+ ->select("website.*", "template.template_name", "template.template_img")
|
|
|
->first();
|
|
|
if (empty($result)) {
|
|
|
return Result::error("数据不存在", 0);
|
|
@@ -191,7 +171,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* @param string $keyword
|
|
|
* @param int $page
|
|
@@ -214,7 +193,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
$data = [
|
|
|
'rows' => $result->toArray(),
|
|
|
- 'count' => $count
|
|
|
+ 'count' => $count,
|
|
|
];
|
|
|
return Result::success($data);
|
|
|
}
|
|
@@ -302,12 +281,11 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
$data = [
|
|
|
'rows' => $result->toArray(),
|
|
|
- 'count' => $count
|
|
|
+ 'count' => $count,
|
|
|
];
|
|
|
return Result::success($data);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* @param array $data
|
|
|
* @return array
|
|
@@ -317,7 +295,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
|
|
|
$insertData = [
|
|
|
'website_id' => $data['website_id'],
|
|
|
- 'role_id' => $data['role_id'] ?? ''
|
|
|
+ 'role_id' => $data['role_id'] ?? '',
|
|
|
];
|
|
|
$info = WebsiteRole::where($insertData)->first();
|
|
|
if ($info) {
|
|
@@ -367,7 +345,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* @param string $keyword
|
|
|
* @param int $page
|
|
@@ -394,7 +371,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
$data = [
|
|
|
'rows' => $result->toArray(),
|
|
|
- 'count' => $count
|
|
|
+ 'count' => $count,
|
|
|
];
|
|
|
return Result::success($data);
|
|
|
}
|
|
@@ -483,7 +460,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
{
|
|
|
$where = [
|
|
|
'website_id' => $data['website_id'],
|
|
|
- 'pid' => 0
|
|
|
+ 'pid' => 0,
|
|
|
];
|
|
|
$result = WebsiteCategory::where($where)->orderBy('sort', 'asc')->get();
|
|
|
if (empty($result)) {
|
|
@@ -493,181 +470,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 查询网站的广告
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function getWebsiteAdvertisement(array $data): array
|
|
|
- {
|
|
|
- $where = [
|
|
|
- 'website_id' => $data['website_id'],
|
|
|
- 'id' => $data['ad_placeid']
|
|
|
- ];
|
|
|
- $ad_place = AdPlace::where($where)->orderBy('id', 'asc')->limit(1)->get();
|
|
|
-
|
|
|
-
|
|
|
- $today = Carbon::now();
|
|
|
-
|
|
|
- if (empty($ad_place)) {
|
|
|
- return Result::error("error", 0);
|
|
|
- } else {
|
|
|
- foreach ($ad_place as $val) {
|
|
|
- $adplaceid = $val;
|
|
|
- }
|
|
|
- $ad = Ad::where('pid', $adplaceid['id'])->where('status', 1)->orderBy('id', 'asc')->get();
|
|
|
- if (empty($ad)) {
|
|
|
- $result = $adplaceid;
|
|
|
- return Result::success($result);
|
|
|
- } else {
|
|
|
- foreach ($ad as $i) {
|
|
|
- $starttime = Carbon::parse($i['fromtime']);
|
|
|
- $endtime = Carbon::parse($i['totime']);
|
|
|
- $time = $today->between($starttime, $endtime);
|
|
|
- if ($time) {
|
|
|
- $result = $i;
|
|
|
- }
|
|
|
- }
|
|
|
- if (empty($result)) {
|
|
|
- $result = $ad;
|
|
|
- return Result::success($result);
|
|
|
- } else {
|
|
|
- return Result::success($result);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 网站行政职能搜索
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function selectWebsiteDepartment(array $data): array
|
|
|
- {
|
|
|
-
|
|
|
- $depart = Department::where('pid', 0)->orderBy('id', 'asc')->limit(10)->get();
|
|
|
- if (isset($data['keyword']) && !empty($data['keyword'])) {
|
|
|
- $departments = Department::where('name', 'like', '%' . $data['keyword'] . '%')->get();
|
|
|
- if (empty($departments)) {
|
|
|
- $result['message'] = "未查询到与此相关职能部门";
|
|
|
- } else {
|
|
|
- $count = Department::where('name', 'like', "%{$data['keyword']}%")->count();
|
|
|
- $m = [
|
|
|
- 'department' => $depart,
|
|
|
- 'type' => $departments,
|
|
|
- 'count' => $count
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
- $result['sele'] = $m;
|
|
|
- return Result::success($result['sele']);
|
|
|
-
|
|
|
- }
|
|
|
- $result = $depart;
|
|
|
- return Result::success($result['data']);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 搜索地区
|
|
|
- */
|
|
|
- public function selectWebsiteArea(array $data): array
|
|
|
- {
|
|
|
-
|
|
|
- $provinces = District::where('pid', 0)->where('status', 1)->get();
|
|
|
-
|
|
|
- if (isset($data['province'])) {
|
|
|
- $province = District::where('pid', 0)->where('status', 1)->where('id', $data['province'])->orderBy('id')->get();
|
|
|
- $province = $province->toArray();
|
|
|
- if (!empty($province)) {
|
|
|
- $citys = District::where('pid', $data['province'])->where('status', 1)->orderBy('id')->get();
|
|
|
- if (!empty($citys) && isset($data['city']) && !empty($data['city'])) {
|
|
|
- // $province = $province->toArray();
|
|
|
- $province_id = [];
|
|
|
- foreach ($province as $val) {
|
|
|
- array_push($province_id, $val['id']);
|
|
|
- }
|
|
|
- // var_dump($province_id);
|
|
|
- $city = District::whereIn('pid', $province_id)->where('status', 1)->where('id', $data['city'])->orderBy('id')->get();
|
|
|
- if (!empty($city)) {
|
|
|
- $city_id = [];
|
|
|
- foreach ($city as $val) {
|
|
|
- array_push($city_id, $val['id']);
|
|
|
- }
|
|
|
- $regions = District::whereIn('pid', $city_id)->where('status', 1)->orderBy('id')->get();
|
|
|
-
|
|
|
- $result = [
|
|
|
- 'province' => $province,
|
|
|
- 'city' => $city,
|
|
|
- 'region' => $regions
|
|
|
- ];
|
|
|
- } else {
|
|
|
- return Result::error("未查询到此城市", 0);
|
|
|
- }
|
|
|
- } else {
|
|
|
- $result = [
|
|
|
- 'province' => $province,
|
|
|
- 'city' => $citys,
|
|
|
- 'region' => null
|
|
|
- ];
|
|
|
- }
|
|
|
- } else {
|
|
|
- return Result::error("未查询到此省份", 0);
|
|
|
- }
|
|
|
- } else {
|
|
|
- // $keys = array('data');
|
|
|
- $result = $provinces;
|
|
|
- }
|
|
|
- return Result::success($result);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取栏目
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function getWebsiteModelCategory(array $data): array
|
|
|
- {
|
|
|
- $website_id = [
|
|
|
- 'website_id' => $data['website_id']
|
|
|
- ];
|
|
|
- $placeid = $data['placeid'] - 1;
|
|
|
- $pid = [
|
|
|
- 'pid' => $data['pid'],
|
|
|
- ];
|
|
|
- $num = $data['num'];
|
|
|
-
|
|
|
- $result = WebsiteCategory::where($website_id)->where($pid)->orderBy('sort')->offset($placeid)->limit($num)->get();
|
|
|
- $result = $result->toArray();
|
|
|
- if (!empty($result)) {
|
|
|
- return Result::success($result);
|
|
|
- } else {
|
|
|
- return Result::error("本网站暂无栏目", 0);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- /**
|
|
|
- *获取友情链接
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function selectWebsiteLinks(array $data): array
|
|
|
- {
|
|
|
- $where = [
|
|
|
- 'website_id' => $data['website_id'],
|
|
|
- 'status' => 1,
|
|
|
- 'type' => $data['type']
|
|
|
- ];
|
|
|
- $num=$data['num'];
|
|
|
- $result=Link::where($where)->orderBy('id')->limit($num)->get();
|
|
|
- if(!empty($result)){
|
|
|
- return Result::success($result);
|
|
|
- }else{
|
|
|
- return Result::error("本网站暂无此类型友情链接",0);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
/**
|
|
|
* 网站首页数据统计, 管理员
|
|
|
* @return void
|
|
@@ -733,7 +535,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
public function addTemplateClass(array $data): array
|
|
|
{
|
|
|
$insertData = [
|
|
|
- 'name' => $data['name']
|
|
|
+ 'name' => $data['name'],
|
|
|
];
|
|
|
$result = TemplateClass::insertGetId($insertData);
|
|
|
if (empty($result)) {
|
|
@@ -751,10 +553,10 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
public function upTemplateClass(array $data): array
|
|
|
{
|
|
|
$where = [
|
|
|
- 'id' => $data['id']
|
|
|
+ 'id' => $data['id'],
|
|
|
];
|
|
|
$insertData = [
|
|
|
- 'name' => $data['name']
|
|
|
+ 'name' => $data['name'],
|
|
|
];
|
|
|
$result = TemplateClass::where($where)->update($insertData);
|
|
|
if (empty($result)) {
|
|
@@ -772,7 +574,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
public function delTemplateClass(array $data): array
|
|
|
{
|
|
|
$where = [
|
|
|
- 'id' => $data['id']
|
|
|
+ 'id' => $data['id'],
|
|
|
];
|
|
|
|
|
|
$result = TemplateClass::where($where)->delete();
|
|
@@ -804,7 +606,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
$data = [
|
|
|
'rows' => $result->toArray(),
|
|
|
- 'count' => $count
|
|
|
+ 'count' => $count,
|
|
|
];
|
|
|
return Result::success($data);
|
|
|
}
|
|
@@ -837,7 +639,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
public function upTemplate(array $data): array
|
|
|
{
|
|
|
$where = [
|
|
|
- 'id' => $data['id']
|
|
|
+ 'id' => $data['id'],
|
|
|
];
|
|
|
$insertData = [
|
|
|
'template_name' => $data['template_name'],
|
|
@@ -860,7 +662,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
public function delTemplate(array $data): array
|
|
|
{
|
|
|
$where = [
|
|
|
- 'id' => $data['id']
|
|
|
+ 'id' => $data['id'],
|
|
|
];
|
|
|
$result = Template::where($where)->delete();
|
|
|
if (empty($result)) {
|
|
@@ -940,7 +742,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 删除网站导航
|
|
|
* @param array $data
|
|
@@ -969,7 +770,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
{
|
|
|
$where = [
|
|
|
'website_id' => $data['website_id'],
|
|
|
- 'pid' => 0
|
|
|
+ 'pid' => 0,
|
|
|
];
|
|
|
$result = WebsiteCategory::where($where)->get();
|
|
|
if ($result) {
|
|
@@ -1075,31 +876,31 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
public function getWebsiteCategoryList(array $data): array
|
|
|
{
|
|
|
$where = [];
|
|
|
- if(isset($data['keyword']) && !empty($data['keyword'])){
|
|
|
- array_push($where,['website.website_name','like','%'.$data['keyword'].'%']);
|
|
|
+ if (isset($data['keyword']) && !empty($data['keyword'])) {
|
|
|
+ array_push($where, ['website.website_name', 'like', '%' . $data['keyword'] . '%']);
|
|
|
}
|
|
|
- if(isset($data['website_column_id']) && !empty($data['website_column_id'])){
|
|
|
- array_push($where,['website.website_column_id','=',$data['website_column_id']]);
|
|
|
+ if (isset($data['website_column_id']) && !empty($data['website_column_id'])) {
|
|
|
+ array_push($where, ['website.website_column_id', '=', $data['website_column_id']]);
|
|
|
}
|
|
|
$result = Website::where($where)
|
|
|
- ->with(["websiteCategory"=>function ($query) {
|
|
|
- $query->where(['pid'=>0])->select('website_id','name','alias','category_id');
|
|
|
+ ->with(["websiteCategory" => function ($query) {
|
|
|
+ $query->where(['pid' => 0])->select('website_id', 'name', 'alias', 'category_id');
|
|
|
}])
|
|
|
- ->limit($data['pageSize'])->orderBy("updated_at","desc")->offset(($data['page']-1)*$data['pageSize'])
|
|
|
+ ->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
->get();
|
|
|
|
|
|
$count = Website::where($where)->count();
|
|
|
if (empty($result)) {
|
|
|
- return Result::error("没有数据",0);
|
|
|
+ return Result::error("没有数据", 0);
|
|
|
}
|
|
|
$data = [
|
|
|
- 'rows'=>$result->toArray(),
|
|
|
- 'count'=>$count
|
|
|
+ 'rows' => $result->toArray(),
|
|
|
+ 'count' => $count,
|
|
|
];
|
|
|
- if($result){
|
|
|
+ if ($result) {
|
|
|
return Result::success($data);
|
|
|
- }else{
|
|
|
- return Result::error("查询失败",0);
|
|
|
+ } else {
|
|
|
+ return Result::error("查询失败", 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1197,7 +998,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
$data = [
|
|
|
'rows' => $result->toArray(),
|
|
|
- 'count' => $count
|
|
|
+ 'count' => $count,
|
|
|
];
|
|
|
if ($result) {
|
|
|
return Result::success($data);
|
|
@@ -1258,7 +1059,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
return Result::success($websiteInfo->toArray());
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 检测网站url是否重复
|
|
|
* @param array $data
|
|
@@ -1277,28 +1077,16 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
return Result::success($websiteInfo->toArray());
|
|
|
}
|
|
|
- /**
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取并搜索 网站模板信息
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function getWebsiteTemplateintel(array $data): array
|
|
|
+ public function getWebsiteintel(array $data): array
|
|
|
{
|
|
|
- $where = []; // 初始化 $where 数组
|
|
|
- //若存在条件;则在$rep的基础上进行筛选
|
|
|
- if(isset($data['website_name'])){
|
|
|
- array_push($where, ['website.website_name','like','%'.$data['website_name'].'%']);
|
|
|
- }
|
|
|
- if(isset($data['status'])){
|
|
|
- if($data['status'] == 0){
|
|
|
- array_push($where, ['website_template_info.status','=',null]);
|
|
|
- }else{
|
|
|
- array_push($where, ['website_template_info.status','=',$data['status']]);
|
|
|
- }
|
|
|
- }
|
|
|
//查询所有网站模板信息
|
|
|
- if(empty($where)){
|
|
|
- $rep = Website::where('website.status', 1)
|
|
|
+ $query = Website::where('website.status', 1)
|
|
|
->leftJoin("website_template_info", "website_template_info.website_id", "website.id")
|
|
|
->leftJoin("template", "template.id", "website_template_info.template_id")
|
|
|
->select(
|
|
@@ -1307,46 +1095,33 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
"website_template_info.id as tid",
|
|
|
"website_template_info.created_at",
|
|
|
"website_template_info.updated_at",
|
|
|
- "website_template_info.page_type",
|
|
|
- DB::raw("COALESCE(website_template_info.status, 0) as template_status"),
|
|
|
- "template.template_name"
|
|
|
- )
|
|
|
- ->limit($data['pageSize'])
|
|
|
- ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
- ->orderBy("website_template_info.updated_at", "asc")
|
|
|
- ->get();
|
|
|
- }else{
|
|
|
- $rep = Website::where($where)
|
|
|
- ->where('website.status', 1)
|
|
|
- ->leftJoin("website_template_info", "website_template_info.website_id", "website.id")
|
|
|
- ->leftJoin("template", "template.id", "website_template_info.template_id")
|
|
|
- ->select(
|
|
|
- "website.website_name",
|
|
|
- "website.website_url",
|
|
|
- "website_template_info.id as tid",
|
|
|
- "website_template_info.created_at",
|
|
|
- "website_template_info.updated_at",
|
|
|
- "website_template_info.page_type",
|
|
|
+ "website_template_info.page_type",
|
|
|
DB::raw("COALESCE(website_template_info.status, 0) as template_status"),
|
|
|
"template.template_name"
|
|
|
)
|
|
|
->limit($data['pageSize'])
|
|
|
->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
- ->orderBy("website_template_info.updated_at", "asc")
|
|
|
- ->get();
|
|
|
-
|
|
|
+ ->orderBy("website_template_info.updated_at", "asc");
|
|
|
+ //若存在条件;则在$query的基础上进行筛选
|
|
|
+ if (isset($data['website_name'])) {
|
|
|
+ $query->where('website.website_name', 'like', '%' . $data['website_name'] . '%');
|
|
|
}
|
|
|
- $result = [
|
|
|
- "rows" => $rep->toArray(),
|
|
|
- "count" => $rep->count()
|
|
|
- ];
|
|
|
- if($rep->count()==0){
|
|
|
- return Result::error("没有查找到相关数据",0);
|
|
|
+ if (isset($data['status'])) {
|
|
|
+ $query->where('website_template_info.status', $data['status']);
|
|
|
+ }
|
|
|
+ $rep = $query->get();
|
|
|
+ if ($rep->count() == 0) {
|
|
|
+ return Result::error("没有查找到相关数据", 0);
|
|
|
} else {
|
|
|
- return Result::success($result); // 返回结果应该是 $result,而不是 $where
|
|
|
+ $result = [
|
|
|
+ "rows" => $rep->toArray(),
|
|
|
+ "count" => $rep->count(),
|
|
|
+ ];
|
|
|
+ return Result::success($result);
|
|
|
}
|
|
|
// return Result::success($result);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 添加网站基础信息
|
|
|
* @param array $data
|
|
@@ -1354,363 +1129,271 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
*/
|
|
|
public function addWebsiteTemplateintel(array $data): array
|
|
|
{
|
|
|
- $website = Website::where('website.id',$data['website_id'])->first();
|
|
|
- if(empty($website)){
|
|
|
- $message = "请输入正确的网站id!";
|
|
|
- }else{
|
|
|
- if(empty($website['website_column_id'])){
|
|
|
- $message = "请先关联导航池!";
|
|
|
- }
|
|
|
- if(isset($data['page_type'])){
|
|
|
- if (in_array(1, $data['page_type']) && in_array(7, $data['page_type'])) {
|
|
|
- // 数组中同时包含值为 1(首页) 和值为 7 (底部导航详情页)的元素
|
|
|
- // $result = 'yes';
|
|
|
- $data['page_type'] = json_encode($data['page_type'])??''; // 将数组转换为 JSON 字符串
|
|
|
+ $website = Website::where('website.id', $data['website_id'])->first();
|
|
|
+ if (empty($website)) {
|
|
|
+ return Result::error("请输入正确的网站id!", 0);
|
|
|
+ }
|
|
|
+ if (empty($website['website_column_id'])) {
|
|
|
+ return Result::error("请先关联导航池!", 0);
|
|
|
+ }
|
|
|
+ if (isset($data['page_type'])) {
|
|
|
+ // 删除重复元素并重新索引数组
|
|
|
+ $data['page_type'] = array_unique($data['page_type']);
|
|
|
+ $data['page_type'] = array_values($data['page_type']);
|
|
|
+ if (in_array(1, $data['page_type']) && in_array(7, $data['page_type'])) {
|
|
|
+ // 数组中同时包含值为 1(首页) 和值为 7 (底部导航详情页)的元素
|
|
|
+ $info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
|
+ if (empty($info)) {
|
|
|
+ // 将数组转换为 JSON 字符串
|
|
|
+ $data['page_type'] = json_encode($data['page_type']) ?? '';
|
|
|
$result = WebsiteTemplateInfo::insertGetId($data);
|
|
|
} else {
|
|
|
- $message = "请先选择首页和底部导航详情页!";
|
|
|
+ return Result::error("该网站已经存在首页和底部导航详情页!", 0);
|
|
|
}
|
|
|
- }else{
|
|
|
- $footer = FooterCategory::where('website_id',$data['website_id'])->select('type')->get();
|
|
|
- if(empty($footer)){
|
|
|
- $types = '2';
|
|
|
- }else{
|
|
|
- $types = 2;
|
|
|
- foreach ($footer as $v) {
|
|
|
- if ($v['type'] == 1) {
|
|
|
- $types = 1;
|
|
|
- } else {
|
|
|
- $types = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- $result['type'] = $types;
|
|
|
+ } else {
|
|
|
+ return Result::error("请先选择首页和底部导航详情页!", 0);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 获取此网站的底部导航 类型 type: 0:内容型底部导航(只有一条详情内容);1:列表型底部导航(可以有多条详情内容)
|
|
|
+ $foot_type = FooterCategory::where('website_id', $data['website_id'])->pluck('type')->toArray();
|
|
|
+ if (empty($foot_type)) {
|
|
|
+ return Result::error("请先关联导航池!", 0);
|
|
|
+ } elseif (in_array(1, $foot_type)) {
|
|
|
+ $foot_type = 1;
|
|
|
+ } else {
|
|
|
+ $foot_type = 0;
|
|
|
+ }
|
|
|
+ $result['foot_type'] = $foot_type;
|
|
|
+ // 友情链接类型'1:图片 2:文字 3:底部';
|
|
|
+ $types = Link::where('website_id', $data['website_id'])->pluck('type')->toArray();
|
|
|
+ $missingTypes = [];
|
|
|
+ if (!in_array(1, $types)) {
|
|
|
+ $missingTypes[] = "文字链接";
|
|
|
+ }
|
|
|
+ if (!in_array(2, $types)) {
|
|
|
+ $missingTypes[] = "图片链接";
|
|
|
+ }
|
|
|
+ if (!in_array(3, $types)) {
|
|
|
+ $missingTypes[] = "底部链接";
|
|
|
+ }
|
|
|
+ if (!empty($missingTypes)) {
|
|
|
+ $errorMessage = "请先添加 " . implode(" 和 ", $missingTypes) . "!";
|
|
|
+ return Result::error($errorMessage, 0);
|
|
|
}
|
|
|
}
|
|
|
- if(empty($result)){
|
|
|
- return Result::error($message,0);
|
|
|
- }else{
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("添加失败!", 0);
|
|
|
+ } else {
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
}
|
|
|
- /**
|
|
|
- * 获取所有网站风格信息
|
|
|
+ /**
|
|
|
+ * 获取网站基础信息
|
|
|
*
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function getAllTemplateClass(array $data): array
|
|
|
+ public function getWebsiteTemplateintel(array $data): array
|
|
|
{
|
|
|
- $result = TemplateClass::all();
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("没有查找到相关数据!",0);
|
|
|
- }else{
|
|
|
+ $result = WebsiteTemplateInfo::where('website_template_info.id', $data['id'])
|
|
|
+ ->leftJoin('footer_category', 'footer_category.website_id', 'website_template_info.website_id')
|
|
|
+ ->select(
|
|
|
+ "website_template_info.*",
|
|
|
+ "footer_category.type",
|
|
|
+ )
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ if ($result) {
|
|
|
+ $result['page_type'] = json_decode($result['page_type'], true);
|
|
|
return Result::success($result);
|
|
|
+ } else {
|
|
|
+ return Result::error("请先添加网站基础信息!", 0);
|
|
|
}
|
|
|
}
|
|
|
- /**
|
|
|
- * 获取网站模板信息
|
|
|
- * @param array $data
|
|
|
+ /**
|
|
|
+ * 修改网站基础信息
|
|
|
+ *
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function getWebsiteTemplateList(array $data): array
|
|
|
+ public function upWebsiteTemplateintel(array $data): array
|
|
|
{
|
|
|
- $website = Website::where('website.id',$data['website_id'])->first();
|
|
|
- if(empty($website)){
|
|
|
- $message = "请输入正确的网站id!";
|
|
|
- }else{
|
|
|
- $page_type = WebsiteTemplateInfo::where('website_id',$data['website_id'])->select('page_type')->first();
|
|
|
- $where = json_decode($page_type['page_type'], true);
|
|
|
- // $where = $data["page_type"];
|
|
|
- if(isset($data['template_class_id'])){
|
|
|
- $template_class = TemplateClass::where('id',$data['template_class_id'])->first();
|
|
|
- if(empty($template_class)){
|
|
|
- $message = "请输入正确的模板风格id!";
|
|
|
- }else{
|
|
|
- // 获取指定风格下的模板
|
|
|
- $rep = Template::where('template_class_id', $data['template_class_id'])
|
|
|
- ->where(function ($query) use ($where) {
|
|
|
- foreach ($where as $value) {
|
|
|
- $query->whereJsonContains('template_img', ['value' => $value]);
|
|
|
- }
|
|
|
- })
|
|
|
- ->leftJoin('template_class','template_class.id','template.template_class_id')
|
|
|
- ->select('template.*','template_class.name')
|
|
|
- ->limit($data['pageSize'])
|
|
|
- ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
- ->orderBy("template.updated_at", "desc")
|
|
|
- ->get();
|
|
|
- }
|
|
|
- }else{
|
|
|
- //获取所有模板
|
|
|
- $rep = Template::where(function ($query) use ($where) {
|
|
|
- foreach ($where as $value) {
|
|
|
- $query->whereJsonContains('template_img', ['value' => $value]);
|
|
|
- }
|
|
|
- })
|
|
|
- ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
- ->limit($data['pageSize'])
|
|
|
- ->orderBy("template.updated_at", "desc")
|
|
|
- ->get();
|
|
|
- }
|
|
|
- if(empty($rep->toArray())){
|
|
|
- $message = "没有查找到相关数据!";
|
|
|
- }else{
|
|
|
- $result = [
|
|
|
- "rows" => $rep->toArray(),
|
|
|
- "count" => $rep->count()
|
|
|
- ];
|
|
|
+ $where = ['website_id' => $data['website_id']];
|
|
|
+ $result = WebsiteTemplateInfo::where($where)->first();
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("请先添加网站基础信息!", 0);
|
|
|
+ } else {
|
|
|
+ unset($data['website_id']);
|
|
|
+ // 删除重复元素
|
|
|
+ $data['page_type'] = array_unique($data['page_type']);
|
|
|
+ // 重新索引数组
|
|
|
+ $data['page_type'] = array_values($data['page_type']);
|
|
|
+ // 数组中同时包含值为 1(首页) 和值为 7 (底部导航详情页)的元素
|
|
|
+ if (in_array(1, $data['page_type']) && in_array(7, $data['page_type'])) {
|
|
|
+ // 将数组转换为 JSON 字符串
|
|
|
+ $data['page_type'] = json_encode($data['page_type']) ?? '';
|
|
|
+ $result = WebsiteTemplateInfo::where($where)->update($data);
|
|
|
+ return Result::success($result);
|
|
|
+ } else {
|
|
|
+ return Result::error("请先选择首页和底部导航详情页!", 0);
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if(empty($rep)){
|
|
|
- return Result::error($message,0);
|
|
|
- }else{
|
|
|
- return Result::success($result);
|
|
|
}
|
|
|
}
|
|
|
- /**
|
|
|
- * 添加网站模板
|
|
|
- * @param array $data
|
|
|
- */
|
|
|
- public function addWebsiteTemplateclassintel(array $data): array
|
|
|
- {
|
|
|
- $template = Template::where('id',$data['template_id'])->first();
|
|
|
- $web = Website::where('id',$data['website_id'])->first();
|
|
|
- if(empty($template)){
|
|
|
- return Result::error("请输入正确的模板id",0);
|
|
|
- }
|
|
|
- if(empty($web)){
|
|
|
- return Result::error("请输入正确的网站id",0);
|
|
|
- }
|
|
|
- $result = WebsiteTemplateInfo::where('website_id',$data['website_id'])->update(['template_id' => $data['template_id']]);
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("添加失败",0);
|
|
|
- }else{
|
|
|
- return Result::success($result);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
/**
|
|
|
- * 风格下的板块
|
|
|
- * @return void
|
|
|
+ * 获取所有网站风格信息
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
*/
|
|
|
- public function templateSectorList(array $data): array
|
|
|
+ public function getAllTemplateClass(array $data): array
|
|
|
{
|
|
|
- $where = [
|
|
|
- 'template_id' => $data['template_id']
|
|
|
- ];
|
|
|
- $result = Sector::where($where)->whereJsonContains("page_type", $data['page_type'])
|
|
|
- ->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
- ->get();
|
|
|
-
|
|
|
- $count = Sector::where($where)->count();
|
|
|
- if (empty($result)) {
|
|
|
- return Result::error("没有数据", 0);
|
|
|
- }
|
|
|
- $data = [
|
|
|
- 'rows' => $result->toArray(),
|
|
|
- 'count' => $count
|
|
|
- ];
|
|
|
+ $result = TemplateClass::all();
|
|
|
if (empty($result)) {
|
|
|
- return Result::error("没有数据", 0);
|
|
|
+ return Result::error("没有查找到相关数据!", 0);
|
|
|
+ } else {
|
|
|
+ return Result::success($result);
|
|
|
}
|
|
|
- return Result::success($data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 板块下的组件
|
|
|
+ * 搜索并获取网站模板信息
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function sectorComponentList(array $data): array
|
|
|
+ public function getWebsiteTemplateList(array $data): array
|
|
|
{
|
|
|
- $where = [
|
|
|
- 'template_id' => $data['template_id'],
|
|
|
- 'sector_id' => $data['sector_id'],
|
|
|
- ];
|
|
|
- $result = Component::where($where)
|
|
|
- ->select("*")
|
|
|
- ->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
- ->get();
|
|
|
+ $website = Website::where('website.id', $data['website_id'])->first();
|
|
|
+ if (empty($website)) {
|
|
|
+ $message = "请输入正确的网站id!";
|
|
|
+ } else {
|
|
|
+ $page_type = WebsiteTemplateInfo::where('website_id', $data['website_id'])->select('page_type')->first();
|
|
|
+ if (empty($page_type)) {
|
|
|
+ $message = "此网站还未添加基础信息!";
|
|
|
+ } else {
|
|
|
+ $where = json_decode($page_type['page_type'], true);
|
|
|
+ // $where = $data["page_type"];
|
|
|
+ if (isset($data['template_class_id'])) {
|
|
|
+ $template_class = TemplateClass::where('id', $data['template_class_id'])->first();
|
|
|
+ if (empty($template_class)) {
|
|
|
+ $message = "请输入正确的模板风格id!";
|
|
|
+ } else {
|
|
|
+ // 获取指定风格下的模板
|
|
|
+ $rep = Template::where('template_class_id', $data['template_class_id'])
|
|
|
+ ->where(function ($query) use ($where) {
|
|
|
+ foreach ($where as $value) {
|
|
|
+ $query->whereJsonContains('template_img', ['value' => $value]);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->leftJoin('template_class', 'template_class.id', 'template.template_class_id')
|
|
|
+ ->select('template.*', 'template_class.name', 'template_class.id as class_id')
|
|
|
+ ->limit($data['pageSize'])
|
|
|
+ ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
+ ->orderBy("template.updated_at", "desc")
|
|
|
+ ->get();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //获取所有模板
|
|
|
+ $rep = Template::where(function ($query) use ($where) {
|
|
|
+ foreach ($where as $value) {
|
|
|
+ $query->whereJsonContains('template_img', ['value' => $value]);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
+ ->limit($data['pageSize'])
|
|
|
+ ->orderBy("template.updated_at", "desc")
|
|
|
+ ->get();
|
|
|
+ }
|
|
|
+ if (empty($rep) || $rep->count() == 0) {
|
|
|
+ $message = "没有查找到相关数据!";
|
|
|
+ } else {
|
|
|
+ // 过滤 template_img 字段 只获取 基础信息中 包含的模板图片
|
|
|
+ $rep->each(function ($item) use ($where) {
|
|
|
+ $template_img = json_decode($item->template_img, true);
|
|
|
+ $filtered_img = array_filter($template_img, function ($img) use ($where) {
|
|
|
+ return in_array($img['value'], $where);
|
|
|
+ });
|
|
|
+ $item->template_img = $filtered_img;
|
|
|
+ });
|
|
|
+ $result = [
|
|
|
+ "rows" => $rep->toArray(),
|
|
|
+ "count" => $rep->count(),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- $count = Component::where($where)->count();
|
|
|
- if (empty($result)) {
|
|
|
- return Result::error("没有数据", 0);
|
|
|
}
|
|
|
- $data = [
|
|
|
- 'rows' => $result->toArray(),
|
|
|
- 'count' => $count
|
|
|
- ];
|
|
|
- if (empty($result)) {
|
|
|
- return Result::error("没有数据", 0);
|
|
|
- }
|
|
|
- return Result::success($data);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取模板内容
|
|
|
- * @return void
|
|
|
- */
|
|
|
- public function getWebsiteTemplateInfo(array $data): array
|
|
|
- {
|
|
|
- $wehre = [
|
|
|
- "website_id" => $data['website_id']
|
|
|
- ];
|
|
|
- $result = WebsiteTemplate::where($wehre)->first();
|
|
|
- if ($result) {
|
|
|
- return Result::success($result);
|
|
|
+ if (!empty($message)) {
|
|
|
+ return Result::error($message, 0);
|
|
|
} else {
|
|
|
- return Result::error("没有数据", 0);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存网站模板
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function addWebsiteTemplate(array $data): array
|
|
|
- {
|
|
|
- var_dump("接收参数:", $data['template_data']);
|
|
|
- $result = WebsiteTemplate::updateOrInsert(['website_id' => $data['website_id']], ['template_data' => json_encode($data['template_data'])]);
|
|
|
- if ($result) {
|
|
|
return Result::success($result);
|
|
|
- } else {
|
|
|
- return Result::error("创建失败", 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 预览网站首页模板数据
|
|
|
+ * 添加网站模板
|
|
|
* @param array $data
|
|
|
- * @return array
|
|
|
*/
|
|
|
- public function getWebsiteTemplateData(array $data): array
|
|
|
+ public function addWebsiteTemplateclassintel(array $data): array
|
|
|
{
|
|
|
- $wehre = [
|
|
|
- "website_id" => $data['website_id']
|
|
|
- ];
|
|
|
- $result = WebsiteTemplate::where($wehre)->first();
|
|
|
-
|
|
|
- if ($result) {
|
|
|
- $templateData = json_decode($result['template_data'], true);
|
|
|
-// var_dump("数据:",$templateData[1]);
|
|
|
- $templateData[1] = $this->getNewsList($templateData[1]);
|
|
|
+ $template = Template::where('id', $data['template_id'])->first();
|
|
|
+ $web = Website::where('id', $data['website_id'])->first();
|
|
|
+ if (empty($template)) {
|
|
|
+ return Result::error("请输入正确的模板id", 0);
|
|
|
+ }
|
|
|
+ if (empty($web)) {
|
|
|
+ return Result::error("请输入正确的网站id", 0);
|
|
|
+ }
|
|
|
|
|
|
- return Result::success($templateData);
|
|
|
+ $result = WebsiteTemplateInfo::where('website_id', $data['website_id'])->update(['template_id' => $data['template_id']]);
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("添加失败", 0);
|
|
|
} else {
|
|
|
- return Result::error("没有数据", 0);
|
|
|
+ return Result::success($result);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
/**
|
|
|
- * 获取数据
|
|
|
- * @return void
|
|
|
+ * 获取网站模板信息
|
|
|
+ * @param array $data
|
|
|
*/
|
|
|
- public function getNewsList(array $data): array
|
|
|
+ public function getWebsiteTemplateclassintel(array $data): array
|
|
|
{
|
|
|
- if ($data) {
|
|
|
- foreach ($data as $key => $val) {
|
|
|
- if ($val) {
|
|
|
- foreach ($val['data'] as $k => $item) {
|
|
|
- if ($item['isReturn'] && intval($item['isReturn']) == 1) {
|
|
|
- $imgList = [];
|
|
|
- if ($item['data']['imgNum'] && intval($item['data']['imgNum']) > 0) {
|
|
|
- $imgList = Article::where('imgurl', "!=", "")
|
|
|
- ->where('catid', $item['data']['category_id'])
|
|
|
- ->select($item['data']['selectField'])
|
|
|
- ->orderBy("created_at", "desc")
|
|
|
- ->offset(0)
|
|
|
- ->limit(intval($item['data']['imgNum']))
|
|
|
- ->get();
|
|
|
- $imgList = $imgList->toArray();
|
|
|
- $listIds = [];
|
|
|
- if ($imgList) {
|
|
|
- $listIds = array_column($imgList, 'id');
|
|
|
- }
|
|
|
- $dataList = Article::whereNotIn('id', $listIds)
|
|
|
- ->where('catid', $item['data']['category_id'])
|
|
|
- ->select($item['data']['selectField'])
|
|
|
- ->orderBy("created_at", "desc")
|
|
|
- ->offset(0)
|
|
|
- ->limit(intval($item['data']['pageSize']) - intval($item['data']['imgNum']))
|
|
|
- ->get();
|
|
|
- $dataList = $dataList->toArray();
|
|
|
- var_dump("图片列表:", $imgList, "数据列表:", $dataList);
|
|
|
- $datas = array_merge($imgList, $dataList);
|
|
|
-// return $datas;
|
|
|
- var_dump("合并列表:", $datas);
|
|
|
- $data[$key]['data'][$k]['dataList'] = $datas;
|
|
|
- } else {
|
|
|
- $dataList = Article::where('catid', $item['data']['category_id'])
|
|
|
- ->select($item['data']['selectField'])
|
|
|
- ->orderBy("created_at", "desc")
|
|
|
- ->offset(0)
|
|
|
- ->limit(intval($item['data']['pageSize']))
|
|
|
- ->get();
|
|
|
- $dataList = $dataList->toArray();
|
|
|
- var_dump("数据列表:", $dataList);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ $template = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
|
+ if (empty($template)) {
|
|
|
+ return Result::error("请输入正确的搭建网站id", 0);
|
|
|
+ }
|
|
|
+ $page_type = json_decode($template['page_type'], true);
|
|
|
+ // 获取指定网站下的基础信息和模板及风格信息
|
|
|
+ $result = WebsiteTemplateInfo::where([
|
|
|
+ ['website_template_info.website_id', $data['website_id']],
|
|
|
+ ['template_id', '!=', null],
|
|
|
+ ])
|
|
|
+ ->leftJoin('template', 'template.id', 'website_template_info.template_id')
|
|
|
+ ->leftJoin('template_class', 'template_class.id', 'template.template_class_id')
|
|
|
+ ->where(function ($query) use ($page_type) {
|
|
|
+ // 假设 $data['page_type'] 是一个数组,包含需要匹配的 page_type 值
|
|
|
+ foreach ($page_type as $pageType) {
|
|
|
+ $query->orWhereJsonContains('template.template_img', ['value' => $pageType]);
|
|
|
}
|
|
|
-
|
|
|
+ })
|
|
|
+ ->select(
|
|
|
+ 'template.template_name',
|
|
|
+ 'template.template_img',
|
|
|
+ 'template.id as tid', 'template_class.name',
|
|
|
+ 'template_class.id as class_id',
|
|
|
+ 'website_template_info.*')
|
|
|
+ ->first();
|
|
|
+ // 过滤 template_img 字段 只获取 基础信息中 包含的模板图片
|
|
|
+ $template_img = json_decode($result['template_img'], true);
|
|
|
+ $page_type = json_decode($result['page_type'], true);
|
|
|
+ foreach ($template_img as $key => $value) {
|
|
|
+ if (!in_array($value['value'], $page_type)) {
|
|
|
+ unset($template_img[$key]);
|
|
|
}
|
|
|
}
|
|
|
- return $data;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取底部导航列表
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function getFooterCategoryList(array $data): array
|
|
|
- {
|
|
|
- $where = [
|
|
|
- "website_id" => $data['website_id']
|
|
|
- ];
|
|
|
- $result = FooterCategory::where($where)->get();
|
|
|
- if ($result) {
|
|
|
- return Result::success($result);
|
|
|
+ $result['template_img'] = $template_img;
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("没有查找到相关数据", 0);
|
|
|
} else {
|
|
|
- return Result::error("没有数据");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //获取底部导航内容列表
|
|
|
- public function getFooterContentList(array $data): array
|
|
|
- {
|
|
|
- $where = [
|
|
|
- "fcat_id" => $data['fcat_id'],
|
|
|
- ];
|
|
|
- switch (intval($data['type'])) {
|
|
|
- case 0:
|
|
|
- $result = FooterContent::where($where)->first();
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- $result = FooterContent::where($where)->get();
|
|
|
- break;
|
|
|
- }
|
|
|
- if ($result) {
|
|
|
return Result::success($result);
|
|
|
- } else {
|
|
|
- return Result::error("没有数据");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //获取底部导航内容详情
|
|
|
- public function getFooterContentInfo(array $data): array
|
|
|
- {
|
|
|
- $where = [
|
|
|
- "id" => $data['content_id']
|
|
|
- ];
|
|
|
- $result = FooterContent::where($where)->first();
|
|
|
- if ($result) {
|
|
|
- return Result::success($result);
|
|
|
- } else {
|
|
|
- return Result::error("没有数据");
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+}
|