TeamController.php
3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
namespace app\team\controller;
use cmf\controller\HomeBaseController;
use Think\Db;
/**
* @title 团队定制模块
*/
class TeamController extends HomeBaseController
{
/**
* @title 提交表单
* @description 默认访问接口
* @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ
* @url /team/Team/teamCustomization
* @method POST
*
* @param name:team_name type:char require:1 default:法兰不死队 other: desc:团队名称
* @param name:team_num type:int require:1 default:999 other: desc:团队人员数量
* @param name:start_time type:date require:1 default:2018-09-01 other: desc:出发日期
* @param name:end_time type:date require:1 default:2018-10-01 other: desc:结束日期
* @param name:city type:char require:1 default:天津市 other: desc:市
* @param name:county type:char require:1 default:南开区 other: desc:区
* @param name:street type:char require:1 default:华苑 other: desc:街道
* @param name:contact type:char require:1 default:李大师 other: desc:联系人
* @param name:tel type:char require:1 default:15122554643 other: desc:电话
* @param name:wechat type:char require:1 default:xxx other: desc:微信号
* @param name:desc type:text require:1 default:欢迎来到德莱联盟 other: desc:需求描述
*/
public function teamCustomization()
{
$request = request();
if ($request->isPost()) {
$post = $request->param();
$result = $this->validate(
[
'team_name' => $post['team_name'],
'team_num' => $post['team_num'],
'start_time' => $post['start_time'],
'end_time' => $post['end_time'],
'contact' => $post['contact'],
'tel' => $post['tel'],
'wechat' => $post['wechat'],
'desc' => $post['desc']
],
[
'team_name' => 'require',
'team_num' => 'require',
'start_time' => 'require',
'end_time' => 'require',
'contact' => 'require',
'tel' => 'require',
'wechat' => 'require',
'desc' => 'require'
]);
if (true !== $result) {
echo json_encode(['msg' => $result, 'code' => 40000]);
exit();
} else {
$post['address'] = $post['city'] . $post['county'] . $post['street'];
unset($post['city']);
unset($post['county']);
unset($post['street']);
if (Db::name('team_customization')->insert($post)) {
echo json_encode(['msg' => '提交成功', 'code' => 20000]);
exit();
} else {
echo json_encode(['msg' => '提交失败', 'code' => 40000]);
exit();
}
}
} else {
return $this->fetch();
}
}
}