更新
This commit is contained in:
92
modules/Account/app/Controllers/Api/StatisticsController.php
Normal file
92
modules/Account/app/Controllers/Api/StatisticsController.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Account\Controllers\Api;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\BaseController;
|
||||
use Modules\Account\Services\StatisticsService;
|
||||
|
||||
class StatisticsController extends BaseController
|
||||
{
|
||||
protected $statisticsService;
|
||||
|
||||
public function __construct(StatisticsService $statisticsService)
|
||||
{
|
||||
$this->statisticsService = $statisticsService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取统计概览
|
||||
*/
|
||||
public function overview(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->statisticsService->getOverview($request);
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取收支趋势
|
||||
*/
|
||||
public function trend(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->statisticsService->getTrend($request);
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分类统计
|
||||
*/
|
||||
public function category(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->statisticsService->getCategory($request);
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取月度报表
|
||||
*/
|
||||
public function monthly(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->statisticsService->getMonthly($request);
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取年度报表
|
||||
*/
|
||||
public function yearly(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->statisticsService->getYearly($request);
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user