update
This commit is contained in:
@ -44,4 +44,70 @@ class WebsiteController extends AbstractController
|
||||
{
|
||||
return $render->render('website/view');
|
||||
}
|
||||
|
||||
/**
|
||||
* @url /admin/website/first-column
|
||||
* @param RenderInterface $render
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'first-column', methods: 'get')]
|
||||
public function firstColumn(RenderInterface $render): ResponseInterface
|
||||
{
|
||||
return $render->render('website/first-column/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @url /admin/website/first-column/insert
|
||||
* @param RenderInterface $render
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'first-column/insert', methods: 'get')]
|
||||
public function firstColumnInsert(RenderInterface $render): ResponseInterface
|
||||
{
|
||||
return $render->render('website/first-column/insert');
|
||||
}
|
||||
|
||||
/**
|
||||
* @url /admin/website/first-column/view
|
||||
* @param RenderInterface $render
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'first-column/view', methods: 'get')]
|
||||
public function firstColumnView(RenderInterface $render): ResponseInterface
|
||||
{
|
||||
return $render->render('website/first-column/view');
|
||||
}
|
||||
|
||||
/**
|
||||
* @url /admin/website/second-column
|
||||
* @param RenderInterface $render
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'second-column', methods: 'get')]
|
||||
public function secondColumn(RenderInterface $render): ResponseInterface
|
||||
{
|
||||
return $render->render('website/second-column/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @url /admin/website/second-column/insert
|
||||
* @param RenderInterface $render
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'second-column/insert', methods: 'get')]
|
||||
public function secondColumnInsert(RenderInterface $render): ResponseInterface
|
||||
{
|
||||
return $render->render('website/second-column/insert');
|
||||
}
|
||||
|
||||
/**
|
||||
* @url /admin/website/second-column/view
|
||||
* @param RenderInterface $render
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'second-column/view', methods: 'get')]
|
||||
public function secondColumnView(RenderInterface $render): ResponseInterface
|
||||
{
|
||||
return $render->render('website/second-column/view');
|
||||
}
|
||||
}
|
@ -88,7 +88,7 @@ class NewsController extends AbstractController
|
||||
public function insert()
|
||||
{
|
||||
$model = new NewsFormModel();
|
||||
$model->setAttributes($this->request->post(), ['title', 'keywords', 'description', 'cover', 'content', 'platform']);
|
||||
$model->setAttributes($this->request->post(), ['title', 'keywords', 'description', 'cover', 'content', 'platform', 'column1', 'column2']);
|
||||
$model->insert();
|
||||
return $this->response->json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
@ -104,6 +104,7 @@ class NewsController extends AbstractController
|
||||
$content = $this->request->post('content', null);
|
||||
$platform = $this->request->post('platform', 0);
|
||||
$column = $this->request->post('column', 0);
|
||||
$column2 = $this->request->post('column2', 0);
|
||||
// 随机图片
|
||||
$directory = env('COVER_ROOT'); // 文件夹路径
|
||||
$images = glob($directory . '/*.{jpg,jpeg,png,gif,bmp}', GLOB_BRACE); // 获取图片文件
|
||||
@ -139,6 +140,7 @@ class NewsController extends AbstractController
|
||||
EOF
|
||||
]);
|
||||
$model->column_tag = $column;
|
||||
$model->second_column = $column2;
|
||||
$model->save();
|
||||
}
|
||||
return $this->response->json(['code' => 0, 'msg' => 'ok']);
|
||||
|
@ -3,6 +3,8 @@
|
||||
namespace App\Controller\admin\api;
|
||||
|
||||
use App\Controller\AbstractController;
|
||||
use App\Model\AppNewsColumn;
|
||||
use App\Model\AppNewsSecondColumn;
|
||||
use App\Model\AppWebsiteConfig;
|
||||
use Hyperf\HttpServer\Annotation\Controller;
|
||||
use Hyperf\HttpServer\Annotation\RequestMapping;
|
||||
@ -119,4 +121,167 @@ class WebsiteController extends AbstractController
|
||||
|
||||
return $this->response->json(['code' => 0, 'msg' => 'ok', 'data' => $query]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 一级栏目列表
|
||||
* @url /admin/api/website/first-column
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'first-column', methods: 'get')]
|
||||
public function firstColumn(): ResponseInterface
|
||||
{
|
||||
$query = AppNewsColumn::query()->where('is_delete', 0)->get()->toArray();
|
||||
|
||||
foreach ($query as &$item) {
|
||||
$item['website'] = AppWebsiteConfig::find($item['website'])->app_name;
|
||||
}
|
||||
|
||||
return $this->response->json([
|
||||
'code' => 0,
|
||||
'data' => $query
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增一级栏目
|
||||
* @url /admin/api/website/first-column/insert
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'first-column/insert', methods: 'post')]
|
||||
public function firstColumnInsert(): ResponseInterface
|
||||
{
|
||||
$model = new AppNewsColumn();
|
||||
$model->name = $this->request->post('name');
|
||||
$model->website = $this->request->post('website');
|
||||
$model->url = $this->request->post('url');
|
||||
$model->desc = $this->request->post('desc');
|
||||
$model->save();
|
||||
|
||||
return $this->response->json([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @url /admin/api/website/first-column/view
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'first-column/view', methods: 'get')]
|
||||
public function firstColumnView(): ResponseInterface
|
||||
{
|
||||
$id = $this->request->input('id');
|
||||
|
||||
$query = AppNewsColumn::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/first-column/save
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'first-column/save', methods: 'post')]
|
||||
public function firstColumnSave(): ResponseInterface
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
|
||||
$query = AppNewsColumn::find($id);
|
||||
if (!$query) {
|
||||
return $this->response->json(['code' => 400, 'msg' => 'id 有误']);
|
||||
}
|
||||
|
||||
$query->website = $this->request->post('website');
|
||||
$query->name = $this->request->post('name');
|
||||
$query->url = $this->request->post('url');
|
||||
$query->desc = $this->request->post('desc');
|
||||
$query->save();
|
||||
|
||||
return $this->response->json(['code' => 0, 'msg' => 'ok', 'data' => $query]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 二级栏目列表
|
||||
* @url /admin/api/website/second-column
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'second-column', methods: 'get')]
|
||||
public function secondColumn(): ResponseInterface
|
||||
{
|
||||
$query = AppNewsSecondColumn::query()->where('is_delete', 0);
|
||||
$pagination = $query->paginate($this->request->input('limit', 10), page: $this->request->input('page'));
|
||||
$data = $query->get()->toArray();
|
||||
foreach ($data as &$item) {
|
||||
$query = AppWebsiteConfig::find($item['website']);
|
||||
$item['website'] = $query->app_name;
|
||||
$item['rid'] = AppNewsColumn::find($item['rid'])->name;
|
||||
}
|
||||
|
||||
return $this->response->json([
|
||||
'code' => 0,
|
||||
'data' => $data,
|
||||
'count' => $pagination->total()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增二级栏目
|
||||
* @url /admin/api/website/second-column/insert
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'second-column/insert', methods: 'post')]
|
||||
public function secondColumnInsert(): ResponseInterface
|
||||
{
|
||||
$model = new AppNewsSecondColumn();
|
||||
$model->name = $this->request->post('name');
|
||||
$model->website = $this->request->post('website');
|
||||
$model->url = $this->request->post('url');
|
||||
$model->desc = $this->request->post('desc');
|
||||
$model->rid = $this->request->post('rid');
|
||||
$model->save();
|
||||
|
||||
return $this->response->json([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @url /admin/api/website/second-column/view
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'second-column/view', methods: 'get')]
|
||||
public function secondColumnView(): ResponseInterface
|
||||
{
|
||||
$id = $this->request->input('id');
|
||||
|
||||
$query = AppNewsSecondColumn::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/second-column/save
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
#[RequestMapping(path: 'second-column/save', methods: 'post')]
|
||||
public function secondColumnSave(): ResponseInterface
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
|
||||
$query = AppNewsSecondColumn::find($id);
|
||||
if (!$query) {
|
||||
return $this->response->json(['code' => 400, 'msg' => 'id 有误']);
|
||||
}
|
||||
|
||||
$query->website = $this->request->post('website');
|
||||
$query->name = $this->request->post('name');
|
||||
$query->url = $this->request->post('url');
|
||||
$query->desc = $this->request->post('desc');
|
||||
$query->rid = $this->request->post('rid');
|
||||
$query->save();
|
||||
|
||||
return $this->response->json(['code' => 0, 'msg' => 'ok', 'data' => $query]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user