add
This commit is contained in:
70
app/admin/controller/Announcement.php
Normal file
70
app/admin/controller/Announcement.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use app\common\library\DatabaseRoute;
|
||||
use think\facade\Db;
|
||||
|
||||
class Announcement extends Backend
|
||||
{
|
||||
protected array $noNeedLogin = ['*'];
|
||||
protected array $noNeedPermission = ['statisticsIncomeMoney', 'statisticsCashMoney'];
|
||||
|
||||
public function list()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
$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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user