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.
127 lines
3.4 KiB
127 lines
3.4 KiB
<?php
|
|
|
|
|
|
namespace app\admin\controller\content;
|
|
|
|
|
|
use app\admin\logic\content\HelpCategoryLogic;
|
|
use app\admin\logic\content\HelpLogic;
|
|
use app\admin\logic\content\ResourceCategoryLogic;
|
|
use app\admin\logic\content\ResourceLogic;
|
|
use app\admin\validate\content\HelpValidate;
|
|
use app\common\basics\AdminBase;
|
|
use app\common\server\JsonServer;
|
|
|
|
class Resource extends AdminBase
|
|
{
|
|
/**
|
|
* @NOTES: 帮助分类列表
|
|
* @author: 张无忌
|
|
*/
|
|
public function lists()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$get = $this->request->get();
|
|
$lists = ResourceLogic::lists($get);
|
|
return JsonServer::success("获取成功", $lists);
|
|
}
|
|
|
|
return view('', [
|
|
'category' => ResourceCategoryLogic::getCategory()
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @NOTES: 添加帮助类
|
|
* @author: 张无忌
|
|
*/
|
|
public function add()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
// (new HelpValidate())->goCheck('add');
|
|
$post = $this->request->post();
|
|
$res = ResourceLogic::add($post);
|
|
if ($res === false) {
|
|
$error = ResourceLogic::getError() ?: '新增失败';
|
|
return JsonServer::error($error);
|
|
}
|
|
return JsonServer::success('新增成功');
|
|
}
|
|
|
|
|
|
return view('', [
|
|
'category' => ResourceCategoryLogic::getCategory()
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @NOTES: 编辑帮助分类
|
|
* @author: 张无忌
|
|
*/
|
|
public function edit()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
// (new HelpValidate())->goCheck('edit');
|
|
$post = $this->request->post();
|
|
$res = ResourceLogic::edit($post);
|
|
if ($res === false) {
|
|
$error = ResourceLogic::getError() ?: '编辑失败';
|
|
return JsonServer::error($error);
|
|
}
|
|
return JsonServer::success('编辑成功');
|
|
}
|
|
|
|
|
|
$id = $this->request->get('id');
|
|
$detail = ResourceLogic::detail($id);
|
|
$category2 = [];
|
|
if($detail['cid']>0){
|
|
$category2 = ResourceCategoryLogic::getCategory($detail['cid']);
|
|
}
|
|
return view('', [
|
|
'detail' => $detail,
|
|
'category' => ResourceCategoryLogic::getCategory(),
|
|
'category2' => $category2
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @NOTES: 删除帮助分类
|
|
* @author: 张无忌
|
|
*/
|
|
public function del()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
// (new HelpValidate())->goCheck('id');
|
|
$id = $this->request->post('id');
|
|
$res = ResourceLogic::del($id);
|
|
if ($res === false) {
|
|
$error = ResourceLogic::getError() ?: '删除失败';
|
|
return JsonServer::error($error);
|
|
}
|
|
return JsonServer::success('删除成功');
|
|
}
|
|
|
|
return JsonServer::error('异常');
|
|
}
|
|
|
|
/**
|
|
* @Notes: 隐藏帮助分类
|
|
* @Author: 张无忌
|
|
*/
|
|
public function hide()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
// (new HelpValidate())->goCheck('id');
|
|
$id = $this->request->post('id');
|
|
$res = ResourceLogic::hide($id);
|
|
if ($res === false) {
|
|
$error = ResourceLogic::getError() ?: '操作失败';
|
|
return JsonServer::error($error);
|
|
}
|
|
return JsonServer::success('操作成功');
|
|
}
|
|
|
|
return JsonServer::success('异常');
|
|
}
|
|
}
|