dlh_test_server/app/admin/controller/MallNews.php
2024-08-09 02:28:04 +08:00

172 lines
4.7 KiB
PHP
Executable File

<?php
namespace app\admin\controller;
use app\admin\logic\goods\GoodsLogic;
use app\admin\logic\MallNewsLogic;
use app\common\basics\AdminBase;
use app\common\server\JsonServer;
class MallNews extends AdminBase
{
public function lists()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
$lists = MallNewsLogic::lists($get);
return JsonServer::success('', $lists);
}
return view('');
}
public function add()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$result = MallNewsLogic::create($post);
if ($result['code'] == 1) {
return JsonServer::success('添加成功');
}
return JsonServer::error($result['msg']);
}
return view('', [
'max_upload_size' => MallNewsLogic::$MAX_UPLOAD_SIZE . 'Mb',
'max_upload_file' => MallNewsLogic::$MAX_UPLOAD_FILE,
]);
}
public function audit()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$result = MallNewsLogic::edit($post);
if ($result['code'] == 1) {
return JsonServer::success('修改成功');
}
return JsonServer::error($result['msg']);
}
$id = $this->request->get('id');
return view('', [
'detail' => MallNewsLogic::detail($id),
'max_upload_size' => MallNewsLogic::$MAX_UPLOAD_SIZE . 'Mb',
'max_upload_file' => MallNewsLogic::$MAX_UPLOAD_FILE,
]);
}
// 上传视频到OSS
public function uploadVideo()
{
$result = MallNewsLogic::uploadVideo();
if ($result['code'] == 1) {
return JsonServer::success('', $result['data']);
}
return JsonServer::error('', $result['msg']);
}
// 删除视频
public function delVideo()
{
if ($this->request->isAjax()) {
$file = $this->request->post('videoFile');
MallNewsLogic::delVideo($file);
}
}
// 删除文章
public function del()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$result = MallNewsLogic::del($post['id']);
if ($result) {
return JsonServer::success('删除成功');
}
return JsonServer::error('删除失败');
}
}
// 选择商品
public function goods()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
return JsonServer::success('', GoodsLogic::lists($get));
}
return view();
}
// 快讯商品列表
public function shop()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
$lists = MallNewsLogic::shop_list($get);
return JsonServer::success('', $lists);
}
return view('');
}
// 添加快讯商品
public function add_shop()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$result = MallNewsLogic::create_shop($post);
if ($result['code'] == 1) {
return JsonServer::success('添加成功');
}
return JsonServer::error($result['msg']);
}
return view('',[
'max_upload_file' => MallNewsLogic::$MAX_UPLOAD_FILE,
]);
}
// 修改快讯商品
public function audit_shop()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$result = MallNewsLogic::edit_shop($post);
if ($result['code'] == 1) {
return JsonServer::success('修改成功');
}
return JsonServer::error($result['msg']);
}
$id = $this->request->get('id');
return view('', [
'detail' => MallNewsLogic::shop_detail($id),
'max_upload_file' => MallNewsLogic::$MAX_UPLOAD_FILE,
]);
}
// 删除快讯商品
public function del_shop()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$result = MallNewsLogic::del_shop($post['id']);
if ($result) {
return JsonServer::success('删除成功');
}
return JsonServer::error('删除失败');
}
}
// 快讯页面获取商品
public function mall_news_goods()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
$lists = MallNewsLogic::shop_list($get);
return JsonServer::success('', $lists);
}
return view('');
}
}