ProjectController.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/11/12
* Time: 16:25
*/
namespace api\index\controller;
use cmf\controller\RestBaseController;
use think\Db;
use think\Validate;
/**
* @title 关于我们
* @description
*/
class ProjectController extends RestBaseController
{
/**
* @title 公司介绍
* @description
* @author GuoSheng
* @url /index/Project/index
* @method GET
*
* @return id:ID
* @return content:公司介绍
* @return create_time:创建时间
*
*/
public function index(){
$data = Db::name('about')
->where('id',1)
->field('id,content,create_time')
->find();
$data['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($data['content']));
$data['create_time'] = date('Y-m-d H:i:s',$data['create_time']);
$this->success('SUCCESS',$data);
}
/**
* @title 产品方案
* @description
* @author GuoSheng
* @url /index/Project/project
* @method GET
*
* @return id:ID
* @return content:产品方案
*
*/
public function project(){
$data = Db::name('project')
->where('id',1)
->field('id,content')
->find();
$data['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($data['content']));
$this->success('SUCCESS',$data);
}
/**
* @title 加入我们
* @description
* @author GuoSheng
* @url /index/Project/joinUs
* @method GET
*
* @return id:ID
* @return content:内容
*
*/
public function joinUs(){
$data = Db::name('joinus')
->where('id',1)
->field('id,content')
->find();
$data['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($data['content']));
$this->success('SUCCESS',$data);
}
/**
* @title 加入我们信息填写
* @description
* @author GuoSheng
* @url /index/Project/join
* @method GET
*
* @header name:XX-Token require:1 default: desc:token
*
* @param name:name type:string require:1 other: desc:姓名
* @param name:phone type:int require:1 other: desc:电话
* @param name:email type:string require:1 other: desc:邮箱
* @param name:content type:string require:1 other: desc:加盟信息
*
*/
public function join()
{
$user_id = $this->getUserId();
$param = $this->request->param();
$param['user_id'] = $user_id;
$param['create_time'] = time();
$validate = new Validate([
'name' => 'require',
'phone' => 'require|max:11',
'email'=>'require',
'content'=>'require',
]);
if (!$validate->check($param)) {
$this->error(['code'=>40005,'msg'=>$validate->getError()]);
}
$data = Db::name('join')
->insert($param);
if(empty($data)){
$this->error(['code'=>40006,'msg'=>'sql执行失败']);
}
$this->success('SUCCESS');
}
}