| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace app\api\controller;
- use app\api\service\ProductService;
- use app\BaseController;
- use app\Request;
- use think\App;
- class Product extends BaseController
- {
- private $service;
- public function __construct(App $app)
- {
- $this->service = new ProductService();
- parent::__construct($app);
- }
- public function search(Request $request) {
- $params = $request->param();
- predicate(isset($params['store_id']) && $params['store_id'] > 0, lang('Store information does not exist'));
- $res = $this->service->search(
- $params['store_id'],
- format_string($params['bar_code'] ?? null),
- format_string($params['product_name'] ?? null),
- $params['page'] ?? 1,
- $params['size'] ?? 10
- );
- return $this->ok($res);
- }
- /**
- * @return \think\response\Json
- */
- public function upload() {
- // 获取表单上传文件 例如上传了001.jpg
- $file = request()->file('file');
- // 上传到本地服务器
- $save_name = \think\facade\Filesystem::disk('public')->putFile( 'numerology', $file);
- return $this->ok(str_replace('\\',"/",'/storage/'.$save_name));
- }
- }
|