test_lgq/niucloud/app/adminapi/controller/sys/Attachment.php
2024-01-24 17:36:08 +08:00

165 lines
4.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\adminapi\controller\sys;
use app\dict\sys\FileDict;
use app\service\admin\sys\AttachmentService;
use core\base\BaseAdminController;
use think\Response;
class Attachment extends BaseAdminController
{
/**
* 附件列表
*/
public function lists()
{
$data = $this->request->params([
['att_type', ''],
['cate_id', 0],
['real_name', ''],
['page', 0],
['limit', 0],
]);
return success((new AttachmentService())->getPage($data));
}
/**
* 删除附件
* @param $att_id
* @return Response
*/
// public function del($att_id)
// {
// return success((new AttachmentService())->del($att_id));
// }
/**
* 批量删除
* @return Response
*/
public function batchDel()
{
$data = $this->request->params([
['att_ids', []],
]);
(new AttachmentService())->delAll($data['att_ids']);
return success('DELETE_SUCCESS');
}
/**
* 新增附件分组
* @return Response
*/
public function addCategory()
{
$data = $this->request->params([
['type', FileDict::IMAGE],
['name', '']
]);
$this->validate($data, 'app\validate\sys\AttachmentCategory.add');
(new AttachmentService())->addCategory($data);
return success('ADD_SUCCESS');
}
/**
* 附件分组列表
*/
public function categoryLists()
{
$data = $this->request->params([
['type', ''],
['name', ''],
]);
return success((new AttachmentService())->getCategoryList($data));
}
/**
* 更新附件分组
* @return Response
*/
public function editCategory($id)
{
$data = $this->request->params([
['name', '']
]);
$this->validate($data, 'app\validate\sys\AttachmentCategory.edit');
(new AttachmentService())->editCategory($id, $data);
return success('EDIT_SUCCESS');
}
/**
* 删除附件组
* @param $id
* @return Response
*/
public function deleteCategory($id)
{
(new AttachmentService())->delCategory($id);
return success('DELETE_SUCCESS');
}
/**
* 移动图片分组
* @return Response
*/
public function moveCategory($att_id)
{
$data = $this->request->params([
['cate_id', '']
]);
(new AttachmentService())->modifyCategory($att_id, $data['cate_id']);
return success();
}
/**
* 批量移动图片分组
* @return Response
*/
public function batchMoveCategory()
{
$data = $this->request->params([
['cate_id', ''],
['att_ids', []]
]);
(new AttachmentService())->batchModifyCategory($data['att_ids'], $data['cate_id']);
return success();
}
/**
* 获取图标库分类列表
*/
public function getIconCategoryList()
{
$data = $this->request->params([
['name', ''],
]);
return success((new AttachmentService())->getIconCategoryList($data));
}
/**
* 获取图标库列表
*/
public function getIconList()
{
$data = $this->request->params([
['page', 0],
['limit', 0],
['cate_id', 0],
['real_name', ''],
]);
return success((new AttachmentService())->getIconList($data));
}
}