初始化项目:添加后端代码、ThinkPHP框架、前端资源

This commit is contained in:
amb
2026-09-03 12:42:39 +08:00
commit 482bece22e
3726 changed files with 416708 additions and 0 deletions
@@ -0,0 +1,135 @@
<?php
namespace app\admin\controller\app\complaint;
use app\common\controller\Backend;
/**
* 投诉类型
*/
class Category extends Backend
{
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\app\complaint\Category;
}
/**
* 投诉类型列表
*/
public function index()
{
$this->request->filter(['strip_tags', 'trim']);
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->where($where)
->where('uniacid', UNIACID)
->order($sort ?: 'weigh', $order ?: 'desc')
->paginate($limit);
$result = [
'total' => $list->total(),
'rows' => $list->items(),
'attr' => [
'statusList' => $this->model->getStatusList()
]
];
return $this->success('获取成功', $result);
}
/**
* 添加投诉类型
*/
public function add()
{
$params = $this->request->only(['pid', 'title', 'description', 'weigh', 'status']);
$params['uniacid'] = UNIACID;
$params['createtime'] = time();
$params['updatetime'] = time();
$this->validateParams($params);
$this->model->insert($params);
return $this->success('保存成功');
}
/**
* 投诉类型详情
*/
public function detail($id)
{
$row = $this->model->where(['id' => $id, 'uniacid' => UNIACID])->find();
if (!$row) {
$this->error(__('No Results were found'));
}
return $this->success('获取成功', $row);
}
/**
* 编辑投诉类型
*/
public function edit($id = null)
{
$id = $id ?: $this->request->post('id');
$params = $this->request->only(['pid', 'title', 'description', 'weigh', 'status']);
$params['updatetime'] = time();
$row = $this->model->where(['id' => $id, 'uniacid' => UNIACID])->find();
if (!$row) {
$this->error(__('No Results were found'));
}
$this->validateParams($params, $id);
$row->save($params);
return $this->success('保存成功');
}
/**
* 删除投诉类型(级联删除子选项)
*/
public function del($ids = null)
{
if (!$ids) {
$this->error(__('Parameter %s can not be empty', 'ids'));
}
$ids = explode(',', $ids);
$allIds = $this->getAllChildIds($ids);
$this->model->where('uniacid', UNIACID)->where('id', 'in', $allIds)->delete();
return $this->success('删除成功');
}
/**
* 递归获取所有子选项ID
*/
protected function getAllChildIds($pids)
{
$allIds = $pids;
$children = $this->model->where('uniacid', UNIACID)->where('pid', 'in', $pids)->column('id');
if (!empty($children)) {
$allIds = array_merge($allIds, $this->getAllChildIds($children));
}
return $allIds;
}
/**
* 参数验证
*/
protected function validateParams($params, $id = 0)
{
if (empty($params['title'])) {
$this->error('请填写类型名称');
}
if ($id && intval($params['pid']) === intval($id)) {
$this->error('父级不能选择自身');
}
}
}
@@ -0,0 +1,45 @@
<?php
namespace app\admin\controller\app\complaint;
use app\common\controller\Backend;
/**
* 投诉设置
*/
class Config extends Backend
{
protected $configName = 'complaint';
public function _initialize()
{
parent::_initialize();
}
/**
* 获取投诉设置
*/
public function getConfig()
{
$config = \app\common\model\app\Config::getConfig($this->configName);
if (!is_array($config) || !isset($config['status'])) {
$config = ['status' => '1'];
}
return $this->success('获取成功', [
'config' => $config
]);
}
/**
* 保存投诉设置
*/
public function setConfig()
{
$row = $this->request->post('row/a', [], 'trim');
$row['status'] = isset($row['status']) && (string)$row['status'] === '0' ? '0' : '1';
\app\common\model\app\Config::setConfig($this->configName, $row);
return $this->success('保存成功');
}
}
@@ -0,0 +1,92 @@
<?php
namespace app\admin\controller\app\complaint;
use app\common\controller\Backend;
/**
* 投诉记录
*/
class Record extends Backend
{
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\app\complaint\Record;
}
/**
* 投诉记录列表
*/
public function index()
{
$this->request->filter(['strip_tags', 'trim']);
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->where($where)
->where('uniacid', UNIACID)
->order($sort ?: 'id', $order ?: 'desc')
->paginate($limit);
$result = [
'total' => $list->total(),
'rows' => $list->items(),
'attr' => [
'statusList' => $this->model->getStatusList()
]
];
return $this->success('获取成功', $result);
}
/**
* 投诉记录详情
*/
public function detail($id)
{
$row = $this->model->where(['id' => $id, 'uniacid' => UNIACID])->find();
if (!$row) {
$this->error(__('No Results were found'));
}
return $this->success('获取成功', $row);
}
/**
* 处理投诉
*/
public function handle($id = null)
{
$id = $id ?: $this->request->post('id');
$params = $this->request->only(['status', 'remark']);
$row = $this->model->where(['id' => $id, 'uniacid' => UNIACID])->find();
if (!$row) {
$this->error(__('No Results were found'));
}
if (!in_array((string)$params['status'], ['0', '1', '2'])) {
$this->error('处理状态无效');
}
$params['updatetime'] = time();
$row->save($params);
return $this->success('保存成功');
}
/**
* 删除投诉记录
*/
public function del($ids = null)
{
if (!$ids) {
$this->error(__('Parameter %s can not be empty', 'ids'));
}
$this->model->where('uniacid', UNIACID)->where('id', 'in', explode(',', $ids))->delete();
return $this->success('删除成功');
}
}