MedalModel.class.php
2.29 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
<?php
/**
* 考试-激励表
* @author: houyingcai
* @email: 594609175@qq.com
* @date : 2017-05-19 18:04:33
* @version $Id$
*/
namespace Common\Model;
class MedalModel extends AbstractModel
{
/**
* 构造方法
*/
public function __construct()
{
parent::__construct();
}
/**
* 查询列表
*
* @param $data array 查询条件
* @param string $fields 查询的字段
*
* @return array|bool
*/
public function fetch_all_medal($data, $fields = '*')
{
list($where, $params) = $this->get_where($data);
// 排序
$sql = "SELECT {$fields} FROM __TABLE__ WHERE " . $where;
return $this->_m->fetch_array($sql, $params);
}
/**
* 拼接Sql语句
*
* @param array $data 查询条件
*
* @return array
*/
public function get_where($data = [])
{
// 组装查询语句
$where = "status <? AND domain=?";
// 操作状态和域名
$params[] = self::ST_DELETE;
$params[] = QY_DOMAIN;
$params[] = 1;
// 权限判断
$rightModel = new RightModel();
$table = $rightModel->get_tname();
$right = $data['right'];
if (!empty($right)) {
$where_right = " 0 ";
$params[] = self::ST_DELETE;
$params[] = QY_DOMAIN;
if (!empty($right['memID'])) {
$where_right .= " OR uid =? ";
$params[] = $right['memID'];
}
//部门
if (!empty($right['dpIds'])) {
$where_right .= " OR `cd_id` IN (?) ";
$params[] = $right['dpIds'];
}
// 标签
if (!empty($right['tagIds'])) {
$where_right .= "OR `tag_id` IN (?) ";
$params[] = $right['tagIds'];
}
// 岗位
if (!empty($right['jobIds'])) {
$where_right .= "OR `job_id` IN (?) ";
$params[] = $right['jobIds'];
}
$right_sql = " em_id in( select distinct epc_id from " . $table . " where status <? AND domain= ? AND `em_type`=0 AND (" . $where_right . "))";
}
$where .= " and (is_all =? OR $right_sql)";
return [$where, $params];
}
}