// +---------------------------------------------------------------------- namespace app\controller\admin\wechat; use crmeb\basic\BaseController; use crmeb\services\WechatUserGroupService; use crmeb\services\WechatUserTagService; use FormBuilder\Exception\FormBuilderException; use think\App; /** * Class WechatGroup * @package app\controller\admin\wechat * @author xaboy * @day 2020-04-27 */ class WechatGroup extends BaseController { /** * @var WechatUserGroupService */ protected $service; /** * WechatTag constructor. * @param App $app * @param WechatUserGroupService $service */ public function __construct(App $app, WechatUserGroupService $service) { parent::__construct($app); $this->service = $service; } public function lst() { return app('json')->success($this->service->lst()); } /** * @return mixed * @throws FormBuilderException * @author xaboy * @day 2020-04-27 */ public function createForm() { return app('json')->success(formToData($this->service->form())); } /** * @return mixed * @author xaboy * @day 2020-04-27 */ public function create() { $name = $this->request->param('group_name'); if (!$name) return app('json')->fail('请输入分组名称'); $this->service->create($name); return app('json')->success('添加成功'); } /** * @param $id * @return mixed * @author xaboy * @day 2020-04-27 */ public function update($id) { $name = $this->request->param('group_name'); if (!$name) return app('json')->fail('请输入分组名称'); $this->service->update($id, $name); return app('json')->success('编辑成功'); } /** * @param $id * @return mixed * @throws FormBuilderException * @author xaboy * @day 2020-04-27 */ public function updateForm($id) { return app('json')->success(formToData($this->service->form($id, ''))); } /** * @param $id * @return mixed * @author xaboy * @day 2020-04-27 */ public function delete($id) { $this->service->delete($id); return app('json')->success('删除成功'); } }