|
@@ -20,16 +20,25 @@ class WebsiteService implements WebsiteServiceInterface
|
|
* @param int $pageSize
|
|
* @param int $pageSize
|
|
* @return array
|
|
* @return array
|
|
*/
|
|
*/
|
|
- public function getWebsitetList(string $keyword,int $page,int $pageSize):array
|
|
|
|
|
|
+ public function getWebsitetList(array $data): array
|
|
{
|
|
{
|
|
- $where = [
|
|
|
|
- ['website.website_name','like','%'.$keyword.'%']
|
|
|
|
- ];
|
|
|
|
|
|
+ $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)
|
|
$result = Website::where($where)
|
|
->leftJoin("website_column","website.website_column_id","website_column.id")
|
|
->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")
|
|
|
|
- ->limit($pageSize)->offset(($page-1)*$pageSize)->get();
|
|
|
|
|
|
+ ->select("website.*","website_column.column_name","district.name as city_name")
|
|
|
|
+ ->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])->get();
|
|
|
|
+
|
|
$count = Website::where($where)->count();
|
|
$count = Website::where($where)->count();
|
|
if (empty($result)) {
|
|
if (empty($result)) {
|
|
return Result::error("没有数据",0);
|
|
return Result::error("没有数据",0);
|
|
@@ -47,6 +56,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
*/
|
|
*/
|
|
public function createWebsite(array $data): array
|
|
public function createWebsite(array $data): array
|
|
{
|
|
{
|
|
|
|
+ var_dump("网站数据:",$data);
|
|
$insertData = [
|
|
$insertData = [
|
|
'website_name'=>$data['website_name'],
|
|
'website_name'=>$data['website_name'],
|
|
'logo'=>$data['logo']??'',
|
|
'logo'=>$data['logo']??'',
|
|
@@ -59,6 +69,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
'status'=>$data['status']??0,
|
|
'status'=>$data['status']??0,
|
|
'website_column_arr_id'=>$data['website_column_arr_id'],
|
|
'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);
|
|
$result = Website::insertGetId($insertData);
|
|
if(empty($result)){
|
|
if(empty($result)){
|
|
@@ -87,6 +98,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
'status'=>$data['status']??0,
|
|
'status'=>$data['status']??0,
|
|
'website_column_arr_id'=>$data['website_column_arr_id'],
|
|
'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);
|
|
$result = Website::where('id',$id)->update($insertData);
|
|
var_dump("更新站点",$result);
|
|
var_dump("更新站点",$result);
|
|
@@ -118,7 +130,14 @@ class WebsiteService implements WebsiteServiceInterface
|
|
*/
|
|
*/
|
|
public function getWebsiteInfo(int $id): array
|
|
public function getWebsiteInfo(int $id): array
|
|
{
|
|
{
|
|
- $result = Website::where('id',$id )->first();
|
|
|
|
|
|
+
|
|
|
|
+ $where = [
|
|
|
|
+ ['website.id','=',$id]
|
|
|
|
+ ];
|
|
|
|
+ $result = Website::where($where )
|
|
|
|
+ ->leftJoin("template","template.id","website.template_id")
|
|
|
|
+ ->select("website.*","template.template_name","template.template_img")
|
|
|
|
+ ->first();
|
|
if(empty($result)){
|
|
if(empty($result)){
|
|
return Result::error("数据不存在",0);
|
|
return Result::error("数据不存在",0);
|
|
}else{
|
|
}else{
|