|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+<?php
|
|
|
2
|
+/**
|
|
|
3
|
+ * @package merchant
|
|
|
4
|
+ *
|
|
|
5
|
+ * @author xaboy
|
|
|
6
|
+ * @day 2020-03-24
|
|
|
7
|
+ *
|
|
|
8
|
+ *
|
|
|
9
|
+ */
|
|
|
10
|
+
|
|
|
11
|
+namespace app\controller\admin\system\config;
|
|
|
12
|
+
|
|
|
13
|
+
|
|
|
14
|
+use crmeb\basic\BaseController;
|
|
|
15
|
+use app\common\repositories\system\config\ConfigContributionRepository;
|
|
|
16
|
+use FormBuilder\Exception\FormBuilderException;
|
|
|
17
|
+use think\App;
|
|
|
18
|
+use think\db\exception\DataNotFoundException;
|
|
|
19
|
+use think\db\exception\DbException;
|
|
|
20
|
+use think\db\exception\ModelNotFoundException;
|
|
|
21
|
+
|
|
|
22
|
+/**
|
|
|
23
|
+ * Class Contribution
|
|
|
24
|
+ * @package app\controller\admin\system\config
|
|
|
25
|
+ * @author xaboy
|
|
|
26
|
+ * @day 2020-03-27
|
|
|
27
|
+ */
|
|
|
28
|
+class Contribution extends BaseController
|
|
|
29
|
+{
|
|
|
30
|
+ /**
|
|
|
31
|
+ * @var ConfigContributionRepository
|
|
|
32
|
+ */
|
|
|
33
|
+ private $repository;
|
|
|
34
|
+
|
|
|
35
|
+ /**
|
|
|
36
|
+ * ConfigClassify constructor.
|
|
|
37
|
+ * @param App $app
|
|
|
38
|
+ * @param ConfigContributionRepository $repository
|
|
|
39
|
+ */
|
|
|
40
|
+ public function __construct(App $app, ConfigContributionRepository $repository)
|
|
|
41
|
+ {
|
|
|
42
|
+ parent::__construct($app);
|
|
|
43
|
+ $this->repository = $repository;
|
|
|
44
|
+ }
|
|
|
45
|
+
|
|
|
46
|
+ /**
|
|
|
47
|
+ * @return mixed 列表
|
|
|
48
|
+ * @throws DataNotFoundException
|
|
|
49
|
+ * @throws DbException
|
|
|
50
|
+ * @throws ModelNotFoundException
|
|
|
51
|
+ * @author xaboy
|
|
|
52
|
+ * @day 2020-03-31
|
|
|
53
|
+ */
|
|
|
54
|
+ public function lst()
|
|
|
55
|
+ {
|
|
|
56
|
+ $lst = $this->repository->lst();
|
|
|
57
|
+ // $lst['list'] = $lst['list']->toArray();
|
|
|
58
|
+ return app('json')->success($lst);
|
|
|
59
|
+ }
|
|
|
60
|
+
|
|
|
61
|
+
|
|
|
62
|
+ /**
|
|
|
63
|
+ * @return mixed 创建表单
|
|
|
64
|
+ * @throws FormBuilderException
|
|
|
65
|
+ * @author xaboy
|
|
|
66
|
+ * @day 2020-03-31
|
|
|
67
|
+ */
|
|
|
68
|
+ public function createTable()
|
|
|
69
|
+ {
|
|
|
70
|
+ $form = $this->repository->createForm();
|
|
|
71
|
+ return app('json')->success(formToData($form));
|
|
|
72
|
+ }
|
|
|
73
|
+
|
|
|
74
|
+ /** 修改表单
|
|
|
75
|
+ * @param int $id
|
|
|
76
|
+ * @return mixed
|
|
|
77
|
+ * @throws DataNotFoundException
|
|
|
78
|
+ * @throws DbException
|
|
|
79
|
+ * @throws ModelNotFoundException
|
|
|
80
|
+ * @throws FormBuilderException
|
|
|
81
|
+ * @author xaboy
|
|
|
82
|
+ * @day 2020-03-31
|
|
|
83
|
+ */
|
|
|
84
|
+ public function updateTable($id)
|
|
|
85
|
+ {
|
|
|
86
|
+ if (!$this->repository->exists($id)) app('json')->fail('数据不存在');
|
|
|
87
|
+ $form = $this->repository->updateForm($id);
|
|
|
88
|
+ return app('json')->success(formToData($form));
|
|
|
89
|
+ }
|
|
|
90
|
+
|
|
|
91
|
+
|
|
|
92
|
+ /** 创建
|
|
|
93
|
+ * @return mixed
|
|
|
94
|
+ * @author xaboy
|
|
|
95
|
+ * @day 2020-03-27
|
|
|
96
|
+ */
|
|
|
97
|
+ public function create()
|
|
|
98
|
+ {
|
|
|
99
|
+ $data = $this->request->params(['title', 'start', 'end', 'type', 'jd', 'value']);
|
|
|
100
|
+ $this->repository->create($data);
|
|
|
101
|
+ return app('json')->success('添加成功');
|
|
|
102
|
+ }
|
|
|
103
|
+
|
|
|
104
|
+ /**修改
|
|
|
105
|
+ * @param int $id
|
|
|
106
|
+ * @return mixed
|
|
|
107
|
+ * @throws DbException
|
|
|
108
|
+ * @author xaboy
|
|
|
109
|
+ * @day 2020-03-27
|
|
|
110
|
+ */
|
|
|
111
|
+ public function update($id)
|
|
|
112
|
+ {
|
|
|
113
|
+ $data = $this->request->params(['title', 'start', 'end', 'type', 'jd', 'value']);
|
|
|
114
|
+ $this->repository->update($id, $data);
|
|
|
115
|
+ return app('json')->success('修改成功');
|
|
|
116
|
+ }
|
|
|
117
|
+
|
|
|
118
|
+
|
|
|
119
|
+ /** 删除
|
|
|
120
|
+ * @param int $id
|
|
|
121
|
+ * @return mixed
|
|
|
122
|
+ * @throws DbException
|
|
|
123
|
+ * @author xaboy
|
|
|
124
|
+ * @day 2020-03-27
|
|
|
125
|
+ */
|
|
|
126
|
+ public function delete($id)
|
|
|
127
|
+ {
|
|
|
128
|
+ $this->repository->delete($id);
|
|
|
129
|
+ return app('json')->success('删除成功');
|
|
|
130
|
+ }
|
|
|
131
|
+}
|