| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace app\controller\adminapi\cutter;
- use app\extra\basic\Base;
- use app\extra\service\cutter\CutterApplyService;
- use app\extra\service\user\UserService;
- use app\middleware\AuthMiddleware;
- use app\validate\system\UserValidate;
- use DI\Attribute\Inject;
- use LinFly\Annotation\Route\Controller;
- use LinFly\Annotation\Route\Middleware;
- use LinFly\Annotation\Route\Route;
- use support\Request;
- use support\Response;
- #[Controller(prefix: "/adminapi/cutter/apply"),Middleware(AuthMiddleware::class)]
- class CutterApply extends Base
- {
- #[Inject]
- protected CutterApplyService $service;
- #[Inject]
- protected UserService $userService;
- #[Route(path: "list",methods: "get")]
- public function getList(Request $request): Response
- {
- try {
- $param = $request->get();
- $list = $this->service->getList($param,'*',$param['page']??0,$param['limit']??0);
- return successTrans("success.data",$list);
- } catch (\Throwable $throwable) {
- return error($throwable->getMessage());
- }
- }
- #[Route(path: "info/{id}",methods: "get")]
- public function info($id): Response
- {
- try {
- $take = $this->service->getOne(["id"=>$id,'status'=>1,'is_del'=>0]);
- if ($take->isEmpty()) return errorTrans("empty.error");
- return successTrans("success.data",$take->toArray());
- } catch (\Throwable $throwable) {
- return error($throwable->getMessage());
- }
- }
- #[Route(path: "agreed/{id}",methods: "post")]
- public function agreed($id): Response
- {
- try {
- $apply = $this->service->getOne(["id"=>$id]);
- if ($apply->isEmpty()) return errorTrans("empty.error");
- $state = $this->service->update($id,['status'=>1]) && $this->userService->update($apply['uid'],['is_cutter'=>1]);
- if (!$state) return errorTrans("error.data");
- return successTrans("success.data");
- } catch (\Throwable $throwable) {
- return error($throwable->getMessage());
- }
- }
- #[Route(path: "refuse/{id}",methods: "post")]
- public function refuse (Request $request,$id): Response
- {
- try {
- $remark = $request->post('remark','');
- $apply = $this->service->getOne(["id"=>$id]);
- if ($apply->isEmpty()) return errorTrans("empty.error");
- $state = $this->service->update($id,['status'=>2,'remark'=>$remark]);
- if (!$state) return errorTrans("error.data");
- return successTrans("success.data");
- } catch (\Throwable $throwable) {
- return error($throwable->getMessage());
- }
- }
- }
|