erp/app/admin/controller/goods/GoodsController.php
2024-04-27 11:41:34 +08:00

103 lines
2.4 KiB
PHP

<?php
namespace app\admin\controller\goods;
use app\admin\controller\BaseAdminController;
use app\admin\lists\goods\GoodsLists;
use app\admin\logic\goods\GoodsLogic;
use app\admin\validate\goods\GoodsValidate;
/**
* 商品列表控制器
* Class GoodsController
* @package app\admin\controller\goods
*/
class GoodsController extends BaseAdminController
{
/**
* @notes 获取商品列表列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/23 11:28
*/
public function lists()
{
return $this->dataLists(new GoodsLists());
}
/**
* @notes 添加商品列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/23 11:28
*/
public function add()
{
$params = (new GoodsValidate())->post()->goCheck('add');
$result = GoodsLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(GoodsLogic::getError());
}
/**
* @notes 编辑商品列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/23 11:28
*/
public function edit()
{
$params = (new GoodsValidate())->post()->goCheck('edit');
$result = GoodsLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(GoodsLogic::getError());
}
/**
* @notes 删除商品列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/23 11:28
*/
public function delete()
{
$params = (new GoodsValidate())->post()->goCheck('delete');
GoodsLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取商品列表详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/23 11:28
*/
public function detail()
{
$params = (new GoodsValidate())->goCheck('detail');
$result = GoodsLogic::detail($params);
return $this->data($result);
}
public function setLabel(){
$params=$this->request->post();
$result = GoodsLogic::setLabel($params);
if (true === $result) {
return $this->success('设置成功', [], 1, 1);
}
return $this->fail(GoodsLogic::getError());
}
}