|
@@ -2,6 +2,7 @@ |
|
@@ -2,6 +2,7 @@ |
2
|
|
2
|
|
3
|
namespace app\admin\controller;
|
3
|
namespace app\admin\controller;
|
4
|
|
4
|
|
|
|
5
|
+use think\Db;
|
5
|
use app\common\controller\Backend;
|
6
|
use app\common\controller\Backend;
|
6
|
|
7
|
|
7
|
/**
|
8
|
/**
|
|
@@ -11,7 +12,7 @@ use app\common\controller\Backend; |
|
@@ -11,7 +12,7 @@ use app\common\controller\Backend; |
11
|
*/
|
12
|
*/
|
12
|
class Seller extends Backend
|
13
|
class Seller extends Backend
|
13
|
{
|
14
|
{
|
14
|
-
|
15
|
+
|
15
|
/**
|
16
|
/**
|
16
|
* Seller模型对象
|
17
|
* Seller模型对象
|
17
|
* @var \app\admin\model\Seller
|
18
|
* @var \app\admin\model\Seller
|
|
@@ -24,12 +25,64 @@ class Seller extends Backend |
|
@@ -24,12 +25,64 @@ class Seller extends Backend |
24
|
$this->model = new \app\admin\model\Seller;
|
25
|
$this->model = new \app\admin\model\Seller;
|
25
|
$this->view->assign("isShowList", $this->model->getIsShowList());
|
26
|
$this->view->assign("isShowList", $this->model->getIsShowList());
|
26
|
}
|
27
|
}
|
27
|
-
|
28
|
+
|
28
|
/**
|
29
|
/**
|
29
|
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
30
|
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
30
|
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
31
|
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
31
|
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
32
|
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
32
|
*/
|
33
|
*/
|
33
|
-
|
|
|
34
|
|
34
|
|
35
|
-} |
35
|
+
|
|
|
36
|
+ /**
|
|
|
37
|
+ * 编辑
|
|
|
38
|
+ */
|
|
|
39
|
+ public function edit($ids = null)
|
|
|
40
|
+ {
|
|
|
41
|
+ $row = $this->model->get($ids);
|
|
|
42
|
+ if (!$row) {
|
|
|
43
|
+ $this->error(__('No Results were found'));
|
|
|
44
|
+ }
|
|
|
45
|
+ $adminIds = $this->getDataLimitAdminIds();
|
|
|
46
|
+ if (is_array($adminIds)) {
|
|
|
47
|
+ if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
|
|
48
|
+ $this->error(__('You have no permission'));
|
|
|
49
|
+ }
|
|
|
50
|
+ }
|
|
|
51
|
+ if ($this->request->isPost()) {
|
|
|
52
|
+ $params = $this->request->post("row/a");
|
|
|
53
|
+ if ($params) {
|
|
|
54
|
+ $params = $this->preExcludeFields($params);
|
|
|
55
|
+ $result = false;
|
|
|
56
|
+ Db::startTrans();
|
|
|
57
|
+ try {
|
|
|
58
|
+ //是否采用模型验证
|
|
|
59
|
+ if ($this->modelValidate) {
|
|
|
60
|
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
|
|
61
|
+ $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
|
|
62
|
+ $row->validateFailException(true)->validate($validate);
|
|
|
63
|
+ }
|
|
|
64
|
+ $params['talk_num'] = 0;
|
|
|
65
|
+ $result = $row->allowField(true)->save($params);
|
|
|
66
|
+ Db::commit();
|
|
|
67
|
+ } catch (ValidateException $e) {
|
|
|
68
|
+ Db::rollback();
|
|
|
69
|
+ $this->error($e->getMessage());
|
|
|
70
|
+ } catch (PDOException $e) {
|
|
|
71
|
+ Db::rollback();
|
|
|
72
|
+ $this->error($e->getMessage());
|
|
|
73
|
+ } catch (Exception $e) {
|
|
|
74
|
+ Db::rollback();
|
|
|
75
|
+ $this->error($e->getMessage());
|
|
|
76
|
+ }
|
|
|
77
|
+ if ($result !== false) {
|
|
|
78
|
+ $this->success();
|
|
|
79
|
+ } else {
|
|
|
80
|
+ $this->error(__('No rows were updated'));
|
|
|
81
|
+ }
|
|
|
82
|
+ }
|
|
|
83
|
+ $this->error(__('Parameter %s can not be empty', ''));
|
|
|
84
|
+ }
|
|
|
85
|
+ $this->view->assign("row", $row);
|
|
|
86
|
+ return $this->view->fetch();
|
|
|
87
|
+ }
|
|
|
88
|
+} |