| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace app\controller\store;
- use app\extra\basic\Base;
- use app\middleware\AuthMiddleware;
- use app\model\saas\SaasStore;
- use DI\Attribute\Inject;
- use LinFly\Annotation\Route\Controller;
- use LinFly\Annotation\Route\Route;
- use support\Request;
- use support\Response;
- use Webman\Annotation\Middleware;
- #[Controller(prefix: "/api/store/shop"),Middleware(AuthMiddleware::class)]
- class Shop extends Base
- {
- #[Inject]
- protected SaasStore $mode;
- #[Route(path: "detail",methods: "get")]
- public function getShopDetail(Request $request): Response
- {
- try {
- $map = ["store_id" => $request->user['store_id'],'agent_id' => $request->user['agent_id']];
- $detail = $this->mode->where($map)->findOrEmpty();
- if ($detail->isEmpty()) return error("店铺信息错误");
- return success("ok",$detail->toArray());
- } catch (\Throwable $throwable) {
- return error($throwable->getMessage());
- }
- }
- /**
- * 保存
- * @param Request $request
- * @return Response
- */
- #[Route(path: "save",methods: "post")]
- public function setUserData(Request $request): Response
- {
- try {
- $param = $request->post();
- $store = $this->mode->where("store_id",$request->user['store_id'])->findOrEmpty();
- if ($store->isEmpty()) return errorTrans(40015);
- $state = $this->mode->setAutoData($param,"store_id");
- if (!$state) return errorTrans("error.data");
- return successTrans("success.data");
- } catch (\Throwable $throwable) {
- return error($throwable->getMessage());
- }
- }
- }
|