Browse Source

技术规范,也就是文库

lizhen_gitee 8 months ago
parent
commit
3dd8582497

+ 50 - 1
application/api/controller/worker/Jishuguifan.php

@@ -61,6 +61,8 @@ class Jishuguifan extends Api
         $info = Db::name('jishuguifan')
             ->where('id',$id)
             ->find();
+        //收藏
+        $info['is_collect'] = $this->is_collect($info['id'],$this->auth->id);
 
         //上一篇
         $up_id = 0;
@@ -85,6 +87,53 @@ class Jishuguifan extends Api
         $this->success(1, $rs);
     }
 
-    //收藏功能
+
     //下载功能
+    public function download(){
+        $where = [
+            'worker_id'  => $this->auth->id,
+            'table_id' => input('id',0),
+        ];
+        $check = Db::name('worker_download')->where($where)->find();
+        if($check){
+            Db::name('worker_download')->where($where)->update(['updatetime'=>time()]);
+            $this->success();
+        }else{
+            $where['updatetime'] = time();
+            Db::name('worker_download')->insertGetId($where);
+            $this->success();
+        }
+    }
+
+    //收藏,取消收藏
+    public function collect(){
+        $where = [
+            'worker_id'  => $this->auth->id,
+            'table'    => 'jishuguifan',
+            'table_id' => input('id',0),
+        ];
+        $check = Db::name('worker_collect')->where($where)->find();
+        if($check){
+            Db::name('worker_collect')->where($where)->delete();
+            $this->success('已取消收藏');
+        }else{
+            Db::name('worker_collect')->insertGetId($where);
+            $this->success('收藏成功');
+        }
+    }
+
+    //动态是否收藏
+    private function is_collect($id,$uid){
+        $where = [
+            'worker_id'  => $uid,
+            'table'    => 'jishuguifan',
+            'table_id' => $id,
+        ];
+        $check = Db::name('worker_collect')->where($where)->find();
+        if($check){
+            return 1;
+        }else{
+            return 0;
+        }
+    }
 }

+ 34 - 0
application/api/controller/worker/Messagesys.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace app\api\controller\worker;
+
+use app\common\controller\Api;
+use think\Db;
+/**
+ * 消息
+ */
+class Messagesys extends Api
+{
+    protected $noNeedLogin = [];
+    protected $noNeedRight = ['*'];
+
+    //消息页信息
+    public function index(){
+
+        $list = Db::name('message_sys')->field('content',true)
+            ->where('company_id',$this->auth->company_id)
+            ->autopage()->order('id desc')->select();
+
+        $this->success("获取成功!",$list);
+    }
+    //消息页信息
+    public function info(){
+        $id = input('id',0);
+        $info = Db::name('message_sys')->where('id',$id)->find();
+
+        $this->success("获取成功!",$info);
+    }
+
+
+
+}