| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace app\controller\admin;
- use app\extra\basic\Base;
- use app\middleware\AuthMiddleware;
- use app\model\cpa\CpaPage;
- use app\service\cpa\PageService;
- use DI\Attribute\Inject;
- use LinFly\Annotation\Attributes\Route\Controller;
- use LinFly\Annotation\Attributes\Route\GetMapping;
- use LinFly\Annotation\Attributes\Route\Middleware;
- use LinFly\Annotation\Attributes\Route\PostMapping;
- use support\Request;
- use support\Response;
- #[Controller("/api/pages"),Middleware(AuthMiddleware::class)]
- class Pages extends Base
- {
- #[Inject]
- protected PageService $service;
- #[Inject]
- protected CpaPage $model;
- #[GetMapping('list')]
- public function getDataList(Request $request): Response
- {
- try {
- $param = $request->all();
- $data = $this->service->setModel()->getList($param,['product','account']);
- return successTrans("success.data",pageFormat($data),200);
- } catch (\Throwable $th) {
- return error($th->getMessage());
- }
- }
- #[PostMapping("save")]
- public function setDepositData(Request $request): Response
- {
- try {
- $param = $request->post();
- $state = $this->model->setAutoData($param);
- if (!$state) return errorTrans("error.data");
- return successTrans("success.data");
- } catch (\Throwable $throwable) {
- return error($throwable->getMessage());
- }
- }
- }
|