<?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() ?:'删除失败');
|
}
|
|
}
|