|
@@ -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;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|