Browse Source

友情链接

rkljw 4 months ago
parent
commit
e8b6cc396e

+ 33 - 24
app/JsonRpc/LinkService.php

@@ -17,25 +17,24 @@ class LinkService implements LinkServiceInterface
     public function getLinkList(array $data): array
     {
         $where = [];
-        if(isset($data['keyWord'])){
-            $where = [
-                ['link.title','like','%'.$data['keyWord'].'%']
-            ];
+        if(isset($data['title']) && $data['title']!=''){
+            array_push($where, ['link.title','like','%'.$data['title'].'%']);
         }
-        $result  = [];
-        if(isset($data['pageSize'])){
-            $rep = Link::where($where)
-                ->leftJoin("website","website.id","link.website_id")
-                ->select("link.*","website.website_name")
-                ->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])->orderBy("sort","asc")->get();
-            $count = Link::where($where)->count();
-            $result = [
-                'rows'=>$rep,
-                'count'=>$count
-            ];
-        }else{
-            $result = Link::where($data)->orderBy("sort","asc")->get();
+        if(isset($data['website_id']) && $data['website_id']!=''){
+            array_push($where,  ['link.website_id','=',$data['website_id']]);
         }
+        $rep = Link::where($where)
+            ->leftJoin("website","website.id","link.website_id")
+            ->select("link.*","website.website_name")
+            ->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])->orderBy("sort","desc")->get();
+        $count = Link::where($where)
+            ->leftJoin("website","website.id","link.website_id")
+            ->count();
+        $result = [
+            'rows'=>$rep,
+            'count'=>$count
+        ];
+
         return $result?Result::success($result):Result::error("没有查到数据");
     }
 
@@ -45,8 +44,6 @@ class LinkService implements LinkServiceInterface
      */
     public function createLink(array $data): array
     {
-
-
         $result = Link::insertGetId($data);
         if (empty($result)) {
             return Result::error("创建失败", 0);
@@ -61,9 +58,6 @@ class LinkService implements LinkServiceInterface
      */
     public function updateLink(array $data): array
     {
-        //website_name` = '三农市场网', `status_name` =
-        unset($data['website_name']);
-        unset($data['status_name']);
         $result = Link::where('id', $data['id'])->update($data);
         if (empty($result)) {
             return Result::error("更新失败", 0);
@@ -76,9 +70,9 @@ class LinkService implements LinkServiceInterface
      * @param int $id
      * @return array
      */
-    public function delLink(int $id): array
+    public function delLink(array $data): array
     {
-        $result = Link::where('id', $id)->delete();
+        $result = Link::where('id', $data['id'])->delete();
         if (empty($result)) {
             return Result::error("删除失败", 0);
         } else {
@@ -86,5 +80,20 @@ class LinkService implements LinkServiceInterface
         }
     }
 
+    /**
+     * 获取友情链接详情
+     * @param array $data
+     * @return array
+     */
+    public function getLinkInfo(array $data): array
+    {
+        $result = Link::where('id', $data['id'])->first();
+        if (empty($result)) {
+            return Result::error("获取友情链接详情失败", 0);
+        } else {
+            return Result::success($result);
+        }
+    }
+
 
 }

+ 6 - 2
app/JsonRpc/LinkServiceInterface.php

@@ -24,8 +24,12 @@ interface LinkServiceInterface
      * @param int $id
      * @return array
      */
-    public function delLink(int $id): array;
-
+    public function delLink(array $data): array;
 
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getLinkInfo(array $data): array;
 
 }

File diff suppressed because it is too large
+ 0 - 0
runtime/container/scan.cache


+ 1 - 1
runtime/hyperf.pid

@@ -1 +1 @@
-19533
+42510

+ 4 - 3
runtime/logs/hyperf.log

@@ -1,3 +1,4 @@
-[2024-11-21T07:56:29.674152+00:00] sql.INFO: [87.21] select * from `letter_type` where (`type` = '1') order by `sort` asc [] []
-[2024-11-21T07:56:40.645759+00:00] sql.INFO: [18.18] select * from `letter_type` where (`type` = '1' and `pid` = '14') order by `sort` asc [] []
-[2024-11-21T07:56:56.646094+00:00] sql.INFO: [103.6] insert into `letter_of_complaint` (`title`, `nature`, `nature_level0`, `nature_level1`, `nature_level3`, `name`, `id_card`, `mobile`, `describe`, `like_remark`, `judgment`, `audio_and_video`, `contract`, `qualifications`, `money`, `other`, `user_id`) values ('我测试一条', '5', '14', '29', '113', '1', '1', '15801245755', '111', '111111111', '', '', '', '', '1', '111', '71') [] []
+[2024-11-25T07:30:51.464468+00:00] sql.INFO: [1170.48] select `link`.*, `website`.`website_name` from `link` left join `website` on `website`.`id` = `link`.`website_id` where (`link`.`website_id` = '2') order by `sort` asc limit 10 offset 0 [] []
+[2024-11-25T07:30:51.494094+00:00] sql.INFO: [19.62] select count(*) as aggregate from `link` left join `website` on `website`.`id` = `link`.`website_id` where (`link`.`website_id` = '2') [] []
+[2024-11-25T07:34:40.180987+00:00] sql.INFO: [300.89] select `link`.*, `website`.`website_name` from `link` left join `website` on `website`.`id` = `link`.`website_id` where (`link`.`title` like '%这是标题33377%' and `link`.`website_id` = '2') order by `sort` desc limit 10 offset 0 [] []
+[2024-11-25T07:34:40.257661+00:00] sql.INFO: [63.7] select count(*) as aggregate from `link` left join `website` on `website`.`id` = `link`.`website_id` where (`link`.`title` like '%这是标题33377%' and `link`.`website_id` = '2') [] []

Some files were not shown because too many files changed in this diff