Files
huangjingfen/pro_v3.5.1/app/controller/admin/v1/system/config/SystemConfigTab.php
panchengyong c1e74d8e68 chore(php): 统一 ScottPan 文件头与注释域名替换
- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明

Made-with: Cursor
2026-03-29 11:22:58 +08:00

157 lines
3.8 KiB
PHP

<?php
// +----------------------------------------------------------------------
// | Author: ScottPan Team
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\system\config;
use app\controller\admin\AuthController;
use app\services\system\config\SystemConfigServices;
use app\services\system\config\SystemConfigTabServices;
use think\annotation\Inject;
/**
* 配置分类
* Class SystemConfigTab
* @package app\controller\admin\v1\setting
*/
class SystemConfigTab extends AuthController
{
/**
* @var SystemConfigTabServices
*/
#[Inject]
protected SystemConfigTabServices $services;
/**
* 显示资源列表
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$where = $this->request->getMore([
['status', ''],
['title', ''],
['is_store', '']
]);
return $this->success($this->services->getConfgTabList($where));
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create()
{
return $this->success($this->services->createForm());
}
/**
* 保存新建的资源
*
* @return \think\Response
*/
public function save()
{
$data = $this->request->postMore([
'eng_title',
'status',
'title',
'icon',
['type', 0],
['sort', 0],
['pid', []],
['is_store', 0],
]);
$data['pid'] = end($data['pid']);
if (!$data['title']) return $this->fail('请输入按钮名称');
$this->services->save($data);
return $this->success('添加配置分类成功!');
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
//
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
return $this->success($this->services->updateForm((int)$id));
}
/**
* 保存更新的资源
*
* @param int $id
* @return \think\Response
*/
public function update($id)
{
$data = $this->request->postMore([
'title',
'status',
'eng_title',
'icon',
['type', 0],
['sort', 0],
['pid', []],
['is_store', 0],
]);
$data['pid'] = end($data['pid']);
if (!$data['title']) return $this->fail('请输入分类昵称');
if (!$data['eng_title']) return $this->fail('请输入分类字段');
$this->services->update($id, $data);
return $this->success('修改成功!');
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete(SystemConfigServices $services, $id)
{
if ($services->count(['tab_id' => $id])) {
return $this->fail('存在下级配置,无法删除!');
}
if (!$this->services->delete($id))
return $this->fail('删除失败,请稍候再试!');
else
return $this->success('删除成功!');
}
/**
* 修改状态
* @param $id
* @param $status
* @return mixed
*/
public function set_status($id, $status)
{
if ($status == '' || $id == 0) {
return $this->fail('参数错误');
}
$this->services->update($id, ['status' => $status]);
return $this->success($status == 0 ? '隐藏成功' : '显示成功');
}
}