feat 添加产品管理接口
This commit is contained in:
parent
f03755613e
commit
1de69a90a7
76
app/api/controller/Products/Product.php
Normal file
76
app/api/controller/Products/Product.php
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller\Products;
|
||||||
|
|
||||||
|
use app\BaseController;
|
||||||
|
use app\common\model\Products\Product as ModelProduct;
|
||||||
|
use app\Request;
|
||||||
|
use think\Validate;
|
||||||
|
use think\exception\ValidateException;
|
||||||
|
use think\facade\Filesystem;
|
||||||
|
use app\common\arw\adjfut\src\Excel;
|
||||||
|
use app\common\arw\adjfut\src\UploadFile;
|
||||||
|
use think\facade\Db;
|
||||||
|
use app\common\exception\Tool;
|
||||||
|
use think\facade\Env;
|
||||||
|
|
||||||
|
|
||||||
|
class Product extends BaseController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取产品列表
|
||||||
|
*/
|
||||||
|
public function getProductList(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$con = [];
|
||||||
|
|
||||||
|
$con = Tool::getOptionalQuery(['product_type_guid', '='], ['product_name', 'LIKE'],);
|
||||||
|
|
||||||
|
$query = ModelProduct::where($con)
|
||||||
|
->field([
|
||||||
|
'product_id',
|
||||||
|
'product_guid',
|
||||||
|
'product_type_guid',
|
||||||
|
'product_name',
|
||||||
|
'product_img',
|
||||||
|
'product_description',
|
||||||
|
'product_link',
|
||||||
|
'product_details',
|
||||||
|
'product_sort'
|
||||||
|
])
|
||||||
|
->order('product_sort', 'asc')
|
||||||
|
->select();
|
||||||
|
|
||||||
|
return msg(0, "获取产品列表成功!", [
|
||||||
|
'data' => $query,
|
||||||
|
'count' => count($query)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取产品详情
|
||||||
|
*/
|
||||||
|
public function getProductInfo(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
|
||||||
|
$this->validate($params, ['product_id' => 'require']);
|
||||||
|
|
||||||
|
$find = ModelProduct::field([
|
||||||
|
'product_id',
|
||||||
|
'product_guid',
|
||||||
|
'product_type_guid',
|
||||||
|
'product_name',
|
||||||
|
'product_img',
|
||||||
|
'product_description',
|
||||||
|
'product_link',
|
||||||
|
'product_details',
|
||||||
|
'product_sort'
|
||||||
|
])
|
||||||
|
->where('product_id', $params['product_id'])
|
||||||
|
->find();
|
||||||
|
|
||||||
|
return msg(0, '获取产品详情成功!', ['data' => $find]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user