Family.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 家庭乐园
  7. */
  8. class Family extends Api
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = ['*'];
  12. //图片,视频的列表
  13. public function lists(){
  14. $type = input('type',1);
  15. $list = Db::name('family')->where('user_id',$this->auth->id)->where('type',$type)->order('id desc')->autopage()->select();
  16. $list = list_domain_image($list,['media_file']);
  17. $this->success(1,$list);
  18. }
  19. //上传
  20. public function addone(){
  21. $media_file = input('media_file','');
  22. $media_name = input('media_name','');
  23. $media_size = input('media_size','');
  24. $type = input('type','');
  25. if(!$media_file || !$media_name || !$media_size){
  26. $this->error();
  27. }
  28. $data = [
  29. 'user_id' => $this->auth->id,
  30. 'media_file' => $media_file,
  31. 'media_name' => $media_name,
  32. 'media_size' => $media_size,
  33. 'createtime' => time(),
  34. 'type' => $type,
  35. ];
  36. Db::name('family')->insertGetId($data);
  37. $this->success(1);
  38. }
  39. //删除
  40. public function delete(){
  41. $ids = input('ids','','trim');
  42. if(empty($ids)){
  43. $this->error();
  44. }
  45. $ids = explode(',',$ids);
  46. if(empty($ids)){
  47. $this->error();
  48. }
  49. Db::name('family')->where('id','IN',$ids)->delete();
  50. $this->success(1);
  51. }
  52. }