70 lines
1.7 KiB
PHP
70 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace app\czg\controller;
|
|
|
|
use app\common\controller\Backend;
|
|
use app\common\library\DatabaseRoute;
|
|
use think\facade\Db;
|
|
|
|
class AnnouncementController extends Backend
|
|
{
|
|
protected array $noNeedLogin = ['*'];
|
|
protected array $noNeedPermission = ['statisticsIncomeMoney', 'statisticsCashMoney'];
|
|
|
|
public function list()
|
|
{
|
|
$params = $this->request->get();
|
|
$where = [];
|
|
if (!empty($params['title'])) {
|
|
$where[] = ['title', '=', $params['title']];
|
|
}
|
|
|
|
if (!empty($params['type'])) {
|
|
$where[] = ['type', '=', $params['type']];
|
|
}
|
|
|
|
if (!empty($params['state'])) {
|
|
$where[] = ['state', '=', $params['state']];
|
|
}
|
|
|
|
if (!empty($params['id'])) {
|
|
$where[] = ['id', '=', $params['id']];
|
|
}
|
|
|
|
$this->successWithData(apiconvertToCamelCase(Db::name('announcement')->where($where)->select()->toArray()));
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
$params = $this->request->post();
|
|
$params = convertKeysCamelToSnakeRecursive($params);
|
|
$params['create_time'] = getNormalDate();
|
|
Db::name('announcement')->insert($params);
|
|
$this->success();
|
|
}
|
|
|
|
public function update()
|
|
{
|
|
$params = $this->request->post();
|
|
$params = convertKeysCamelToSnakeRecursive($params);
|
|
Db::name('announcement')->where([
|
|
'id' => $params['id']
|
|
])->update($params);
|
|
|
|
$this->success();
|
|
}
|
|
|
|
public function delete()
|
|
{
|
|
$id = $this->request->post('id');
|
|
Db::name('announcement')->delete([
|
|
'id' => $id
|
|
]);
|
|
|
|
$this->success();
|
|
}
|
|
|
|
|
|
|
|
|
|
} |