74 lines
1.8 KiB
PHP
74 lines
1.8 KiB
PHP
<?php
|
|
namespace app\controller\admin\marketing\activity;
|
|
|
|
|
|
use app\common\repositories\marketing\activity\CateRepository;
|
|
use crmeb\basic\BaseController;
|
|
use think\App;
|
|
|
|
class Cate extends BaseController{
|
|
|
|
protected $repository;
|
|
|
|
public function __construct(App $app, CateRepository $repository){
|
|
parent::__construct($app);
|
|
$this->repository = $repository;
|
|
}
|
|
/**
|
|
* Common: 分类列表
|
|
* Author: wu-hui
|
|
* Time: 2024/03/14 15:20
|
|
* @return mixed
|
|
*/
|
|
public function getList(){
|
|
[$page, $limit] = $this->getPage();
|
|
$params = $this->request->params(['title']);
|
|
$data = $this->repository->getList((array)$params,(int)$page,(int)$limit);
|
|
|
|
return app('json')->success($data);
|
|
}
|
|
/**
|
|
* Common: 分类编辑表单
|
|
* Author: wu-hui
|
|
* Time: 2024/03/14 15:06
|
|
* @return mixed
|
|
* @throws \FormBuilder\Exception\FormBuilderException
|
|
*/
|
|
public function editForm(){
|
|
$id = (int)$this->request->param('id');
|
|
$data = $this->repository->getEditFormData($id);
|
|
|
|
return app('json')->success(formToData($data));
|
|
}
|
|
/**
|
|
* Common: 分类编辑表单提交
|
|
* Author: wu-hui
|
|
* Time: 2024/03/14 15:29
|
|
* @return mixed
|
|
* @throws \think\db\exception\DbException
|
|
*/
|
|
public function editInfo(){
|
|
$params = $this->request->params(['title',['id', 0]]);
|
|
$this->repository->submitEditFormData($params);
|
|
|
|
return app('json')->success('编辑成功');
|
|
}
|
|
/**
|
|
* Common: 删除分类
|
|
* Author: wu-hui
|
|
* Time: 2024/03/14 15:45
|
|
* @return mixed
|
|
*/
|
|
public function delInfo(){
|
|
$id = (int)$this->request->param('id');
|
|
|
|
$this->repository->delete($id);
|
|
|
|
return app('json')->success('删除成功');
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|