|
|
1
|
+<?php
|
|
|
2
|
+namespace app\escort\controller;
|
|
|
3
|
+use cmf\controller\HomeBaseController;
|
|
|
4
|
+use Think\Db;
|
|
|
5
|
+
|
|
|
6
|
+/**
|
|
|
7
|
+ * @title 萨米户外
|
|
|
8
|
+ */
|
|
|
9
|
+class EscortController extends HomeBaseController
|
|
|
10
|
+{
|
|
|
11
|
+
|
|
|
12
|
+ function _initialize()
|
|
|
13
|
+ {
|
|
|
14
|
+ header("Access-Control-Allow-Origin: *"); // 允许任意域名发起的跨域请求
|
|
|
15
|
+ header('Access-Control-Allow-Headers: X-Requested-With,X_Requested_With');
|
|
|
16
|
+ $this->userId = (empty($_POST['user_id'])) ? null : $_POST['user_id'];
|
|
|
17
|
+ if (empty($this->userId)) {
|
|
|
18
|
+ echo json_encode(['msg' => '登陆失败', 'code' => 40001]);
|
|
|
19
|
+ exit();
|
|
|
20
|
+ }
|
|
|
21
|
+ }
|
|
|
22
|
+
|
|
|
23
|
+ /**
|
|
|
24
|
+ * @title 添加出行人
|
|
|
25
|
+ * @description 接口说明
|
|
|
26
|
+ * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
|
|
|
27
|
+ * @url /escort/Escort/add
|
|
|
28
|
+ * @method POST
|
|
|
29
|
+ * @module 出行人模块
|
|
|
30
|
+ *
|
|
|
31
|
+ * @param name:name type:char require:1 default:lihan other: desc:出行人姓名
|
|
|
32
|
+ * @param name:sex type:tinyint require:1 default:0 other: 0 desc:出行人性别 0男 1女
|
|
|
33
|
+ * @param name:tel type:char require:1 default:15122554644 desc:出行人电话
|
|
|
34
|
+ * @param name:identity type:char require:1 default:12010319991111261X desc:出行人身份证
|
|
|
35
|
+ * @param name:wechat type:char require:1 default:9fk390_xmw1985 desc:出行人微信号
|
|
|
36
|
+ *
|
|
|
37
|
+ * @return id:新增出行人id
|
|
|
38
|
+ */
|
|
|
39
|
+ public function add()
|
|
|
40
|
+ {
|
|
|
41
|
+ $request = request();
|
|
|
42
|
+ if ($request->isPost()) {
|
|
|
43
|
+ $userId = $this->userId;
|
|
|
44
|
+ if (!empty($userId)) {
|
|
|
45
|
+ $post = $request->param();
|
|
|
46
|
+ if (empty($post['name'])) {
|
|
|
47
|
+ echo json_encode(['msg' => '请填写出行人姓名', 'code' => 40000]);
|
|
|
48
|
+ exit();
|
|
|
49
|
+ }
|
|
|
50
|
+ if (empty($post['tel'])) {
|
|
|
51
|
+ echo json_encode(['msg' => '请填写出行人电话', 'code' => 40000]);
|
|
|
52
|
+ exit();
|
|
|
53
|
+ }
|
|
|
54
|
+ if (empty($post['identity'])) {
|
|
|
55
|
+ echo json_encode(['msg' => '请填写出行人身份证信息', 'code' => 40000]);
|
|
|
56
|
+ exit();
|
|
|
57
|
+ }
|
|
|
58
|
+ if (empty($post['wechat'])) {
|
|
|
59
|
+ echo json_encode(['msg' => '请填写出行人微信号', 'code' => 40000]);
|
|
|
60
|
+ exit();
|
|
|
61
|
+ }
|
|
|
62
|
+ $post['user_id'] = $userId;
|
|
|
63
|
+ if (Db::name('escort')->insert($post)) {
|
|
|
64
|
+ echo json_encode(['msg' => '添加成功', 'data' => ['id' => Db::name('escort')->getLastInsID()], 'code' => 20000]);
|
|
|
65
|
+ exit();
|
|
|
66
|
+ } else {
|
|
|
67
|
+ echo json_encode(['msg' => '添加失败', 'code' => 40000]);
|
|
|
68
|
+ exit();
|
|
|
69
|
+ }
|
|
|
70
|
+ } else {
|
|
|
71
|
+ echo json_encode(['msg' => '登陆失败', 'code' => 40001]);
|
|
|
72
|
+ exit();
|
|
|
73
|
+ }
|
|
|
74
|
+ } else {
|
|
|
75
|
+ echo json_encode(['msg' => '非法操作', 'code' => 40000]);
|
|
|
76
|
+ exit();
|
|
|
77
|
+ }
|
|
|
78
|
+ }
|
|
|
79
|
+
|
|
|
80
|
+ /**
|
|
|
81
|
+ * @title 编辑出行人
|
|
|
82
|
+ * @description 接口说明
|
|
|
83
|
+ * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
|
|
|
84
|
+ * @url /escort/Escort/edit
|
|
|
85
|
+ * @method POST
|
|
|
86
|
+ * @module 出行人模块
|
|
|
87
|
+ *
|
|
|
88
|
+ * @param name:id type:int require:1 default:2 desc:出行人id
|
|
|
89
|
+ * @param name:name type:char require:1 default:lihan other: desc:出行人姓名
|
|
|
90
|
+ * @param name:sex type:tinyint require:1 default:other: 0 desc:出行人性别 0男 1女
|
|
|
91
|
+ * @param name:tel type:char require:1 default:15122554644 desc:出行人电话
|
|
|
92
|
+ * @param name:identity type:char require:1 default:12010319991111261X desc:出行人身份证
|
|
|
93
|
+ * @param name:wechat type:char require:1 default:9fk390_xmw1985 desc:出行人微信号
|
|
|
94
|
+ */
|
|
|
95
|
+ public function edit()
|
|
|
96
|
+ {
|
|
|
97
|
+ $request = request();
|
|
|
98
|
+ if ($request->isPost()) {
|
|
|
99
|
+ $userId = $this->userId;
|
|
|
100
|
+ if (!empty($userId)) {
|
|
|
101
|
+ $post = $request->param();
|
|
|
102
|
+ if (empty($post['name'])) {
|
|
|
103
|
+ echo json_encode(['msg' => '请填写出行人姓名', 'code' => 40000]);
|
|
|
104
|
+ exit();
|
|
|
105
|
+ }
|
|
|
106
|
+ if (empty($post['tel'])) {
|
|
|
107
|
+ echo json_encode(['msg' => '请填写出行人电话', 'code' => 40000]);
|
|
|
108
|
+ exit();
|
|
|
109
|
+ }
|
|
|
110
|
+ if (empty($post['identity'])) {
|
|
|
111
|
+ echo json_encode(['msg' => '请填写出行人身份证信息', 'code' => 40000]);
|
|
|
112
|
+ exit();
|
|
|
113
|
+ }
|
|
|
114
|
+ if (empty($post['wechat'])) {
|
|
|
115
|
+ echo json_encode(['msg' => '请填写出行人微信号', 'code' => 40000]);
|
|
|
116
|
+ exit();
|
|
|
117
|
+ }
|
|
|
118
|
+ $post['user_id'] = $userId;
|
|
|
119
|
+ if (Db::name('escort')->update($post)) {
|
|
|
120
|
+ echo json_encode(['msg' => '编辑成功', 'code' => 20000]);
|
|
|
121
|
+ exit();
|
|
|
122
|
+ } else {
|
|
|
123
|
+ echo json_encode(['msg' => '您未做出任何修改', 'code' => 40000]);
|
|
|
124
|
+ exit();
|
|
|
125
|
+ }
|
|
|
126
|
+ } else {
|
|
|
127
|
+ echo json_encode(['msg' => '登陆失败', 'code' => 40001]);
|
|
|
128
|
+ exit();
|
|
|
129
|
+ }
|
|
|
130
|
+ } else {
|
|
|
131
|
+ echo json_encode(['msg' => '非法操作', 'code' => 40000]);
|
|
|
132
|
+ exit();
|
|
|
133
|
+ }
|
|
|
134
|
+ }
|
|
|
135
|
+
|
|
|
136
|
+ /**
|
|
|
137
|
+ * @title 删除出行人
|
|
|
138
|
+ * @description 接口说明
|
|
|
139
|
+ * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
|
|
|
140
|
+ * @url /escort/Escort/del
|
|
|
141
|
+ * @method POST
|
|
|
142
|
+ * @module 出行人模块
|
|
|
143
|
+ *
|
|
|
144
|
+ * @param name:id type:int require:1 default:2 desc:出行人id
|
|
|
145
|
+ */
|
|
|
146
|
+ public function del()
|
|
|
147
|
+ {
|
|
|
148
|
+ $request = request();
|
|
|
149
|
+ if ($request->isPost()) {
|
|
|
150
|
+ $userId = $this->userId;
|
|
|
151
|
+ if (!empty($userId)) {
|
|
|
152
|
+ if (Db::name('escort')->delete($request->param('id'))) {
|
|
|
153
|
+ echo json_encode(['msg' => '删除成功', 'code' => 20000]);
|
|
|
154
|
+ exit();
|
|
|
155
|
+ } else {
|
|
|
156
|
+ echo json_encode(['msg' => '删除失败', 'code' => 40000]);
|
|
|
157
|
+ exit();
|
|
|
158
|
+ }
|
|
|
159
|
+ } else {
|
|
|
160
|
+ echo json_encode(['msg' => '登陆失败', 'code' => 40001]);
|
|
|
161
|
+ exit();
|
|
|
162
|
+ }
|
|
|
163
|
+ } else {
|
|
|
164
|
+ echo json_encode(['msg' => '非法操作', 'code' => 40000]);
|
|
|
165
|
+ exit();
|
|
|
166
|
+ }
|
|
|
167
|
+ }
|
|
|
168
|
+
|
|
|
169
|
+ /**
|
|
|
170
|
+ * @title 出行人列表
|
|
|
171
|
+ * @description 接口说明
|
|
|
172
|
+ * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
|
|
|
173
|
+ * @url /escort/Escort/_list
|
|
|
174
|
+ * @method POST
|
|
|
175
|
+ * @module 出行人模块
|
|
|
176
|
+ *
|
|
|
177
|
+ * @param name:user_id type:int require:1 default:1 desc:用户id
|
|
|
178
|
+ *
|
|
|
179
|
+ * @return id:出行人id
|
|
|
180
|
+ * @return name:出行人姓名
|
|
|
181
|
+ * @return tel:出行人电话
|
|
|
182
|
+ * @return identity:出行人身份证
|
|
|
183
|
+ */
|
|
|
184
|
+ public function _list()
|
|
|
185
|
+ {
|
|
|
186
|
+ $request = request();
|
|
|
187
|
+ $userId = $this->userId;
|
|
|
188
|
+ if ($request->isPost()) {
|
|
|
189
|
+ $data = Db::name('escort')->field('id,name,tel,identity')->where(['user_id' => $userId])->select()->toArray();
|
|
|
190
|
+ if (!empty($data)) {
|
|
|
191
|
+ echo json_encode(['data' => $data, 'code' => 20000]);
|
|
|
192
|
+ exit();
|
|
|
193
|
+ } else {
|
|
|
194
|
+ echo json_encode(['msg' => '暂无数据', 'code' => 40000]);
|
|
|
195
|
+ exit();
|
|
|
196
|
+ }
|
|
|
197
|
+ } else {
|
|
|
198
|
+ echo json_encode(['msg' => '非法操作', 'code' => 40000]);
|
|
|
199
|
+ exit();
|
|
|
200
|
+ }
|
|
|
201
|
+ }
|
|
|
202
|
+
|
|
|
203
|
+} |