|
|
@@ -0,0 +1,64 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\controller\admin;
|
|
|
+
|
|
|
+use app\extra\basic\Base;
|
|
|
+use app\middleware\AuthMiddleware;
|
|
|
+use LinFly\Annotation\Route\Controller;
|
|
|
+use LinFly\Annotation\Route\Route;
|
|
|
+use support\Request;
|
|
|
+use support\Response;
|
|
|
+use Webman\Annotation\Middleware;
|
|
|
+
|
|
|
+
|
|
|
+#[Controller(prefix: "/api/cloth"),Middleware(AuthMiddleware::class)]
|
|
|
+class Cloth extends Base
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+ #[Route(path: "color",methods: ["get","post"])]
|
|
|
+ public function getColor(Request $request): Response
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ if ($request->method() == "GET")
|
|
|
+ {
|
|
|
+ $param = $this->_valid([
|
|
|
+ "type.require" => trans("error.require"),
|
|
|
+ ]);
|
|
|
+ return success("ok",['data' => sData($param['type']),"num" => count(sData($param['type']))]);
|
|
|
+ } else {
|
|
|
+ $param = $request->post();
|
|
|
+ if (!is_array($param)) return error($param);
|
|
|
+ $sysData = sData($param['type']);
|
|
|
+ $sysData[$param['num']] = $param;
|
|
|
+ $state = sData($param['type'],$sysData);
|
|
|
+ if (!$state) return errorTrans(100011);
|
|
|
+ return successTrans(100010);
|
|
|
+ }
|
|
|
+ } catch (\Throwable $throwable) {
|
|
|
+ return error($throwable->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #[Route(path: "del",methods: "post")]
|
|
|
+ public function delColor(): Response
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $param = $this->_valid([
|
|
|
+ "id.require" => trans("error.require"),
|
|
|
+ "type.require" => trans("error.require"),
|
|
|
+ ],"post");
|
|
|
+ if (!is_array($param)) return error($param);
|
|
|
+ $data = sData($param['type']);
|
|
|
+ unset($data[$param['id']]);
|
|
|
+ $data = array_values($data);
|
|
|
+ $state = sData($param['type'],$data);
|
|
|
+ if (!$state) return errorTrans("error.data");
|
|
|
+ return successTrans("success.data");
|
|
|
+ } catch (\Throwable $throwable) {
|
|
|
+ return error($throwable->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|