|
@@ -5,9 +5,9 @@ use App\Model\Article;
|
|
|
|
|
|
use App\Model\Ad;
|
|
use App\Model\Ad;
|
|
use App\Model\Category;
|
|
use App\Model\Category;
|
|
-use App\Model\AdPlace;
|
|
|
|
-use App\Model\Department;
|
|
|
|
-use App\Model\District;
|
|
|
|
|
|
+use App\Model\AdPlace;
|
|
|
|
+use App\Model\Department;
|
|
|
|
+use App\Model\District;
|
|
use App\Model\FooterCategory;
|
|
use App\Model\FooterCategory;
|
|
use App\Model\FooterContent;
|
|
use App\Model\FooterContent;
|
|
use App\Model\LetterOfComplaint;
|
|
use App\Model\LetterOfComplaint;
|
|
@@ -15,6 +15,7 @@ use App\Model\Link;
|
|
use App\Model\TemplateClass;
|
|
use App\Model\TemplateClass;
|
|
use App\Model\Template;
|
|
use App\Model\Template;
|
|
use App\Model\User;
|
|
use App\Model\User;
|
|
|
|
+use App\Model\UserInfo;
|
|
use App\Model\WebsiteRole;
|
|
use App\Model\WebsiteRole;
|
|
use App\Model\WebsiteRoleUser;
|
|
use App\Model\WebsiteRoleUser;
|
|
use App\Model\Website;
|
|
use App\Model\Website;
|
|
@@ -22,14 +23,15 @@ use App\Model\WebsiteColumn;
|
|
use Hyperf\DbConnection\Db;
|
|
use Hyperf\DbConnection\Db;
|
|
use Hyperf\RpcServer\Annotation\RpcService;
|
|
use Hyperf\RpcServer\Annotation\RpcService;
|
|
use App\Tools\Result;
|
|
use App\Tools\Result;
|
|
-use Carbon\Carbon;
|
|
|
|
|
|
+use Carbon\Carbon;
|
|
use App\Model\WebsiteCategory;
|
|
use App\Model\WebsiteCategory;
|
|
use App\Model\WebsiteTemplate;
|
|
use App\Model\WebsiteTemplate;
|
|
use App\Model\WebsiteTemplateInfo;
|
|
use App\Model\WebsiteTemplateInfo;
|
|
use Hamcrest\Arrays\IsArray;
|
|
use Hamcrest\Arrays\IsArray;
|
|
use PhpParser\Node\Stmt\Return_;
|
|
use PhpParser\Node\Stmt\Return_;
|
|
-
|
|
|
|
|
|
+use App\Model\WebsiteGroup;
|
|
use function PHPUnit\Framework\isNull;
|
|
use function PHPUnit\Framework\isNull;
|
|
|
|
+
|
|
// use Illuminate\Support\Facades\DB;
|
|
// use Illuminate\Support\Facades\DB;
|
|
#[RpcService(name: "WebsiteService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
#[RpcService(name: "WebsiteService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
class WebsiteService implements WebsiteServiceInterface
|
|
class WebsiteService implements WebsiteServiceInterface
|
|
@@ -42,24 +44,22 @@ class WebsiteService implements WebsiteServiceInterface
|
|
*/
|
|
*/
|
|
public function getWebsitetList(array $data): array
|
|
public function getWebsitetList(array $data): array
|
|
{
|
|
{
|
|
- $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")
|
|
|
|
|
|
+ $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")
|
|
->leftJoin("district", "district.id", "website.city_id")
|
|
->select("website.*", "website_column.column_name", "district.name as city_name")
|
|
->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();
|
|
->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->orderBy("website.id", "desc")->get();
|
|
-
|
|
|
|
- $count = Website::where($where)->count();
|
|
|
|
|
|
+ $count = $resultWwhere->count();
|
|
if (empty($result)) {
|
|
if (empty($result)) {
|
|
return Result::error("没有数据", 0);
|
|
return Result::error("没有数据", 0);
|
|
}
|
|
}
|
|
@@ -78,18 +78,18 @@ class WebsiteService implements WebsiteServiceInterface
|
|
{
|
|
{
|
|
var_dump("网站数据:", $data);
|
|
var_dump("网站数据:", $data);
|
|
$insertData = [
|
|
$insertData = [
|
|
- 'website_name'=>$data['website_name'],
|
|
|
|
- 'logo'=>$data['logo']??'',
|
|
|
|
- 'website_url'=>$data['website_url']??'',
|
|
|
|
- // '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],
|
|
|
|
- 'template_id' =>$data['template_id']??0,
|
|
|
|
|
|
+ 'website_name' => $data['website_name'],
|
|
|
|
+ 'logo' => $data['logo'] ?? '',
|
|
|
|
+ 'website_url' => $data['website_url'] ?? '',
|
|
|
|
+// '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],
|
|
|
|
+ 'template_id' => $data['template_id'] ?? 0,
|
|
];
|
|
];
|
|
$result = Website::insertGetId($insertData);
|
|
$result = Website::insertGetId($insertData);
|
|
if (empty($result)) {
|
|
if (empty($result)) {
|
|
@@ -107,18 +107,18 @@ class WebsiteService implements WebsiteServiceInterface
|
|
public function updateWebsite(int $id, array $data): array
|
|
public function updateWebsite(int $id, array $data): array
|
|
{
|
|
{
|
|
$insertData = [
|
|
$insertData = [
|
|
- 'website_name'=>$data['website_name'],
|
|
|
|
- 'logo'=>$data['logo']??'',
|
|
|
|
- 'website_url'=>$data['website_url']??'',
|
|
|
|
- // '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],
|
|
|
|
- 'template_id' =>$data['template_id']??0,
|
|
|
|
|
|
+ 'website_name' => $data['website_name'],
|
|
|
|
+ 'logo' => $data['logo'] ?? '',
|
|
|
|
+ 'website_url' => $data['website_url'] ?? '',
|
|
|
|
+// '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],
|
|
|
|
+ 'template_id' => $data['template_id'] ?? 0,
|
|
];
|
|
];
|
|
$result = Website::where('id', $id)->update($insertData);
|
|
$result = Website::where('id', $id)->update($insertData);
|
|
var_dump("更新站点", $result);
|
|
var_dump("更新站点", $result);
|
|
@@ -489,48 +489,46 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
|
|
|
$where = [
|
|
$where = [
|
|
'website_id' => 1,
|
|
'website_id' => 1,
|
|
- 'id' => $data['ad_placeid']
|
|
|
|
|
|
+ 'id' => $data['ad_placeid'],
|
|
];
|
|
];
|
|
-
|
|
|
|
|
|
+
|
|
//查询这个广告位是否存在
|
|
//查询这个广告位是否存在
|
|
- $ad_place = AdPlace::where($where)->orderBy('id','asc')->first();
|
|
|
|
-
|
|
|
|
- var_dump("==========",$ad_place);
|
|
|
|
- if(empty($ad_place)){
|
|
|
|
- return Result::error("error",0);
|
|
|
|
- }else{
|
|
|
|
|
|
+ $ad_place = AdPlace::where($where)->orderBy('id', 'asc')->first();
|
|
|
|
+
|
|
|
|
+ var_dump("==========", $ad_place);
|
|
|
|
+ if (empty($ad_place)) {
|
|
|
|
+ return Result::error("error", 0);
|
|
|
|
+ } else {
|
|
$adplaceid = $ad_place['id'];
|
|
$adplaceid = $ad_place['id'];
|
|
//查找有没有广告
|
|
//查找有没有广告
|
|
- $ad=Ad::where('pid',$adplaceid['id'])->where('status',1)->orderBy('id','asc')->get();
|
|
|
|
- if(empty($ad)){
|
|
|
|
|
|
+ $ad = Ad::where('pid', $adplaceid['id'])->where('status', 1)->orderBy('id', 'asc')->get();
|
|
|
|
+ if (empty($ad)) {
|
|
//若没有生效的广告,则显示默认的缩略图
|
|
//若没有生效的广告,则显示默认的缩略图
|
|
- $result=$adplaceid;
|
|
|
|
- return Result::success($result);
|
|
|
|
- }else{
|
|
|
|
- //查找在生效时间的广告
|
|
|
|
- $today = Carbon::now();
|
|
|
|
- foreach($ad as $i)
|
|
|
|
- {
|
|
|
|
- $starttime=Carbon::parse($i['fromtime']);
|
|
|
|
- $endtime=Carbon::parse($i['totime']);
|
|
|
|
- $time=$today->between($starttime,$endtime);
|
|
|
|
- if($time)
|
|
|
|
- {
|
|
|
|
- $result=$i;
|
|
|
|
|
|
+ $result = $adplaceid;
|
|
|
|
+ return Result::success($result);
|
|
|
|
+ } else {
|
|
|
|
+ //查找在生效时间的广告
|
|
|
|
+ $today = Carbon::now();
|
|
|
|
+ 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);
|
|
|
|
|
|
+ if (empty($result)) {
|
|
|
|
+ $result = $ad;
|
|
|
|
+ return Result::success($result);
|
|
|
|
+ } else {
|
|
|
|
+ return Result::success($result);
|
|
}
|
|
}
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- *
|
|
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
* @param array $data
|
|
* @param array $data
|
|
* @return array
|
|
* @return array
|
|
*/
|
|
*/
|
|
@@ -538,81 +536,80 @@ class WebsiteService implements WebsiteServiceInterface
|
|
public function selectWebsiteDepartment(array $data): 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();
|
|
|
|
|
|
+ $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 = [
|
|
$m = [
|
|
- 'department'=>$depart,
|
|
|
|
- 'type'=>$departments,
|
|
|
|
- 'count'=>$count
|
|
|
|
- ];
|
|
|
|
|
|
+ 'department' => $depart,
|
|
|
|
+ 'type' => $departments,
|
|
|
|
+ 'count' => $count,
|
|
|
|
+ ];
|
|
}
|
|
}
|
|
-
|
|
|
|
- $result['sele'] = $m;
|
|
|
|
- return Result::success($result['sele']);
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ $result['sele'] = $m;
|
|
|
|
+ return Result::success($result['sele']);
|
|
|
|
+
|
|
}
|
|
}
|
|
- $result=$depart;
|
|
|
|
- return Result::success($result);
|
|
|
|
|
|
+ $result = $depart;
|
|
|
|
+ return Result::success($result);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 搜索地区
|
|
* 搜索地区
|
|
- * @param array $data
|
|
|
|
- * @return array
|
|
|
|
- */
|
|
|
|
- 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'])){
|
|
|
|
|
|
+ * @param array $data
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ 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 = $province->toArray();
|
|
- $province_id=[];
|
|
|
|
- foreach($province as $val){
|
|
|
|
- array_push($province_id,$val['id']);
|
|
|
|
|
|
+ $province_id = [];
|
|
|
|
+ foreach ($province as $val) {
|
|
|
|
+ array_push($province_id, $val['id']);
|
|
}
|
|
}
|
|
// var_dump($province_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']);
|
|
|
|
|
|
+ $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);
|
|
|
|
|
|
+ $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=[
|
|
|
|
|
|
+ } else {
|
|
|
|
+ $result = [
|
|
'province' => $province,
|
|
'province' => $province,
|
|
'city' => $citys,
|
|
'city' => $citys,
|
|
- 'region' => null
|
|
|
|
|
|
+ 'region' => null,
|
|
];
|
|
];
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
- return Result::error("未查询到此省份",0);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ return Result::error("未查询到此省份", 0);
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
// $keys = array('data');
|
|
// $keys = array('data');
|
|
- $result = $provinces;
|
|
|
|
- }
|
|
|
|
- return Result::success($result);
|
|
|
|
|
|
+ $result = $provinces;
|
|
|
|
+ }
|
|
|
|
+ return Result::success($result);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -621,27 +618,27 @@ class WebsiteService implements WebsiteServiceInterface
|
|
* @return array
|
|
* @return array
|
|
*/
|
|
*/
|
|
|
|
|
|
- public function getWebsiteModelCategory(array $data): array
|
|
|
|
|
|
+ public function getWebsiteModelCategory(array $data): array
|
|
{
|
|
{
|
|
- $website_id=[
|
|
|
|
- 'website_id' => $data['website_id']
|
|
|
|
|
|
+ $website_id = [
|
|
|
|
+ 'website_id' => $data['website_id'],
|
|
];
|
|
];
|
|
- $placeid=$data['placeid']-1;
|
|
|
|
- $pid=[
|
|
|
|
- 'pid' => $data['pid'],
|
|
|
|
|
|
+ $placeid = $data['placeid'] - 1;
|
|
|
|
+ $pid = [
|
|
|
|
+ 'pid' => $data['pid'],
|
|
];
|
|
];
|
|
$num = $data['num'];
|
|
$num = $data['num'];
|
|
- $result=WebsiteCategory::where($website_id)->where($pid)->withCount(['children' => function ($query) use ($website_id) {
|
|
|
|
|
|
+ $result = WebsiteCategory::where($website_id)->where($pid)->withCount(['children' => function ($query) use ($website_id) {
|
|
$query->where($website_id);
|
|
$query->where($website_id);
|
|
}])->orderBy('sort')->offset($placeid)->limit($num)->get();
|
|
}])->orderBy('sort')->offset($placeid)->limit($num)->get();
|
|
|
|
|
|
- if(!empty($result)){
|
|
|
|
- return Result::success($result);
|
|
|
|
- }else{
|
|
|
|
- return Result::error("本网站暂无栏目",0);
|
|
|
|
- }
|
|
|
|
|
|
+ if (!empty($result)) {
|
|
|
|
+ return Result::success($result);
|
|
|
|
+ } else {
|
|
|
|
+ return Result::error("本网站暂无栏目", 0);
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取友情链接
|
|
* 获取友情链接
|
|
@@ -649,23 +646,22 @@ class WebsiteService implements WebsiteServiceInterface
|
|
* @return array
|
|
* @return array
|
|
*/
|
|
*/
|
|
|
|
|
|
- public function selectWebsiteLinks(array $data): array
|
|
|
|
- {
|
|
|
|
- $where = [
|
|
|
|
- 'website_id' => $data['website_id'],
|
|
|
|
|
|
+ public function selectWebsiteLinks(array $data): array
|
|
|
|
+ {
|
|
|
|
+ $where = [
|
|
|
|
+ 'website_id' => $data['website_id'],
|
|
'status' => 1,
|
|
'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);
|
|
|
|
|
|
+ '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
|
|
* @return void
|
|
@@ -1082,7 +1078,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
->with(["websiteCategory" => function ($query) {
|
|
->with(["websiteCategory" => function ($query) {
|
|
$query->where(['pid' => 0])->select('website_id', 'name', 'alias', 'category_id');
|
|
$query->where(['pid' => 0])->select('website_id', 'name', 'alias', 'category_id');
|
|
}])
|
|
}])
|
|
- ->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
|
|
|
+ ->limit($data['pageSize'])->orderBy("updated_at", "desc")->offset(($data['page'] - 1) * $data['pageSize'])
|
|
->get();
|
|
->get();
|
|
|
|
|
|
$count = Website::where($where)->count();
|
|
$count = Website::where($where)->count();
|
|
@@ -1273,738 +1269,102 @@ class WebsiteService implements WebsiteServiceInterface
|
|
}
|
|
}
|
|
return Result::success($websiteInfo->toArray());
|
|
return Result::success($websiteInfo->toArray());
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取网站底部基础信息
|
|
|
|
- * @param array $data
|
|
|
|
- * @return array
|
|
|
|
- */
|
|
|
|
- public function getWebsiteFootInfo(array $data): array
|
|
|
|
|
|
+ //20250212 网站标识
|
|
|
|
+ public function addWebsiteGroup(array $data): array
|
|
{
|
|
{
|
|
- if(isset($data['website_id']) && !empty($data['website_id'])){
|
|
|
|
- $website = Website::where('id',$data['website_id'])->where('status',1)->first();
|
|
|
|
- if (empty($website)) {
|
|
|
|
- return Result::error("找不到网站",0);
|
|
|
|
- }
|
|
|
|
- }else{
|
|
|
|
- return Result::error("参数错误",0);
|
|
|
|
- }
|
|
|
|
- $website_foot = WebsiteTemplateInfo::where('website_id',$data['website_id'])->where('status',2)->first();
|
|
|
|
- $website_head = Website::where('id',$data['website_id'])
|
|
|
|
- ->select('id','website_name','logo','title','keywords','description')->first();
|
|
|
|
- if (empty($website_foot)) {
|
|
|
|
- return Result::error("暂无底部基础信息",0);
|
|
|
|
- }
|
|
|
|
- if (empty($website_head)) {
|
|
|
|
- return Result::error("暂无头部基础信息",0);
|
|
|
|
- }
|
|
|
|
- $result = [
|
|
|
|
- 'website_foot'=>$website_foot,
|
|
|
|
- 'website_head'=>$website_head
|
|
|
|
- ];
|
|
|
|
- return Result::success($result);
|
|
|
|
- }
|
|
|
|
- /**
|
|
|
|
- * 获取网站底部导航
|
|
|
|
- * @param array $data
|
|
|
|
- * @return array
|
|
|
|
- */
|
|
|
|
- public function getWebsiteFooterCategory(array $data): array
|
|
|
|
- {
|
|
|
|
- if(isset($data['website_id']) && !empty($data['website_id'])){
|
|
|
|
- $website = Website::where('id',$data['website_id'])->where('status',1)->first();
|
|
|
|
- if (empty($website)) {
|
|
|
|
- return Result::error("找不到网站",0);
|
|
|
|
- }
|
|
|
|
- }else{
|
|
|
|
- return Result::error("参数错误",0);
|
|
|
|
- }
|
|
|
|
- $result = FooterCategory::where('website_id',$data['website_id'])->get();
|
|
|
|
- if (empty($result)) {
|
|
|
|
- return Result::error("暂无底部导航",0);
|
|
|
|
- }
|
|
|
|
- return Result::success($result->toArray());
|
|
|
|
- }
|
|
|
|
- /**
|
|
|
|
- * 获取网站底部导航列表
|
|
|
|
- * @param array $data
|
|
|
|
- * @return array
|
|
|
|
- */
|
|
|
|
- public function getWebsiteFooterCategoryList(array $data): array
|
|
|
|
- {
|
|
|
|
- if(isset($data['website_id']) && !empty($data['website_id'])){
|
|
|
|
- $website = Website::where('id',$data['website_id'])->where('status',1)->first();
|
|
|
|
- if (empty($website)) {
|
|
|
|
- return Result::error("找不到网站",0);
|
|
|
|
- }
|
|
|
|
- }else{
|
|
|
|
- return Result::error("参数错误",0);
|
|
|
|
- }
|
|
|
|
- $footercategory = FooterCategory::where('website_id',$data['website_id'])->where('id',$data['fcat_id'])->first();
|
|
|
|
- // '底部导航类型 0:内容型;1:列表型;',
|
|
|
|
- if (!isset($footercategory['type']) || $footercategory['type'] == 0) {
|
|
|
|
- return Result::error("底部导航id错误",0);
|
|
|
|
- }else{
|
|
|
|
- $query = FooterContent::where('fcat_id',$data['fcat_id']);
|
|
|
|
- if($query->count() == 0){
|
|
|
|
- return Result::error("暂无底部导航列表",0);
|
|
|
|
- }elseif($query->count() == 1){
|
|
|
|
- $result = $query->first();
|
|
|
|
- }else{
|
|
|
|
- $result = $query->get();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return Result::success($result);
|
|
|
|
- }
|
|
|
|
- /**
|
|
|
|
- * 获取网站底部导航
|
|
|
|
- * @param array $data
|
|
|
|
- * @return array
|
|
|
|
- */
|
|
|
|
- public function getWebsiteFooterCategoryInfo(array $data): array
|
|
|
|
- {
|
|
|
|
- if(isset($data['website_id']) && !empty($data['website_id'])){
|
|
|
|
- $website = Website::where('id',$data['website_id'])->where('status',1)->first();
|
|
|
|
- if (empty($website)) {
|
|
|
|
- return Result::error("找不到网站",0);
|
|
|
|
- }
|
|
|
|
- }else{
|
|
|
|
- return Result::error("参数错误",0);
|
|
|
|
- }
|
|
|
|
- if (isset($data['type']) && $data['type'] == 0) {
|
|
|
|
- $fcatid = FooterCategory::where('website_id',$data['website_id'])->where('id',$data['fcat_id'])->first();
|
|
|
|
- if (empty($fcatid)) {
|
|
|
|
- return Result::error("底部导航id错误",0);
|
|
|
|
- }
|
|
|
|
- $result = FooterContent::where('fcat_id',$data['fcat_id'])->first();
|
|
|
|
- }else{
|
|
|
|
- $result = FooterContent::where('id',$data['fcat_id'])->first();
|
|
|
|
- }
|
|
|
|
- if (empty($result)) {
|
|
|
|
- return Result::error("暂无底部导航内容",0);
|
|
|
|
- }
|
|
|
|
- return Result::success($result);
|
|
|
|
- }
|
|
|
|
- /*
|
|
|
|
- * 搜索网站二级导航
|
|
|
|
- * @param array $data
|
|
|
|
- * @return array
|
|
|
|
- * */
|
|
|
|
- public function selectWebsiteCategory(array $data): array
|
|
|
|
- {
|
|
|
|
- if(isset($data['website_id']) &&!empty($data['website_id'])){
|
|
|
|
- $website = Website::where('id',$data['website_id'])->where('status',1)->first();
|
|
|
|
- if (empty($website)) {
|
|
|
|
- return Result::error("暂无该网站",0);
|
|
|
|
- }
|
|
|
|
- $category = WebsiteCategory::where('website_id',$data['website_id'])->where('pid',$data['pid'])->pluck('category_id')->all();
|
|
|
|
- // return Result::success($category);
|
|
|
|
- if (empty($category)) {
|
|
|
|
- // return Result::error("暂无二级导航",0);
|
|
|
|
- }
|
|
|
|
- $query = Category::whereIn('id', $category);
|
|
|
|
- if (isset($data['cityid']) && !empty($data['cityid'])) {
|
|
|
|
- $cityid = District::where('id', $data['cityid'])->first();
|
|
|
|
- if (empty($cityid)) {
|
|
|
|
- return Result::error("暂无此城市", 0);
|
|
|
|
- } else {
|
|
|
|
- $result = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->get();
|
|
|
|
- // $where[] = ['JSON_CONTAINS(city_arr_id, ?)', $data['cityid']];
|
|
|
|
- if (empty($result)) {
|
|
|
|
- return Result::error("暂无此城市下的二级导航", 0);
|
|
|
|
- }
|
|
|
|
- $city = 1;
|
|
|
|
- // var_dump("城市====================",$result);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (isset($data['department_id']) && !empty($data['department_id'])) {
|
|
|
|
- $departmentid = Department::where('id', $data['department_id'])->first();
|
|
|
|
- if (empty($departmentid)) {
|
|
|
|
- return Result::error("暂无此部门", 0);
|
|
|
|
- } else {
|
|
|
|
- $result = $query->whereRaw('JSON_CONTAINS(department_arr_id,?)', [$data['department_id']])->get();
|
|
|
|
- if (empty($result)) {
|
|
|
|
- return Result::error("暂无此部门下的二级导航", 0);
|
|
|
|
- }
|
|
|
|
- // var_dump("职能部门*******************",$result);
|
|
|
|
- $department = 1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(!empty($city) && !empty($department)){
|
|
|
|
- // var_dump("城市和职能部门----------------------",$result);
|
|
|
|
- $result = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->whereRaw('JSON_CONTAINS(department_arr_id,?)', [$data['department_id']])->get();
|
|
|
|
- }else{
|
|
|
|
- $result = $query->get();
|
|
|
|
- }
|
|
|
|
- if (empty($result)) {
|
|
|
|
- return Result::error("暂无二级导航",0);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // department_id
|
|
|
|
- }else{
|
|
|
|
- return Result::error("参数错误",0);
|
|
|
|
- }
|
|
|
|
- return Result::success($result);
|
|
|
|
- }
|
|
|
|
- /**
|
|
|
|
- * 获取网站栏目seo
|
|
|
|
- * @param array $data
|
|
|
|
- * @return array
|
|
|
|
- */
|
|
|
|
- public function getWebsiteCategoryHead(array $data): array
|
|
|
|
- {
|
|
|
|
- if(isset($data['website_id']) && !empty($data['website_id'])){
|
|
|
|
- $website = Website::where('id',$data['website_id'])->where('status',1)->first();
|
|
|
|
- if (empty($website)) {
|
|
|
|
- return Result::error("找不到网站",0);
|
|
|
|
- }
|
|
|
|
- }else{
|
|
|
|
- return Result::error("参数错误",0);
|
|
|
|
- }
|
|
|
|
- if (isset($data['catid']) && !empty($data['catid'])) {
|
|
|
|
- $fcatid = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$data['catid'])->first();
|
|
|
|
- if (empty($fcatid)) {
|
|
|
|
- return Result::error("导航id错误",0);
|
|
|
|
- }
|
|
|
|
- $result = Category::where('id',$data['catid'])->first();
|
|
|
|
- }
|
|
|
|
|
|
+ //添加信息
|
|
|
|
+ $result = WebsiteGroup::insertGetId($data);
|
|
|
|
+ var_dump($result);
|
|
if (empty($result)) {
|
|
if (empty($result)) {
|
|
- return Result::error("暂无导航",0);
|
|
|
|
- }
|
|
|
|
- return Result::success($result);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取并搜索 网站模板信息
|
|
|
|
- * @param array $data
|
|
|
|
- * @return array
|
|
|
|
- */
|
|
|
|
- public function getWebsiteintel(array $data): array
|
|
|
|
- {
|
|
|
|
- //查询所有网站模板信息
|
|
|
|
- $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")
|
|
|
|
- ->leftJoin("template_class", "template_class.id", "template.template_class_id")
|
|
|
|
- ->select(
|
|
|
|
- "website_template_info.id",
|
|
|
|
- "template_class.name",
|
|
|
|
- "website.id as website_id",
|
|
|
|
- "website.website_name",
|
|
|
|
- "website.website_url",
|
|
|
|
- "website_template_info.action_id",
|
|
|
|
- "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"
|
|
|
|
- );
|
|
|
|
- //若存在条件;则在$query的基础上进行筛选
|
|
|
|
- if(isset($data['website_name']) && !empty($data['website_name'])){
|
|
|
|
- $query->where('website.website_name', 'like', '%' . $data['website_name'] . '%');
|
|
|
|
- }
|
|
|
|
- if(isset($data['status']) && !empty($data['status'])){
|
|
|
|
- $query->where('website_template_info.status', $data['status']);
|
|
|
|
- }
|
|
|
|
- $count = $query->count();
|
|
|
|
- $query->limit($data['pageSize'])
|
|
|
|
- ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
|
- ->orderBy("website_template_info.updated_at", "desc");
|
|
|
|
- $rep = $query->get();
|
|
|
|
- if ($rep->count() == 0) {
|
|
|
|
- return Result::error("没有查找到相关数据", 0);
|
|
|
|
|
|
+ return Result::error("创建失败", 0);
|
|
} else {
|
|
} else {
|
|
- $rep->each(function ($item) {
|
|
|
|
- if (!empty($item->page_type)) {
|
|
|
|
- $pageTypeArray = json_decode($item->page_type, true);
|
|
|
|
- if (is_array($pageTypeArray)) {
|
|
|
|
- $item->page_type = $pageTypeArray;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- $result = [
|
|
|
|
- "rows" => $rep->toArray(),
|
|
|
|
- "count" => $count,
|
|
|
|
- ];
|
|
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
}
|
|
}
|
|
- // return Result::success($result);
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 添加网站基础信息
|
|
|
|
- * @param array $data
|
|
|
|
- * @return array
|
|
|
|
- */
|
|
|
|
- public function addWebsiteTemplateintel(array $data): array
|
|
|
|
|
|
+ public function getWebsiteGroupList(array $data): array
|
|
{
|
|
{
|
|
- $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);
|
|
|
|
- }
|
|
|
|
- // 获取此网站的底部导航 类型 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(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'])??'';
|
|
|
|
- // 操作状态:1:填写完成基础信息;2:选择完成模板;0:未构建
|
|
|
|
- $data['action_id'] = 1;
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- $result = WebsiteTemplateInfo::insertGetId($data);
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
- if ($e->getCode() == 22001) {
|
|
|
|
- $errorMessage = $e->getMessage();
|
|
|
|
- return Result::error("请检查表单,某个字段超出了长度限制!");
|
|
|
|
- } else {
|
|
|
|
- // 处理其他类型的数据库错误
|
|
|
|
- return Result::error("插入操作失败: " . $e->getMessage());
|
|
|
|
- }
|
|
|
|
- return Result::error("添加失败!", 0);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- return Result::error("该网站已经构建过了!", 0);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- return Result::error("请先选择首页和底部导航详情页!", 0);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (empty($result)) {
|
|
|
|
- return Result::error("添加失败!", 0);
|
|
|
|
- } else {
|
|
|
|
- return Result::success($result);
|
|
|
|
|
|
+ $where = [];
|
|
|
|
+ if (isset($data['name']) && !empty($data['name'])) {
|
|
|
|
+ array_push($where, ['website_group.name', 'like', '%' . $data['name'] . '%']);
|
|
}
|
|
}
|
|
- }
|
|
|
|
- /**
|
|
|
|
- * 获取网站基础信息
|
|
|
|
- *
|
|
|
|
- * @return array
|
|
|
|
- */
|
|
|
|
- public function getWebsiteTemplateintel(array $data): array
|
|
|
|
- {
|
|
|
|
|
|
+ $result = WebsiteGroup::where($where)
|
|
|
|
+ ->limit($data['pageSize'])->orderBy("id", "desc")->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
|
+ ->get();
|
|
|
|
|
|
- $result = WebsiteTemplateInfo::where('website_template_info.website_id',$data['website_id'])
|
|
|
|
- ->leftJoin('footer_category','footer_category.website_id','website_template_info.website_id')
|
|
|
|
- ->leftJoin('website','website.id','website_template_info.website_id')
|
|
|
|
- ->select(
|
|
|
|
- "website_template_info.*",
|
|
|
|
- "footer_category.type",
|
|
|
|
- "website.website_name",
|
|
|
|
- "website.id as website_id"
|
|
|
|
- )
|
|
|
|
- ->first();
|
|
|
|
- if(empty($result['website_name'])){
|
|
|
|
- return Result::error("请输入正确的网站id!", 0);
|
|
|
|
|
|
+ foreach ($result as $websiteGroup) {
|
|
|
|
+ $webIds = json_decode($websiteGroup->web_ids, true);
|
|
|
|
+ $websites = Website::whereIn('id', $webIds)->get();
|
|
|
|
+ $websiteNames = $websites->pluck('website_name', 'id')->toArray();
|
|
|
|
+ $websiteGroup->website_names = $websiteNames;
|
|
|
|
+ $websiteGroup->website_names1 = implode(',', array_values($websiteNames));
|
|
}
|
|
}
|
|
- if ($result) {
|
|
|
|
- $result['page_type'] = json_decode($result['page_type'], true);
|
|
|
|
- return Result::success($result);
|
|
|
|
- } else {
|
|
|
|
- return Result::error("请先添加网站基础信息!", 0);
|
|
|
|
|
|
+ $count = WebsiteGroup::where($where)->count();
|
|
|
|
+ if (empty($result)) {
|
|
|
|
+ return Result::error("没有数据", 0);
|
|
}
|
|
}
|
|
|
|
+ return Result::success(['list' => $result->toArray(), 'count' => $count]);
|
|
}
|
|
}
|
|
- /**
|
|
|
|
- * 修改网站基础信息
|
|
|
|
- *
|
|
|
|
- * @return array
|
|
|
|
- */
|
|
|
|
- public function upWebsiteTemplateintel(array $data): array
|
|
|
|
|
|
+ public function getWebsiteGroupInfo(array $data): array
|
|
{
|
|
{
|
|
- $web = Website::where('website.id', $data['website_id'])->first();
|
|
|
|
- if (empty($web)) {
|
|
|
|
- return Result::error("请输入正确的网站id!", 0);
|
|
|
|
- }
|
|
|
|
- $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'])??'';
|
|
|
|
- try {
|
|
|
|
- $result = WebsiteTemplateInfo::where($where)->update($data);
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
- if ($e->getCode() == 22001) {
|
|
|
|
- $errorMessage = $e->getMessage();
|
|
|
|
- return Result::error("请检查表单,某个字段超出了长度限制!");
|
|
|
|
- } else {
|
|
|
|
- // 处理其他类型的数据库错误
|
|
|
|
- return Result::error("修改操作失败: " . $e->getMessage());
|
|
|
|
- }
|
|
|
|
- return Result::error("修改失败!", 0);
|
|
|
|
- }
|
|
|
|
- }else{
|
|
|
|
- return Result::error("请先选择首页和底部导航详情页!",0);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (empty($result)) {
|
|
|
|
- return Result::error("修改失败!", 0);
|
|
|
|
- } else {
|
|
|
|
- return Result::success($result);
|
|
|
|
|
|
+ $websiteInfo = WebsiteGroup::query()->where('id', $data['id'])->first();
|
|
|
|
+ $webIds = json_decode($websiteInfo->web_ids, true);
|
|
|
|
+ $websites = Website::whereIn('id', $webIds)->get();
|
|
|
|
+ $websiteNames = $websites->pluck('website_name', 'id')->toArray();
|
|
|
|
+ $websiteInfo->website_names = $websiteNames;
|
|
|
|
+ $websiteInfo->website_names1 = implode(',', array_values($websiteNames));
|
|
|
|
+ if (empty($websiteInfo)) {
|
|
|
|
+ return Result::error("找不到URL", 0);
|
|
}
|
|
}
|
|
|
|
+ return Result::success($websiteInfo->toArray());
|
|
}
|
|
}
|
|
- /**
|
|
|
|
- * 获取所有网站风格信息
|
|
|
|
- *
|
|
|
|
- * @return array
|
|
|
|
- */
|
|
|
|
- public function getAllTemplateClass(array $data): array
|
|
|
|
|
|
+ public function updateWebsiteGroup(array $data): array
|
|
{
|
|
{
|
|
- $result = TemplateClass::all();
|
|
|
|
|
|
+ $where = [
|
|
|
|
+ 'id' => $data['id'],
|
|
|
|
+ ];
|
|
|
|
+ $insertData = [
|
|
|
|
+ 'name' => $data['name'],
|
|
|
|
+ 'web_ids' => $data['web_ids'],
|
|
|
|
+ ];
|
|
|
|
+ $result = WebsiteGroup::where($where)->update($insertData);
|
|
|
|
+ var_dump($result, '------更新');
|
|
if (empty($result)) {
|
|
if (empty($result)) {
|
|
- return Result::error("没有查找到相关数据!", 0);
|
|
|
|
|
|
+ return Result::error("更新失败", 0);
|
|
} else {
|
|
} else {
|
|
- return Result::success($result);
|
|
|
|
|
|
+ return Result::success();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- /**
|
|
|
|
- * 获取模板内容
|
|
|
|
- * @return void
|
|
|
|
- */
|
|
|
|
- public function getWebsiteTemplateInfo(array $data): array //丢了
|
|
|
|
|
|
+ public function deleteWebsiteGroup(array $data): array
|
|
{
|
|
{
|
|
- $wehre = [
|
|
|
|
- "website_id" =>$data['website_id']
|
|
|
|
|
|
+ $where = [
|
|
|
|
+ 'id' => $data['id'],
|
|
];
|
|
];
|
|
- $result = WebsiteTemplate::where($wehre)->first();
|
|
|
|
- if($result){
|
|
|
|
- return Result::success($result);
|
|
|
|
- }else{
|
|
|
|
- return Result::error("没有数据",0);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- /**
|
|
|
|
- * 搜索并获取网站模板信息
|
|
|
|
- * @param array $data
|
|
|
|
- * @return array
|
|
|
|
- */
|
|
|
|
- public function getWebsiteTemplateList(array $data): array
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- $website = Website::where('website.id',$data['website_id'])->first();
|
|
|
|
- if(empty($website)){
|
|
|
|
- return Result::error("请输入正确的网站id!",0);
|
|
|
|
- }else{
|
|
|
|
- $page_type = WebsiteTemplateInfo::where('website_id',$data['website_id'])->select('page_type')->first();
|
|
|
|
- if(empty($page_type)){
|
|
|
|
- return Result::error("此网站还未添加基础信息!",0);
|
|
|
|
- } else{
|
|
|
|
- $where = json_decode($page_type['page_type'], true);
|
|
|
|
- // $where = $data["page_type"];
|
|
|
|
- if(isset($data['template_class_id']) && !empty($data['template_class_id'])){
|
|
|
|
- $template_class = TemplateClass::where('id',$data['template_class_id'])->first();
|
|
|
|
- if(empty($template_class)){
|
|
|
|
- return Result::error("请输入正确的模板风格id!",0);
|
|
|
|
- }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]);
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- ->limit($data['pageSize'])
|
|
|
|
- ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
|
- ->orderBy("template.updated_at", "desc")
|
|
|
|
- ->get();
|
|
|
|
- $count = Template::where('template_class_id', $data['template_class_id'])
|
|
|
|
- ->where(function ($query) use ($where) {
|
|
|
|
- foreach ($where as $value) {
|
|
|
|
- $query->whereJsonContains('template_img', ['value' => $value]);
|
|
|
|
- }
|
|
|
|
- })->count();
|
|
|
|
- }
|
|
|
|
- }else{
|
|
|
|
-
|
|
|
|
- //获取所有模板
|
|
|
|
- $rep = Template::where(function ($query) use ($where) {
|
|
|
|
- foreach ($where as $value) {
|
|
|
|
- $query->whereJsonContains('template_img', ['value' => $value]);
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- ->limit($data['pageSize'])
|
|
|
|
- ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
|
- ->orderBy("template.updated_at", "desc")
|
|
|
|
- ->get();
|
|
|
|
- $count = Template::where(function ($query) use ($where) {
|
|
|
|
- foreach ($where as $value) {
|
|
|
|
- $query->whereJsonContains('template_img', ['value' => $value]);
|
|
|
|
- }
|
|
|
|
- })->count();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- if(empty($rep) || $rep->count()==0){
|
|
|
|
- return Result::error("没有查找到相关数据!",0);
|
|
|
|
- }else{
|
|
|
|
- // 过滤 template_img 字段 只获取 基础信息中 包含的模板图片
|
|
|
|
- // $rep->each(function ($item) use ($where) {
|
|
|
|
- // $template_img = json_decode($item->template_img, true);
|
|
|
|
- // if(is_array($template_img)){
|
|
|
|
- // $filtered_img = array_filter($template_img, function ($img) use ($where) {
|
|
|
|
- // return isset($img['value']) && in_array($img['value'], $where);
|
|
|
|
- // });
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // $item->template_img = $filtered_img;
|
|
|
|
- // });
|
|
|
|
- // $result = [
|
|
|
|
- // "rows" => $rep->toArray(),
|
|
|
|
- // "count" => $count
|
|
|
|
- // ];
|
|
|
|
- $rep->each(function ($item) use ($where) {
|
|
|
|
- $template_img = json_decode($item->template_img, true);
|
|
|
|
- if (is_array($template_img)) {
|
|
|
|
- $filtered_img = array_filter($template_img, function ($img) use ($where) {
|
|
|
|
- return isset($img['value']) && in_array($img['value'], $where);
|
|
|
|
- });
|
|
|
|
- // 对过滤后的数组进行重新排序
|
|
|
|
- $sorted_img = array_values($filtered_img);
|
|
|
|
- $item->template_img = $sorted_img;
|
|
|
|
- } else {
|
|
|
|
- $item->template_img = []; // 如果无法解码为数组,则设置为空数组
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- $result = [
|
|
|
|
- "rows" => $rep->toArray(),
|
|
|
|
- "count" => $count,
|
|
|
|
- ];
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- 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);
|
|
|
|
|
|
+ //看看user表是不是有这个id
|
|
|
|
+ $userGroup = User::query()->where('sszq', $data['id'])->first();
|
|
|
|
+ if (!empty($userGroup)) {
|
|
|
|
+ return Result::error("有用户在使用该网站标识,不能删除", 0);
|
|
}
|
|
}
|
|
-
|
|
|
|
- $result = WebsiteTemplateInfo::where('website_id',$data['website_id'])->update(['template_id'=>$data['template_id'],'action_id'=>2]);
|
|
|
|
- if(empty($result)){
|
|
|
|
- return Result::error("添加失败",0);
|
|
|
|
- }else{
|
|
|
|
- return Result::success($result);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- /**
|
|
|
|
- * 获取网站模板信息
|
|
|
|
- * @param array $data
|
|
|
|
- */
|
|
|
|
- public function getWebsiteTemplateclassintel(array $data): array
|
|
|
|
- {
|
|
|
|
- $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.page_type',
|
|
|
|
- 'website_template_info.website_id')
|
|
|
|
- ->first();
|
|
|
|
-
|
|
|
|
- if(empty($result)){
|
|
|
|
- return Result::error("没有查找到相关数据",0);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // return Result::success($result);
|
|
|
|
- // 过滤 template_img 字段 只获取 基础信息中 包含的模板图片
|
|
|
|
- $template_img = $result['template_img'] !== null ? json_decode($result['template_img'], true) : [];
|
|
|
|
- $page_type = $result['page_type'] !== null ? json_decode($result['page_type'], true) : [];
|
|
|
|
- foreach ($template_img as $key => $value) {
|
|
|
|
- if (!in_array($value['value'], $page_type)) {
|
|
|
|
- unset($template_img[$key]);
|
|
|
|
- }
|
|
|
|
|
|
+ $result = WebsiteGroup::where($where)->delete();
|
|
|
|
+ if (empty($result)) {
|
|
|
|
+ return Result::error("删除失败", 0);
|
|
|
|
+ } else {
|
|
|
|
+ return Result::success();
|
|
}
|
|
}
|
|
- // return Result::success($result);
|
|
|
|
- $result['template_img'] = array_values($template_img);
|
|
|
|
- $result['page_type'] = $page_type;
|
|
|
|
-
|
|
|
|
- // $templateList = $this->getWebsiteTemplateList($data);
|
|
|
|
- // $count = $templateList['data']['count']??'';
|
|
|
|
- // $pages = $count / $data['pageSize'];
|
|
|
|
- // $found = false;
|
|
|
|
- // while ($pages && !$found) {
|
|
|
|
- // $templates = $this->getWebsiteTemplateList($pages,$data['pageSize']);
|
|
|
|
- // $index = array_search($template['template_id'], array_column($templates['rows'], 'id'));
|
|
|
|
- // if ($index !== false) {
|
|
|
|
- // $found = true;
|
|
|
|
- // $result['page'] = $pages;
|
|
|
|
- // $pages = 0;
|
|
|
|
- // // echo "查询到的 template 在第 $page 页";
|
|
|
|
- // }
|
|
|
|
- // $pages--;
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- return Result::success($result);
|
|
|
|
}
|
|
}
|
|
- /**
|
|
|
|
- * 保存网站模板
|
|
|
|
- * @param array $data
|
|
|
|
- * @return array
|
|
|
|
- */
|
|
|
|
- public function addWebsiteTemplate(array $data): array
|
|
|
|
|
|
+ public function getWebsiteNavList(array $data): array
|
|
{
|
|
{
|
|
- $result = WebsiteTemplate::updateOrInsert(['website_id'=>$data['webSiteData']['base']['websiteId']],['template_data'=>json_encode($data['webSiteData']),'updated_at'=>date("Y-m-d H:i:s",time())]);
|
|
|
|
- if($result){
|
|
|
|
- return Result::success($result);
|
|
|
|
- }else{
|
|
|
|
- return Result::error("创建失败",0);
|
|
|
|
|
|
+ $where = [];
|
|
|
|
+ if (isset($data['website_id']) && !empty($data['website_id'])) {
|
|
|
|
+ array_push($where, ['website_id', '=', $data['website_id']]);
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 预览网站首页模板数据
|
|
|
|
- * @param array $data
|
|
|
|
- * @return array
|
|
|
|
- */
|
|
|
|
- public function getWebsiteTemplateData(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]);
|
|
|
|
-
|
|
|
|
- return Result::success($templateData);
|
|
|
|
- }else{
|
|
|
|
- return Result::error("没有数据",0);
|
|
|
|
|
|
+ if (isset($data['pid']) && !empty($data['pid'])) {
|
|
|
|
+ array_push($where, ['pid', '=', $data['pid']]);
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取列表数据
|
|
|
|
- * @return void
|
|
|
|
- */
|
|
|
|
- public function getNewsList(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);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ $list = WebsiteCategory::query()->where($where)->get();
|
|
|
|
+ if (empty($list)) {
|
|
|
|
+ return Result::error("获取失败", 0);
|
|
|
|
+ } else {
|
|
|
|
+ return Result::success($list);
|
|
}
|
|
}
|
|
- return $data;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|