new-admin-api/app/controller/admin/marketing/activity/Activity.php

77 lines
2.1 KiB
PHP

<?php
namespace app\controller\admin\marketing\activity;
use app\common\repositories\marketing\activity\ActivityRepository;
use crmeb\basic\BaseController;
use think\App;
class Activity extends BaseController{
protected $repository;
public function __construct(App $app, ActivityRepository $repository){
parent::__construct($app);
$this->repository = $repository;
}
/**
* Common: 活动列表
* Author: wu-hui
* Time: 2024/03/14 15:52
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
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 16:52
* @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 16:52
* @return mixed
* @throws \think\db\exception\DbException
*/
public function editInfo(){
$params = $this->request->params(['title','cate_id','quota','vegetable_quota','oil_quota','wine_quota','mer_id','coupon_ids','image',['id', 0]]);
$this->repository->submitEditFormData($params);
return app('json')->success('编辑成功');
}
/**
* Common: 删除
* Author: wu-hui
* Time: 2024/03/14 16:53
* @return mixed
*/
public function delInfo(){
$id = (int)$this->request->param('id');
$this->repository->update($id,['is_del' => 1]);
return app('json')->success('删除成功');
}
}