Create.php
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/7/6
* Time: 9:58
*/
namespace app\api\controller;
use app\common\controller\Api;
use think\Db;
/**
* 发布接口
*/
class Create extends Api
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
/**
* @ApiTitle (创建文件夹)
* @ApiSummary (创建文件夹)
* @ApiMethod (POST)
* @ApiRoute (/api/create/publish_folder)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="inter", required=true, description="父级文件夹id")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
}
]
}
})
*/
public function publish_folder()
{
$user_id = $this->auth->id;
$id = $this->request->param('id');
$user = Db::name('user')->where('id',$user_id)->field('id,identity,audit')->find();
//判断用户身份是否审核通过
if($user['audit'] != 1){
$this->error('身份身份通过才可发布!');
}
//判断用户身份是否有发布的权限
if($user['identity'] == 1){
$this->error('您的权限不足');
}
$res['user_id'] = $user_id;
$res['folder_name'] = date('YmdHis');
if(empty($id)){
$res['pid'] = 0;
}else{
$res['pid'] = $id;
}
$res['createtime'] = time();
$res['updatetime'] = time();
$data = Db::name('folder')->insertGetId($res);
if(empty($data)){
$this->error('sql运行失败');
}else{
$this->success('success',$data);
}
}
}