63 lines
1.5 KiB
PHP
63 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace app\controller\api;
|
|
|
|
use app\exception\RepositoryException;
|
|
use app\repository\GoodsRepository;
|
|
use app\validate\Goods as GoodsValidate;
|
|
use Exception;
|
|
use think\response\Json;
|
|
|
|
/**
|
|
* 测试用
|
|
*
|
|
* Class DepartmentGoodsListLog
|
|
* @package app\controller\api
|
|
*/
|
|
class DepartmentGoodsListLog extends Base
|
|
{
|
|
/**
|
|
* @return Json
|
|
* @throws RepositoryException
|
|
*/
|
|
public function list()
|
|
{
|
|
$params = $this->request->param();
|
|
$validate = new GoodsValidate();
|
|
if (!$validate->scene('base')->check($params)) {
|
|
return $this->json(4001, $validate->getError());
|
|
}
|
|
|
|
$data = GoodsRepository::getInstance()->list();
|
|
|
|
return $this->json(0, 'success', $data);
|
|
}
|
|
|
|
/**
|
|
* 获取分类列表
|
|
*
|
|
* @return Json
|
|
* @throws Exception
|
|
*/
|
|
public function category()
|
|
{
|
|
$params = $this->request->param();
|
|
$validate = new GoodsValidate();
|
|
if (!$validate->scene('base')->check($params)) {
|
|
return $this->json(4001, $validate->getError());
|
|
}
|
|
|
|
$data = GoodsRepository::getInstance()->categoryList();
|
|
|
|
return $this->json(0, 'success', $data);
|
|
}
|
|
|
|
public function testApiClassMethod()
|
|
{
|
|
$header = $this->request->header();
|
|
$all = $this->request->param();
|
|
$get = input('get.');
|
|
$post = input('post.');
|
|
return $this->json(0, 'success', ['cost'=>$cost ?? 0]);
|
|
}
|
|
} |