| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace app\controller\common;
- use app\extra\basic\Base;
- use app\model\system\SystemConfig;
- use app\model\system\SystemData;
- use LinFly\Annotation\Route\Controller;
- use LinFly\Annotation\Route\Route;
- use support\Request;
- use support\Response;
- use Tinywan\Captcha\Captcha;
- /**
- *
- */
- #[Controller(prefix: "/api/service")]
- class Common extends Base
- {
- /**
- *
- */
- #[Route(path: "data",methods: "get")]
- public function getServiceData(): Response
- {
- try {
- $captcha = Captcha::base64();
- $service = (new SystemConfig)->where("type","service")->column("value","name");
- $service['privacy'] = htmlspecialchars_decode(sConf("page.privacy"));
- return successTrans("success.data",compact('captcha','service'));
- } catch (\Throwable $throwable) {
- return error($throwable->getMessage());
- }
- }
- #[Route(path: "dic",methods: "get")]
- public function getDicData(Request $request): Response
- {
- try {
- $param = $this->_valid([
- "type.require" => trans("empty.require")
- ],$request->all());
- if (!is_array($param)) return error($param);
- $data = (new SystemData)->where("code",$param['type'])->value("content");
- $data = !empty($data) ? json_decode($data,true) : [];
- return successTrans("success.data",$data);
- } catch (\Throwable $throwable) {
- return error($throwable->getMessage());
- }
- }
- }
|