2026-09-23 15:15:02 +08:00

88 lines
2.8 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
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\setting\notification;
use app\adminapi\controller\AuthController;
use app\services\message\admin\NoticeLogServices;
use think\facade\App;
class NoticeLogController extends AuthController
{
protected $services;
public function __construct(App $app, NoticeLogServices $services)
{
parent::__construct($app);
$this->services = $services;
}
public function index()
{
$filter = $this->request->getMore([
['mark', ''],
['uid', ''],
['channel_key', ''],
['status', ''],
['start_time', ''],
['end_time', ''],
]);
$page = $this->request->get('page', 1);
$limit = $this->request->get('limit', 20);
return app('json')->success($this->services->getList($filter, (int)$page, (int)$limit));
}
public function detail(int $id)
{
if (!$id) {
return app('json')->fail('参数错误');
}
$info = $this->services->getDetail($id);
if (empty($info)) {
return app('json')->fail('记录不存在');
}
return app('json')->success($info);
}
public function statistics()
{
$filter = $this->request->getMore([
['channel_key', ''],
['start_time', ''],
['end_time', ''],
]);
return app('json')->success($this->services->getStatistics($filter));
}
public function retry(int $id)
{
if (!$id) {
return app('json')->fail('参数错误');
}
$info = $this->services->getDetail($id);
if (empty($info)) {
return app('json')->fail('记录不存在');
}
// 日志只有渲染后的内容,没有原始变量;重新执行会发送残缺信息。
return app('json')->fail('该日志未保存原始变量,无法安全重试');
}
public function clean()
{
$days = $this->request->post('days', 30);
$count = $this->services->cleanLogs((int)$days);
return app('json')->success('清理成功,共删除 ' . $count . ' 条记录');
}
}