dlhmaster/app/admin/controller/NewGoods.php

77 lines
1.9 KiB
PHP
Raw Normal View History

2024-07-26 22:21:59 +08:00
<?php
namespace app\admin\controller;
use app\admin\logic\goods\GoodsLogic;
use app\common\basics\AdminBase;
use app\common\server\JsonServer;
use app\admin\logic\NewGoodsLogic;
class NewGoods extends AdminBase
{
public function lists()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
$lists = NewGoodsLogic::lists($get);
return JsonServer::success('', $lists);
}
return view();
}
public function add()
{
if ($this->request->isAjax()) {
$form = $this->request->post();
$result = NewGoodsLogic::create($form);
if ($result['code'] == 1) {
return JsonServer::success('添加成功');
}
return JsonServer::error($result['msg']);
}
return view('');
}
// 修改
public function audit()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$result = NewGoodsLogic::edit($post);
if ($result['code'] == 1) {
return JsonServer::success('修改成功');
}
return JsonServer::error($result['msg']);
}
$id = $this->request->get('id');
return view('', [
'detail' => NewGoodsLogic::detail($id)
]);
}
// 删除
public function del()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$result = NewGoodsLogic::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();
}
}