|
|
@@ -0,0 +1,106 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @copyright ©2020 点小铺
|
|
|
+ * @author hanj
|
|
|
+ * @link: https://dyuit.com
|
|
|
+ * Created by VSCode
|
|
|
+ */
|
|
|
+
|
|
|
+namespace app\store\controller\setting;
|
|
|
+
|
|
|
+use app\common\enum\dtalk\RobotSence;
|
|
|
+use app\store\controller\Controller;
|
|
|
+use app\store\model\DtalkRobot as DtalkRobotModel;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Class DtalkRobot
|
|
|
+ * 钉钉机器人
|
|
|
+ *
|
|
|
+ * @Author: Yeshihao
|
|
|
+ * @DateTime: 2024/8/9 17:28
|
|
|
+ * @package app\store\controller\setting
|
|
|
+ */
|
|
|
+class DtalkRobot extends Controller
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * [index]
|
|
|
+ *
|
|
|
+ * @Author: Yeshihao
|
|
|
+ * @DateTime: 2024/8/9 17:28
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function index()
|
|
|
+ {
|
|
|
+ $model = new DtalkRobotModel;
|
|
|
+ $list = $model->getList();
|
|
|
+ $robotSence = RobotSence::data();
|
|
|
+ return $this->fetch('index', compact('list', 'robotSence'));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * [delete]
|
|
|
+ * 删除
|
|
|
+ *
|
|
|
+ * @Author: Yeshihao
|
|
|
+ * @DateTime: 2024/8/9 18:24
|
|
|
+ * @param $id
|
|
|
+ * @return array|bool
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ public function delete($id)
|
|
|
+ {
|
|
|
+ $model = DtalkRobotModel::detail($id);
|
|
|
+ if (!$model->setDelete()) {
|
|
|
+ return $this->renderError($model->getError() ?: '删除失败');
|
|
|
+ }
|
|
|
+ return $this->renderSuccess('删除成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加配送模板
|
|
|
+ *
|
|
|
+ * @return array|mixed
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function add()
|
|
|
+ {
|
|
|
+ if (!$this->request->isAjax()) {
|
|
|
+ $robotSence = RobotSence::data();
|
|
|
+ return $this->fetch('add', compact('robotSence'));
|
|
|
+ }
|
|
|
+ // 新增记录
|
|
|
+ $model = new DtalkRobotModel;
|
|
|
+ if ($model->add($this->postData())) {
|
|
|
+ return $this->renderSuccess('添加成功', url('setting.dtalk_robot/index'));
|
|
|
+ }
|
|
|
+ return $this->renderError($model->getError() ?: '添加失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑配送模板
|
|
|
+ *
|
|
|
+ * @param $delivery_id
|
|
|
+ * @return array|mixed
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function edit($id)
|
|
|
+ {
|
|
|
+ // 模板详情
|
|
|
+ $model = DtalkRobotModel::detail($id);
|
|
|
+ if (!$this->request->isAjax()) {
|
|
|
+ $robotSence = RobotSence::data();
|
|
|
+ return $this->fetch('edit', compact('model', 'robotSence'));
|
|
|
+ }
|
|
|
+ // 更新记录
|
|
|
+ if ($model->edit($this->postData())) {
|
|
|
+ return $this->renderSuccess('更新成功');
|
|
|
+ }
|
|
|
+ return $this->renderError($model->getError() ?: '更新失败');
|
|
|
+ }
|
|
|
+}
|