123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?php
- namespace app\controller\supplier\product;
- use app\controller\supplier\AuthController;
- use app\services\product\brand\StoreBrandServices;
- use think\facade\App;
- class StoreBrand extends AuthController
- {
-
- protected $service;
-
- public function __construct(App $app, StoreBrandServices $service)
- {
- parent::__construct($app);
- $this->service = $service;
- }
-
- public function index()
- {
- $where = $this->request->getMore([
- ['brand_name', ''],
- ['pid', 0]
- ]);
- $where['is_del'] = 0;
- $data = $this->service->getList($where);
- return $this->success($data);
- }
-
- public function cascader_list($type = 1)
- {
- return $this->success($this->service->cascaderList($type));
- }
-
- public function set_show($is_show = '', $id = '')
- {
- if ($is_show == '' || $id == '') return $this->fail('缺少参数');
- $this->service->setShow($id, $is_show);
- return $this->success($is_show == 1 ? '显示成功' : '隐藏成功');
- }
-
- public function save()
- {
- $data = $this->request->postMore([
- ['fid', []],
- ['brand_name', ''],
- ['sort', 0],
- ['is_show', 0]
- ]);
- if (!$data['brand_name']) {
- return $this->fail('请输入品牌名称');
- }
- if (iconv_strlen($data['brand_name'], 'UTF-8') > 10) {
- return $this->fail('品牌名称过长');
- }
- $this->service->createData($data);
- return $this->success('添加品牌成功!');
- }
-
- public function update($id)
- {
- $data = $this->request->postMore([
- ['fid', []],
- ['brand_name', ''],
- ['sort', 0],
- ['is_show', 0]
- ]);
- if (!$data['brand_name']) {
- return $this->fail('请输入品牌名称');
- }
- if (iconv_strlen($data['brand_name'], 'UTF-8') > 10) {
- return $this->fail('品牌名称过长');
- }
- $this->service->editData($id, $data);
- return $this->success('修改成功!');
- }
-
- public function delete($id)
- {
- $this->service->del((int)$id);
- return $this->success('删除成功!');
- }
- }
|