update
This commit is contained in:
47
app/Controller/admin/WebsiteController.php
Normal file
47
app/Controller/admin/WebsiteController.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller\admin;
|
||||||
|
|
||||||
|
use App\Controller\AbstractController;
|
||||||
|
use App\Model\AppWebsiteConfig;
|
||||||
|
use Hyperf\HttpServer\Annotation\Controller;
|
||||||
|
use Hyperf\HttpServer\Annotation\RequestMapping;
|
||||||
|
use Hyperf\View\RenderInterface;
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
|
||||||
|
#[Controller(prefix: 'admin/website')]
|
||||||
|
class WebsiteController extends AbstractController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @url /admin/website/config
|
||||||
|
* @param RenderInterface $render
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
#[RequestMapping(path: 'config', methods: 'get')]
|
||||||
|
public function config(RenderInterface $render): ResponseInterface
|
||||||
|
{
|
||||||
|
return $render->render('website/index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @url /admin/website/config/insert
|
||||||
|
* @param RenderInterface $render
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
#[RequestMapping(path: 'config/insert', methods: 'get')]
|
||||||
|
public function insert(RenderInterface $render): ResponseInterface
|
||||||
|
{
|
||||||
|
return $render->render('website/insert');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @url /admin/website/config/view
|
||||||
|
* @param RenderInterface $render
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
#[RequestMapping(path: 'config/view', methods: 'get')]
|
||||||
|
public function view(RenderInterface $render): ResponseInterface
|
||||||
|
{
|
||||||
|
return $render->render('website/view');
|
||||||
|
}
|
||||||
|
}
|
107
app/Controller/admin/api/WebsiteController.php
Normal file
107
app/Controller/admin/api/WebsiteController.php
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller\admin\api;
|
||||||
|
|
||||||
|
use App\Controller\AbstractController;
|
||||||
|
use App\Model\AppWebsiteConfig;
|
||||||
|
use Hyperf\HttpServer\Annotation\Controller;
|
||||||
|
use Hyperf\HttpServer\Annotation\RequestMapping;
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
|
||||||
|
#[Controller(prefix: 'admin/api/website')]
|
||||||
|
class WebsiteController extends AbstractController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @url /admin/api/website/config
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
#[RequestMapping(path: 'config', methods: 'get')]
|
||||||
|
public function config(): ResponseInterface
|
||||||
|
{
|
||||||
|
$query = AppWebsiteConfig::query()->where('is_delete', 0)->get()->toArray();
|
||||||
|
return $this->response->json([
|
||||||
|
'code' => 0,
|
||||||
|
'data' => $query
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @url /admin/api/website/config/insert
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
#[RequestMapping(path: 'config/insert', methods: 'post')]
|
||||||
|
public function configInsert(): ResponseInterface
|
||||||
|
{
|
||||||
|
$model = new AppWebsiteConfig();
|
||||||
|
$model->app_company = $this->request->post('app_company');
|
||||||
|
$model->app_description = $this->request->post('app_description');
|
||||||
|
$model->app_name = $this->request->post('app_name');
|
||||||
|
$model->app_domain = $this->request->post('app_domain');
|
||||||
|
$model->save();
|
||||||
|
|
||||||
|
return $this->response->json([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @url /admin/api/website/config/delete
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
#[RequestMapping(path: 'config/delete', methods: 'post')]
|
||||||
|
public function configDelete(): ResponseInterface
|
||||||
|
{
|
||||||
|
$id = $this->request->post('id');
|
||||||
|
|
||||||
|
$query = AppWebsiteConfig::find($id);
|
||||||
|
if (!$query) {
|
||||||
|
return $this->response->json(['code' => 400, 'msg' => 'id 有误']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query->is_delete = 1;
|
||||||
|
$query->save();
|
||||||
|
return $this->response->json([
|
||||||
|
'code' => 0,
|
||||||
|
'data' => $query
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @url /admin/api/website/config/view
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
#[RequestMapping(path: 'config/view', methods: 'get')]
|
||||||
|
public function configView(): ResponseInterface
|
||||||
|
{
|
||||||
|
$id = $this->request->input('id');
|
||||||
|
|
||||||
|
$query = AppWebsiteConfig::query()->where(['id' => $id])->first()->toArray();
|
||||||
|
if (!$query) {
|
||||||
|
return $this->response->json(['code' => 400, 'msg' => 'id 有误']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response->json(['code' => 0, 'msg' => 'ok', 'data' => $query]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @url /admin/api/website/config/save
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
#[RequestMapping(path: 'config/save', methods: 'post')]
|
||||||
|
public function configSave(): ResponseInterface
|
||||||
|
{
|
||||||
|
$id = $this->request->post('id');
|
||||||
|
|
||||||
|
$query = AppWebsiteConfig::find($id);
|
||||||
|
if (!$query) {
|
||||||
|
return $this->response->json(['code' => 400, 'msg' => 'id 有误']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query->app_company = $this->request->post('app_company');
|
||||||
|
$query->app_description = $this->request->post('app_description');
|
||||||
|
$query->app_name = $this->request->post('app_name');
|
||||||
|
$query->app_domain = $this->request->post('app_domain');
|
||||||
|
|
||||||
|
$query->save();
|
||||||
|
|
||||||
|
return $this->response->json(['code' => 0, 'msg' => 'ok', 'data' => $query]);
|
||||||
|
}
|
||||||
|
}
|
@ -86,10 +86,15 @@ var_dump($requestData);
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
list($title, $desc) = call_user_func(function () use ($value) {
|
list($title, $desc) = call_user_func(function () use ($value, $requestData) {
|
||||||
$content = $value['content'];
|
$content = $value['content'];
|
||||||
|
|
||||||
$ex = explode(PHP_EOL . PHP_EOL, $content);
|
if ($requestData['platform'] == 3) {
|
||||||
|
$de = PHP_EOL;
|
||||||
|
} else {
|
||||||
|
$de = PHP_EOL . PHP_EOL;
|
||||||
|
}
|
||||||
|
$ex = explode($de, $content);
|
||||||
if (count($ex) > 1) {
|
if (count($ex) > 1) {
|
||||||
return [$ex[0], $ex[1]];
|
return [$ex[0], $ex[1]];
|
||||||
}
|
}
|
||||||
|
29
app/Rpc/v1/WebsiteService.php
Normal file
29
app/Rpc/v1/WebsiteService.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Rpc\v1;
|
||||||
|
|
||||||
|
use App\Model\AppNews;
|
||||||
|
use App\Model\AppWebsiteConfig;
|
||||||
|
use App\Rpc\BaseService;
|
||||||
|
use Hyperf\RpcServer\Annotation\RpcService;
|
||||||
|
|
||||||
|
#[RpcService(name: "website", server: "jsonrpc-http", protocol: "jsonrpc-http")]
|
||||||
|
class WebsiteService extends BaseService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查看单个新闻详情
|
||||||
|
* @url /news/view
|
||||||
|
* @param $id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function config($host): array
|
||||||
|
{
|
||||||
|
$query = AppWebsiteConfig::query()->where('app_domain', $host)->where('is_delete', 0)->first()?->toArray();
|
||||||
|
|
||||||
|
if (!$query) {
|
||||||
|
return $this->getResponse()->setCode(404)->send();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->getResponse()->setData($query)->setCode(0)->send();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user