更新
This commit is contained in:
95
modules/Account/app/Controllers/Api/BillController.php
Normal file
95
modules/Account/app/Controllers/Api/BillController.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Account\Controllers\Api;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\BaseController;
|
||||
use Modules\Account\Services\BillService;
|
||||
|
||||
class BillController extends BaseController
|
||||
{
|
||||
protected $billService;
|
||||
|
||||
public function __construct(BillService $billService)
|
||||
{
|
||||
$this->billService = $billService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账单列表
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->billService->getList($request);
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加账单
|
||||
*/
|
||||
public function add(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->billService->add($request);
|
||||
$this->data['message'] = '添加成功';
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑账单
|
||||
*/
|
||||
public function edit(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->billService->edit($request);
|
||||
$this->data['message'] = '编辑成功';
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除账单
|
||||
*/
|
||||
public function delete(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->billService->delete($request);
|
||||
$this->data['message'] = '删除成功';
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账单详情
|
||||
*/
|
||||
public function detail(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->billService->detail($request);
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
}
|
||||
155
modules/Account/app/Controllers/Api/FamilyController.php
Normal file
155
modules/Account/app/Controllers/Api/FamilyController.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Account\Controllers\Api;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\BaseController;
|
||||
use Modules\Account\Services\FamilyService;
|
||||
|
||||
class FamilyController extends BaseController
|
||||
{
|
||||
protected $familyService;
|
||||
|
||||
public function __construct(FamilyService $familyService)
|
||||
{
|
||||
$this->familyService = $familyService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取家庭信息
|
||||
*/
|
||||
public function info(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->familyService->getInfo($request);
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建家庭
|
||||
*/
|
||||
public function create(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->familyService->create($request);
|
||||
$this->data['message'] = '创建成功';
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加入家庭
|
||||
*/
|
||||
public function join(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->familyService->join($request);
|
||||
$this->data['message'] = '加入成功';
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出家庭
|
||||
*/
|
||||
public function leave(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->familyService->leave($request);
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取家庭邀请码
|
||||
*/
|
||||
public function inviteCode(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->familyService->getInviteCode($request);
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新生成邀请码
|
||||
*/
|
||||
public function regenerateInviteCode(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->familyService->regenerateInviteCode($request);
|
||||
$this->data['message'] = '邀请码已重新生成';
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除家庭成员
|
||||
*/
|
||||
public function removeMember(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->familyService->removeMember($request);
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取家庭成员列表
|
||||
*/
|
||||
public function members(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->familyService->getMembers($request);
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转让家主
|
||||
*/
|
||||
public function transferOwner(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->data['data'] = $this->familyService->transferOwner($request);
|
||||
} catch (\Throwable $th) {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['message'] = $th->getMessage();
|
||||
}
|
||||
|
||||
return response()->json($this->data);
|
||||
}
|
||||
}
|
||||
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