You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
2.9 KiB
110 lines
2.9 KiB
<?php
|
|
|
|
|
|
namespace app\admin\controller\vote;
|
|
|
|
|
|
use app\admin\logic\content\ArticleCategoryLogic;
|
|
use app\admin\logic\content\ResourceCategoryLogic;
|
|
use app\admin\logic\content\ResourceLogic;
|
|
use app\admin\logic\vote\VoteCategoryLogic;
|
|
use app\admin\logic\vote\VoteLogic;
|
|
use app\admin\validate\content\ArticleCategoryValidate;
|
|
use app\common\basics\AdminBase;
|
|
use app\common\server\JsonServer;
|
|
|
|
class VoteCategory extends AdminBase
|
|
{
|
|
/**
|
|
* @NOTES: 资源分类列表
|
|
* @author: 张无忌
|
|
*/
|
|
public function lists()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$get = $this->request->get();
|
|
$lists = VoteCategoryLogic::lists($get);
|
|
return JsonServer::success("获取成功", $lists);
|
|
}
|
|
|
|
return view();
|
|
}
|
|
|
|
/**
|
|
* @NOTES: 添加资源分类
|
|
* @author: 张无忌
|
|
*/
|
|
public function add()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$post = $this->request->post();
|
|
$res = VoteCategoryLogic::add($post);
|
|
if ($res === false) {
|
|
$error = VoteCategoryLogic::getError() ?: '新增失败';
|
|
return JsonServer::error($error);
|
|
}
|
|
return JsonServer::success('新增成功');
|
|
}
|
|
return view('');
|
|
}
|
|
|
|
/**
|
|
* @NOTES: 编辑分类
|
|
* @author: 张无忌
|
|
*/
|
|
public function edit()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$post = $this->request->post();
|
|
$res = VoteCategoryLogic::edit($post);
|
|
if ($res === false) {
|
|
$error = VoteCategoryLogic::getError() ?: '编辑失败';
|
|
return JsonServer::error($error);
|
|
}
|
|
return JsonServer::success('编辑成功');
|
|
}
|
|
|
|
$id = $this->request->get('id');
|
|
return view('', [
|
|
'detail' => VoteCategoryLogic::detail($id)
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @NOTES: 删除分类
|
|
* @author: 张无忌
|
|
*/
|
|
public function del()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$id = $this->request->post('id');
|
|
$res = VoteCategoryLogic::del($id);
|
|
if ($res === false) {
|
|
$error = VoteCategoryLogic::getError() ?: '删除失败';
|
|
return JsonServer::error($error);
|
|
}
|
|
return JsonServer::success('删除成功');
|
|
}
|
|
|
|
return JsonServer::error('异常');
|
|
}
|
|
|
|
/**
|
|
* @Notes: 隐藏分类
|
|
* @Author: 张无忌
|
|
*/
|
|
public function hide()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$id = $this->request->post('id');
|
|
$res = VoteCategoryLogic::hide($id);
|
|
if ($res === false) {
|
|
$error = VoteCategoryLogic::getError() ?: '操作失败';
|
|
return JsonServer::error($error);
|
|
}
|
|
return JsonServer::success('操作成功');
|
|
}
|
|
|
|
return JsonServer::success('异常');
|
|
}
|
|
}
|