2024-09-29 15:43:18 +08:00

128 lines
3.5 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
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: https://thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\channel\controller;
use think\admin\Controller;
use app\channel\service\ProductBaseService;
use app\channel\service\SystemService;
/**
* 系统管理
* Class Channel
* @package app\channel\controller
*/
class System extends Controller
{
/**
* 绑定数据表
* @var string
*/
public $table = 'service_system';
/**
* 系统列表
* @auth true
* @menu true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$this->title = '系统列表';
$query = $this->_query($this->table);
$this->config = SystemService::instance()->getConfig();
$query->equal('status')->dateBetween('create_at');
$query->like('name');
$query->order('status desc, id desc')->page();
}
/**
* 添加系统
* @auth true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function add()
{
$this->_applyFormToken();
$this->_form($this->table, 'form');
}
/**
* 编辑系统
* @auth true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function edit()
{
$this->_applyFormToken();
$this->_form($this->table, 'form');
}
/**
* 表单数据处理
* @param array $data
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
protected function _form_filter(&$data)
{
$this->config = SystemService::instance()->getConfig();
if ($this->request->isPost()) {
if (empty($data['name'])) $this->error('系统名称不能为空!');
}
}
protected function _form_result($id, $data)
{
//ChannelService::instance()->get($id, false);
}
/**
* 修改系统状态
* @auth true
* @throws \think\db\exception\DbException
*/
public function state()
{
$this->_applyFormToken();
$this->_save($this->table, $this->_vali([
'status.in:0,1' => '状态值范围异常!',
'status.require' => '状态值不能为空!',
]));
}
/**
* 删除系统
* @auth true
* @throws \think\db\exception\DbException
*/
public function remove()
{
$this->_applyFormToken();
$this->_delete($this->table);
}
}