Common.php
2.73 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
<?php
namespace addons\fastflow\model;
use addons\qingdong\model\AuthGroup;
use addons\qingdong\model\Staff;
use app\admin\model\Admin;
use think\Config;
use think\Model;
use addons\fastflow\model\api;
class Common extends Model
{
// 追加属性
protected $append = [
'initiator',
'initiator_group',
'upper_name',
'bill',
'flow_auth',
'runthread_info',
'flow_progress',
'flow_auth_text',
];
public function __construct($data = [])
{
parent::__construct($data);
if(isset($this->appendAttr))
{
$this->append = array_unique(array_merge($this->append,$this->appendAttr));
}
}
public function getName()
{
return $this->name;
}
public function getInitiatorAttr($value, $data)
{
//halt($data);
$createUserId = $data['initiator_id'];
$user = Admin::find($createUserId);
if ($user) {
return $user['nickname'];
}
return '';
}
public function getInitiatorGroupAttr($value, $data)
{
$createUserId = $data['initiator_id'];
$user = Staff::find($createUserId);
$group_id = $user['group_ids']??'0';
$group = AuthGroup::where("find_in_set(id,'$group_id')")->column('name');
// halt($group);
if ($group) {
return implode(',',$group);
}
return '';
}
public function getUpperNameAttr($value, $data)
{
$createUserId = $data['initiator_id'];
$user = Staff::find($createUserId);
$group_id = $user['group_ids']??'0';
$pid = AuthGroup::where("find_in_set(id,'$group_id')")->value('pid');
$group = AuthGroup::where('id',$pid)->column('name');
if ($group) {
return implode(',',$group);
}
return '';
}
public function getBillAttr($value, $data)
{
return Config::get('database')['prefix'] . $this->name;
}
public function getFlowAuthAttr($value, $data)
{
$bill = Config::get('database')['prefix'] . $this->name;
return (new api())->getBillAuthInfo($data['initiator_id'], $bill, $data['id']);
}
public function getFlowAuthTextAttr($value, $data)
{
return $this->getFlowAuthAttr($value, $data)['msg'];
}
public function getRunthreadInfoAttr($value, $data)
{
//halt($this->name);
$bill = Config::get('database')['prefix'] . $this->name;
return (new api())->getRunThreadInfo($bill, $data['id']);
}
public function getFlowProgressAttr($value, $data)
{
$bill = Config::get('database')['prefix'] . $this->name;
return (new api())->getFlowProgress($bill, $data['id']);
}
}