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
<?php
 
namespace app\api\controller\branch\admin;
 
use app\api\controller\branch\Admin;
use app\api\model\branch\ActivityFile as ActivityFileModel;
 
/**
 * 活动文件控制器
 */
class ActivityFile extends Admin
{
    /**
     * 列表
     */
    public function lists($activity_id = 0, $type = 'image')
    {
        $model = new ActivityFileModel;
        $list = $model->getList($activity_id, $this->postData());
        return $this->renderSuccess('', compact('list'));
    }
 
    /**
     * 添加文件
     */
    public function add()
    {
        $model = new ActivityFileModel;
        //Vue要添加的数据
        $data = json_decode($this->request->post('formData', '', null), true);
        // 新增记录
        if ($model->add($data)) {
            return $this->renderSuccess('添加成功');
        }
        return $this->renderError($model->getError() ?: '添加失败');
    }
 
    /**
     * 删除文件
     */
    public function delete($fileIds)
    {
        $model = new ActivityFileModel();
        if ($model->setDelete($fileIds)) {
            return $this->renderSuccess('删除成功');
        }
        return $this->renderError($model->getError() ?:'删除失败');
    }
    
}