webman_duanju/app/admin/controller/Common.php

44 lines
1.2 KiB
PHP

<?php
namespace app\admin\controller;
use app\common\controller\Backend;
use app\common\library\DatabaseRoute;
use think\facade\Db;
class Common extends Backend
{
protected array $noNeedLogin = ['*'];
public function info()
{
$condition = $this->request->param();
$this->successWithData(Db::name('common_info')->where([
'condition_from' => $condition['condition']
])->select()->toArray());
}
public function update()
{
$params = $this->request->post();
$params['create_at'] = getNormalDate();
Db::name('common_info')->where([
'id' => $params['id']
])->update(convertKeysCamelToSnakeRecursive($params));
$info = Db::name('common_info')->where([
'id' => $params['id']
])->find();
cache('common_info:'.$info['type'], null);
$this->success();
}
public function type()
{
$get = $this->request->param();
if(empty($get['num'])) {
$this->error('type 不能为空');
}
$data = convertToCamelCase(Db::connect(config('database.search_library'))->name('common_info')->where('type', $get['num'])->find());
$this->success('ok', $data);
}
}