InstallController.class.php
1.52 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
<?php
/**
* Created by PhpStorm.
*/
namespace Frontend\Controller\Callback;
use Common\Service\CategoryService;
class InstallController extends AbstractController
{
/** @var CategoryService */
protected $category_service;
public function __construct()
{
parent::__construct();
// 实例化分类表
$this->category_service = new CategoryService();
}
/**
* 应用默认数据安装接口
*/
public function Index()
{
$this->Install();
exit('SUCCESS');
}
/**
* 安装应用
*
* @author caijianhua
*
* @return bool
*/
public function Install()
{
// 安装默认分类
$this->AddCategory();
return true;
}
/**
* 添加默认分类数据
* @return bool
*/
public function AddCategory()
{
// 初始化默认数据
$data = [
[
'ca_name' => '入职培训',
'ca_status' => CategoryService::CATEGORY_OPEN,
'ca_order' => 0
],
[
'ca_name' => '技能培训',
'ca_status' => CategoryService::CATEGORY_OPEN,
'ca_order' => 0
],
[
'ca_name' => '晋升培训',
'ca_status' => CategoryService::CATEGORY_OPEN,
'ca_order' => 0
]
];
// 批量写入数据
$this->category_service->insert_all($data);
return true;
}
}