rkljw 3 months ago
parent
commit
df0921684c

+ 3 - 1
app/Controller/IndexController.php

@@ -23,5 +23,7 @@ class IndexController extends AbstractController
             'method' => $method,
             'message' => "Hello {$user}.",
         ];
+        //test
+        //master
     }
-}
+}

+ 239 - 239
app/JsonRpc/AdService.php

@@ -1,240 +1,240 @@
-<?php
-namespace App\JsonRpc;
-use App\Model\Ad;
-use App\Model\AdPlace;
-use Hyperf\RpcServer\Annotation\RpcService;
-use App\Tools\Result;
-#[RpcService(name: "AdService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
-class AdService implements AdServiceInterface
-{
-    /**
-     * @param array $data
-     * @return string
-     */
-    public function createAd(array $data): array
-    {
-        $insertData = [
-            'name'=>$data['name']??'',
-            'pid'=>$data['pid']??0,
-            'areaid'=>$data['areaid']??0,
-            'amount'=>$data['amount']??0,//浏览数量
-            'introduce'=>$data['introduce']??'',
-            'hits'=>$data['hits']??0, //点击数量
-            'fromtime'=>$data['f_t_date'][0]??0,
-            'totime'=>$data['f_t_date'][1]??0,
-            'text_name'=>$data['text_name']??'',
-            'text_url'=>$data['text_url']??'',
-            'text_title'=>$data['text_title']??'',
-            'image_src'=>$data['image_src']??'',
-            'image_url'=>$data['image_url']??'',
-            'image_alt'=>$data['image_alt']??'',
-            'video_src'=>$data['video_src']??'',//视频
-            'video_url'=>$data['video_url']??'',
-            'video_auto'=>$data['video_auto'] ??0,
-            'video_loop'=>$data['video_loop'] ??0,
-            'status'=>$data['status']??2,
-            'remark'=>$data['remark']??'',
-        ];
-        $result = Ad::query()->insertGetId($insertData);
-        if($result){
-            return Result::success();
-        }else{
-            return Result::error("创建广告失败",500);
-        }
-    }
-    /**
-     * @param int $id
-     * @return array
-     */
-    public function getAdInfo(int $id): array
-    {
-        $adInfo = Ad::query()->find($id);
-        if (empty($adInfo)) {
-            return Result::error("没有数据",0);
-        }
-        return Result::success($adInfo->toArray());
-    }
-
-    /**
-     * @param array $data
-     * @return array
-     */
-    public function getAdList(array $data): array
-    {
-        if(isset($data['pid'])){
-            $where[] =   ['ad.pid','=',$data['pid']];
-        }
-        $rep = Ad::where($where)
-            ->leftJoin("ad_place","ad.pid","ad_place.id")
-            ->leftJoin("website","website.id","ad_place.website_id")
-            ->select("ad.*","ad_place.name as place_name","ad_place.typeid","website.website_name")
-            ->limit($data['pageSize'])->orderBy("ad.id","desc")->offset(($data['page']-1)*$data['pageSize'])->get();
-        $count =  Ad::where($where)
-            ->leftJoin("ad_place","ad.pid","ad_place.id")
-            ->leftJoin("website","website.id","ad_place.website_id")
-            ->count();
-        $data = [
-            'rows'=>$rep->toArray(),
-            'count'=>$count
-        ];
-        if(empty($rep->toArray())){
-            return Result::error("没有数据");
-        }
-        return Result::success($data);
-    }
-
-    public function updateAd(array $data): array
-    {
-        $where = [
-            'id'=>$data['id']
-        ];
-        $insertData = [
-            'name'=>$data['name']??'',
-            'pid'=>$data['pid']??0,
-            'areaid'=>$data['areaid']??0,
-            'amount'=>$data['amount']??0,//浏览数量
-            'introduce'=>$data['introduce']??'',
-            'hits'=>$data['hits']??0, //点击数量
-            'fromtime'=>$data['f_t_date'][0]??0,
-            'totime'=>$data['f_t_date'][1]??0,
-            'text_name'=>$data['text_name']??'',
-            'text_url'=>$data['text_url']??'',
-            'text_title'=>$data['text_title']??'',
-            'image_src'=>$data['image_src']??'',
-            'image_url'=>$data['image_url']??'',
-            'image_alt'=>$data['image_alt']??'',
-            'video_src'=>$data['video_src']??'',//视频
-            'video_url'=>$data['video_url']??'',
-            'video_auto'=>isset($data['video_auto']) && empty($data['video_auto'])?0:$data['video_auto'],
-            'video_loop'=>isset($data['video_loop']) && empty($data['video_loop'])?0:$data['video_loop'],
-            'status'=>$data['status']??2,
-            'remark'=>$data['remark']??'',
-        ];
-        $result = Ad::where($where)->update($insertData);
-        if($result){
-            return Result::success($result);
-        }else{
-            return Result::error("更新失败");
-        }
-    }
-
-    public function delAd(array $data): array
-    {
-        $result = Ad::where($data)->delete();
-        if(!$result){
-            return Result::error("删除失败");
-        }
-        return Result::success($result);
-    }
-
-    /**
-     * 广告位列表
-     * @param array $data
-     * @return array
-     */
-    public function getAdPlaceList(array $data): array
-    {
-
-        $where = [];
-        if(isset($data['name'])  && $data['name']){
-            array_push($where,['ad_place.name','like','%'.$data['name'].'%']);
-        }
-        if(isset($data['website_id'])  && $data['website_id']){
-            array_push($where,['ad_place.website_id','=',$data['website_id']]);
-        }
-        $rep = AdPlace::where($where)
-            ->leftJoin("ad_size","ad_place.ad_size_id","ad_size.id")
-            ->leftJoin("website","website.id","ad_place.website_id")
-            ->limit($data['pageSize'])
-            ->orderBy("id","desc")
-            ->offset(($data['page']-1)*$data['pageSize'])
-            ->select("ad_place.*","ad_size.width","ad_size.height","website.website_name")
-            ->get();
-        $count =  AdPlace::where($where)->count();
-        $reponse = [
-            'rows'=>$rep->toArray(),
-            'count'=>$count
-        ];
-        if(empty($rep->toArray())){
-            return Result::error("没有数据");
-        }
-        return Result::success($reponse);
-    }
-
-    public function createAdPlace(array $data): array
-    {
-        unset($data['size']);
-        $result = AdPlace::query()->insertGetId($data);
-        if($result){
-            return Result::success();
-        }else{
-            return Result::error("创建广告位失败",500);
-        }
-    }
-
-    /**
-     * 'name' => 'required', //广告位名称
-     * 'website_id' => 'required',//关联的网站id
-     * 'price' => 'required',//价格
-     * 'thumb'=>'required', //广告示意图
-     * 'typeid'=>'required', //广告类型
-     * 'ad_size_id'=>'required', //广告位大小
-     * 'status'=>'required', //状态
-     * @param array $data
-     * @return array
-     */
-    public function updateAdPlace(array $data): array
-    {
-        $where = [
-            'id'=>$data['id']
-        ];
-        $Insdata = [
-            'website_id'=>$data['website_id']??'',
-            'typeid'=>$data['typeid']??1,
-            'status'=>$data['status']??2,
-            'name'=>$data['name']??'',
-            'thumb'=>$data['thumb']??'',
-            'introduce'=>$data['introduce']??'',
-            'code'=>$data['code']??'',
-            'price'=>$data['price']??0,
-            'ad_size_id'=>$data['ad_size_id']??0,
-        ];
-        $result = AdPlace::where($where)->update($Insdata);
-        if($result){
-            return Result::success($result);
-        }else{
-            return Result::error("更新失败");
-        }
-    }
-
-    /**
-     * 删除广告位
-     * @param array $data
-     * @return array
-     */
-    public function delAdPlace(array $data): array
-    {
-        $adList = Ad::where(['pid'=>$data['id']])->get();
-        if($adList->toArray()){
-            return Result::error("广告位里面还有广告,不能删除广告位");
-        }
-        $result = AdPlace::where($data)->delete();
-        if(!$result){
-            return Result::error("删除失败");
-        }
-        return Result::success($result);
-    }
-    /**
-     * @param int $id
-     * @return array
-     */
-    public function getAdPlaceInfo(int $id): array
-    {
-        $adInfo = AdPlace::query()->find($id);
-        if (empty($adInfo)) {
-            return Result::error("没有数据",0);
-        }
-        return Result::success($adInfo->toArray());
-    }
-
+<?php
+namespace App\JsonRpc;
+use App\Model\Ad;
+use App\Model\AdPlace;
+use Hyperf\RpcServer\Annotation\RpcService;
+use App\Tools\Result;
+#[RpcService(name: "AdService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
+class AdService implements AdServiceInterface
+{
+    /**
+     * @param array $data
+     * @return string
+     */
+    public function createAd(array $data): array
+    {
+        $insertData = [
+            'name'=>$data['name']??'',
+            'pid'=>$data['pid']??0,
+            'areaid'=>$data['areaid']??0,
+            'amount'=>$data['amount']??0,//浏览数量
+            'introduce'=>$data['introduce']??'',
+            'hits'=>$data['hits']??0, //点击数量
+            'fromtime'=>$data['f_t_date'][0]??0,
+            'totime'=>$data['f_t_date'][1]??0,
+            'text_name'=>$data['text_name']??'',
+            'text_url'=>$data['text_url']??'',
+            'text_title'=>$data['text_title']??'',
+            'image_src'=>$data['image_src']??'',
+            'image_url'=>$data['image_url']??'',
+            'image_alt'=>$data['image_alt']??'',
+            'video_src'=>$data['video_src']??'',//视频
+            'video_url'=>$data['video_url']??'',
+            'video_auto'=>$data['video_auto'] ??0,
+            'video_loop'=>$data['video_loop'] ??0,
+            'status'=>$data['status']??2,
+            'remark'=>$data['remark']??'',
+        ];
+        $result = Ad::query()->insertGetId($insertData);
+        if($result){
+            return Result::success();
+        }else{
+            return Result::error("创建广告失败",500);
+        }
+    }
+    /**
+     * @param int $id
+     * @return array
+     */
+    public function getAdInfo(int $id): array
+    {
+        $adInfo = Ad::query()->find($id);
+        if (empty($adInfo)) {
+            return Result::error("没有数据",0);
+        }
+        return Result::success($adInfo->toArray());
+    }
+
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getAdList(array $data): array
+    {
+        if(isset($data['pid'])){
+            $where[] =   ['ad.pid','=',$data['pid']];
+        }
+        $rep = Ad::where($where)
+            ->leftJoin("ad_place","ad.pid","ad_place.id")
+            ->leftJoin("website","website.id","ad_place.website_id")
+            ->select("ad.*","ad_place.name as place_name","ad_place.typeid","website.website_name")
+            ->limit($data['pageSize'])->orderBy("ad.id","desc")->offset(($data['page']-1)*$data['pageSize'])->get();
+        $count =  Ad::where($where)
+            ->leftJoin("ad_place","ad.pid","ad_place.id")
+            ->leftJoin("website","website.id","ad_place.website_id")
+            ->count();
+        $data = [
+            'rows'=>$rep->toArray(),
+            'count'=>$count
+        ];
+        if(empty($rep->toArray())){
+            return Result::error("没有数据");
+        }
+        return Result::success($data);
+    }
+
+    public function updateAd(array $data): array
+    {
+        $where = [
+            'id'=>$data['id']
+        ];
+        $insertData = [
+            'name'=>$data['name']??'',
+            'pid'=>$data['pid']??0,
+            'areaid'=>$data['areaid']??0,
+            'amount'=>$data['amount']??0,//浏览数量
+            'introduce'=>$data['introduce']??'',
+            'hits'=>$data['hits']??0, //点击数量
+            'fromtime'=>$data['f_t_date'][0]??0,
+            'totime'=>$data['f_t_date'][1]??0,
+            'text_name'=>$data['text_name']??'',
+            'text_url'=>$data['text_url']??'',
+            'text_title'=>$data['text_title']??'',
+            'image_src'=>$data['image_src']??'',
+            'image_url'=>$data['image_url']??'',
+            'image_alt'=>$data['image_alt']??'',
+            'video_src'=>$data['video_src']??'',//视频
+            'video_url'=>$data['video_url']??'',
+            'video_auto'=>isset($data['video_auto']) && empty($data['video_auto'])?0:$data['video_auto'],
+            'video_loop'=>isset($data['video_loop']) && empty($data['video_loop'])?0:$data['video_loop'],
+            'status'=>$data['status']??2,
+            'remark'=>$data['remark']??'',
+        ];
+        $result = Ad::where($where)->update($insertData);
+        if($result){
+            return Result::success($result);
+        }else{
+            return Result::error("更新失败");
+        }
+    }
+
+    public function delAd(array $data): array
+    {
+        $result = Ad::where($data)->delete();
+        if(!$result){
+            return Result::error("删除失败");
+        }
+        return Result::success($result);
+    }
+
+    /**
+     * 广告位列表
+     * @param array $data
+     * @return array
+     */
+    public function getAdPlaceList(array $data): array
+    {
+
+        $where = [];
+        if(isset($data['name'])  && $data['name']){
+            array_push($where,['ad_place.name','like','%'.$data['name'].'%']);
+        }
+        if(isset($data['website_id'])  && $data['website_id']){
+            array_push($where,['ad_place.website_id','=',$data['website_id']]);
+        }
+        $rep = AdPlace::where($where)
+            ->leftJoin("ad_size","ad_place.ad_size_id","ad_size.id")
+            ->leftJoin("website","website.id","ad_place.website_id")
+            ->limit($data['pageSize'])
+            ->orderBy("id","desc")
+            ->offset(($data['page']-1)*$data['pageSize'])
+            ->select("ad_place.*","ad_size.width","ad_size.height","website.website_name")
+            ->get();
+        $count =  AdPlace::where($where)->count();
+        $reponse = [
+            'rows'=>$rep->toArray(),
+            'count'=>$count
+        ];
+        if(empty($rep->toArray())){
+            return Result::error("没有数据");
+        }
+        return Result::success($reponse);
+    }
+
+    public function createAdPlace(array $data): array
+    {
+        unset($data['size']);
+        $result = AdPlace::query()->insertGetId($data);
+        if($result){
+            return Result::success();
+        }else{
+            return Result::error("创建广告位失败",500);
+        }
+    }
+
+    /**
+     * 'name' => 'required', //广告位名称
+     * 'website_id' => 'required',//关联的网站id
+     * 'price' => 'required',//价格
+     * 'thumb'=>'required', //广告示意图
+     * 'typeid'=>'required', //广告类型
+     * 'ad_size_id'=>'required', //广告位大小
+     * 'status'=>'required', //状态
+     * @param array $data
+     * @return array
+     */
+    public function updateAdPlace(array $data): array
+    {
+        $where = [
+            'id'=>$data['id']
+        ];
+        $Insdata = [
+            'website_id'=>$data['website_id']??'',
+            'typeid'=>$data['typeid']??1,
+            'status'=>$data['status']??2,
+            'name'=>$data['name']??'',
+            'thumb'=>$data['thumb']??'',
+            'introduce'=>$data['introduce']??'',
+            'code'=>$data['code']??'',
+            'price'=>$data['price']??0,
+            'ad_size_id'=>$data['ad_size_id']??0,
+        ];
+        $result = AdPlace::where($where)->update($Insdata);
+        if($result){
+            return Result::success($result);
+        }else{
+            return Result::error("更新失败");
+        }
+    }
+
+    /**
+     * 删除广告位
+     * @param array $data
+     * @return array
+     */
+    public function delAdPlace(array $data): array
+    {
+        $adList = Ad::where(['pid'=>$data['id']])->get();
+        if($adList->toArray()){
+            return Result::error("广告位里面还有广告,不能删除广告位");
+        }
+        $result = AdPlace::where($data)->delete();
+        if(!$result){
+            return Result::error("删除失败");
+        }
+        return Result::success($result);
+    }
+    /**
+     * @param int $id
+     * @return array
+     */
+    public function getAdPlaceInfo(int $id): array
+    {
+        $adInfo = AdPlace::query()->find($id);
+        if (empty($adInfo)) {
+            return Result::error("没有数据",0);
+        }
+        return Result::success($adInfo->toArray());
+    }
+
 }

+ 1 - 0
runtime/hyperf.pid

@@ -0,0 +1 @@
+10445

+ 8 - 0
runtime/logs/hyperf.log

@@ -1 +1,9 @@
 [2024-11-25 06:06:17] sql.INFO: [159.17] select * from `ad_place` where `ad_place`.`id` = '15' limit 1 [] []
+[2025-01-14 06:10:00] sql.INFO: [77.35] select `ad_place`.*, `ad_size`.`width`, `ad_size`.`height`, `website`.`website_name` from `ad_place` left join `ad_size` on `ad_place`.`ad_size_id` = `ad_size`.`id` left join `website` on `website`.`id` = `ad_place`.`website_id` where (`ad_place`.`name` like '%三农资讯-详情页-1号位置%' and `ad_place`.`website_id` = '1') order by `id` desc limit 10 offset 0 [] []
+[2025-01-14 06:10:00] sql.INFO: [18.5] select count(*) as aggregate from `ad_place` where (`ad_place`.`name` like '%三农资讯-详情页-1号位置%' and `ad_place`.`website_id` = '1') [] []
+[2025-01-14 06:10:23] sql.INFO: [18.65] select `ad_place`.*, `ad_size`.`width`, `ad_size`.`height`, `website`.`website_name` from `ad_place` left join `ad_size` on `ad_place`.`ad_size_id` = `ad_size`.`id` left join `website` on `website`.`id` = `ad_place`.`website_id` where (`ad_place`.`name` like '%三农资讯-详情页-1号位置%') order by `id` desc limit 10 offset 0 [] []
+[2025-01-14 06:10:23] sql.INFO: [17] select count(*) as aggregate from `ad_place` where (`ad_place`.`name` like '%三农资讯-详情页-1号位置%') [] []
+[2025-01-14 06:10:24] sql.INFO: [19.07] select `ad_place`.*, `ad_size`.`width`, `ad_size`.`height`, `website`.`website_name` from `ad_place` left join `ad_size` on `ad_place`.`ad_size_id` = `ad_size`.`id` left join `website` on `website`.`id` = `ad_place`.`website_id` where (`ad_place`.`name` like '%三农资讯-详情页-1号位置%') order by `id` desc limit 10 offset 0 [] []
+[2025-01-14 06:10:24] sql.INFO: [15.05] select count(*) as aggregate from `ad_place` where (`ad_place`.`name` like '%三农资讯-详情页-1号位置%') [] []
+[2025-01-14 06:10:29] sql.INFO: [17.15] select `ad_place`.*, `ad_size`.`width`, `ad_size`.`height`, `website`.`website_name` from `ad_place` left join `ad_size` on `ad_place`.`ad_size_id` = `ad_size`.`id` left join `website` on `website`.`id` = `ad_place`.`website_id` order by `id` desc limit 10 offset 0 [] []
+[2025-01-14 06:10:29] sql.INFO: [17.19] select count(*) as aggregate from `ad_place` [] []

+ 8 - 0
vendor/composer/installed.php

@@ -3,7 +3,11 @@
         'name' => 'hyperf/hyperf-skeleton',
         'pretty_version' => 'dev-master',
         'version' => 'dev-master',
+<<<<<<< HEAD
         'reference' => '004e36c8837e21d56b1e2e9dd79943db8e16e1ca',
+=======
+        'reference' => 'bbee7d57bb99c794a402aa428f3f885d1d34a3e5',
+>>>>>>> ad_2025_02_17_liu
         'type' => 'project',
         'install_path' => __DIR__ . '/../../',
         'aliases' => array(),
@@ -439,7 +443,11 @@
         'hyperf/hyperf-skeleton' => array(
             'pretty_version' => 'dev-master',
             'version' => 'dev-master',
+<<<<<<< HEAD
             'reference' => '004e36c8837e21d56b1e2e9dd79943db8e16e1ca',
+=======
+            'reference' => 'bbee7d57bb99c794a402aa428f3f885d1d34a3e5',
+>>>>>>> ad_2025_02_17_liu
             'type' => 'project',
             'install_path' => __DIR__ . '/../../',
             'aliases' => array(),