AbstractController.class.php
1.46 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
<?php
/**
* Created by PhpStorm.
*/
namespace Api\Controller;
use Common\Controller\Api;
use Common\Service\EducationService;
abstract class AbstractController extends Api\AbstractController
{
// 默认页码
const DEFAULT_PAGE = 1;
// 默认每页条数
const DEFAULT_LIMIT = 15;
// 点赞类型:点赞量加1
const LIKES_INC = 0;
// 点赞类型:点赞量减1
const LIKES_DEC = 1;
// 已参加人数加1
const JOINED_INC = 0;
/**
* 根据培训id获取培训详情
*
* @param int $ed_id 培训id
*
* @return mixed
*/
public function get_education($ed_id = 0)
{
$edu_s = new EducationService();
// 培训详情
$education = $edu_s->get($ed_id);
if (!$education) {
E('_ERR_ED_EXIST');
}
return $education;
}
/**
* 格式化用户微信头像为小头像
*
* @param string $memFace 原始头像
*
* @return string 小头像
*/
public function format_avatar($memFace = '')
{
// 头像为空,直接返回
if (empty($memFace)) {
return '';
}
// 头像根据"/"分隔为数组,取数组最后一个
$end = end(explode('/', $memFace));
// 最后一个元素为空,追加0
if ($end != '0') {
$memFace = $memFace . '0';
}
// 返回用户小头像
return $memFace . '/100';
}
}