mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-28 21:40:50 +00:00
92 lines
2.4 KiB
PHP
92 lines
2.4 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||
// +----------------------------------------------------------------------
|
||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||
// +----------------------------------------------------------------------
|
||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||
// +----------------------------------------------------------------------
|
||
// | Author: CRMEB Team <admin@crmeb.com>
|
||
// +----------------------------------------------------------------------
|
||
namespace app\adminapi\controller\product;
|
||
|
||
use app\adminapi\controller\AuthController;
|
||
use app\services\product\ProductRuleServices;
|
||
use think\facade\App;
|
||
|
||
/**
|
||
* 规则管理
|
||
* Class StoreProductRule
|
||
* @package app\adminapi\controller\product
|
||
*/
|
||
class StoreProductRuleController extends AuthController
|
||
{
|
||
/**
|
||
* @var ProductRuleServices
|
||
*/
|
||
protected $services;
|
||
|
||
public function __construct(App $app, ProductRuleServices $service)
|
||
{
|
||
parent::__construct($app);
|
||
$this->services = $service;
|
||
}
|
||
|
||
/**
|
||
* 规格列表
|
||
* @return mixed
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
*/
|
||
public function index()
|
||
{
|
||
$where = $this->request->getMore([
|
||
['rule_name', '']
|
||
]);
|
||
$list = $this->services->getList($where);
|
||
return app('json')->success($list);
|
||
}
|
||
|
||
/**
|
||
* 保存规格
|
||
* @param $id
|
||
* @return mixed
|
||
*/
|
||
public function save($id)
|
||
{
|
||
$data = $this->request->postMore([
|
||
['rule_name', ''],
|
||
['spec', []]
|
||
]);
|
||
$this->services->save($id, $data);
|
||
return app('json')->success('保存成功');
|
||
}
|
||
|
||
/**
|
||
* 获取规格信息
|
||
* @param $id
|
||
* @return mixed
|
||
*/
|
||
public function read($id)
|
||
{
|
||
$info = $this->services->getInfo($id);
|
||
return app('json')->success($info);
|
||
}
|
||
|
||
/**
|
||
* 删除指定资源
|
||
*
|
||
* @param int $id
|
||
* @return \think\Response
|
||
*/
|
||
public function delete()
|
||
{
|
||
[$ids] = $this->request->postMore([
|
||
['ids', '']
|
||
], true);
|
||
$this->services->del((string)$ids);
|
||
return app('json')->success('删除成功');
|
||
}
|
||
}
|