Browse Source

家庭乐园里的图片与视频

lizhen_gitee 10 months ago
parent
commit
fa1bcfc5fc
1 changed files with 66 additions and 0 deletions
  1. 66 0
      application/api/controller/Family.php

+ 66 - 0
application/api/controller/Family.php

@@ -0,0 +1,66 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+/**
+ * 家庭乐园
+ */
+class Family extends Api
+{
+    protected $noNeedLogin = [];
+    protected $noNeedRight = ['*'];
+
+    //图片,视频的列表
+    public function lists(){
+        $type = input('type',1);
+
+        $list = Db::name('family')->where('user_id',$this->auth->id)->where('type',$type)->order('id desc')->autopage()->select();
+        $list = list_domain_image($list,['media_file']);
+
+        $this->success(1,$list);
+    }
+
+    //上传
+    public function addone(){
+        $media_file = input('media_file','');
+        $media_name = input('media_name','');
+        $media_size = input('media_size','');
+        $type       = input('type','');
+
+        if(!$media_file || !$media_name || !$media_size){
+            $this->error();
+        }
+
+        $data = [
+            'user_id'    => $this->auth->id,
+            'media_file' => $media_file,
+            'media_name' => $media_name,
+            'media_size' => $media_size,
+            'createtime' => time(),
+            'type'       => $type,
+        ];
+        Db::name('family')->insertGetId($data);
+        $this->success(1);
+    }
+
+    //删除
+    public function delete(){
+        $ids = input('ids','','trim');
+        if(empty($ids)){
+            $this->error();
+        }
+
+        $ids = explode(',',$ids);
+        if(empty($ids)){
+            $this->error();
+        }
+
+        Db::name('family')->where('id','IN',$ids)->delete();
+        $this->success(1);
+    }
+
+
+
+}