PCpublicMethods.py
5.82 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
from atdd.PcPost import PcPost
class PCpublicMethods(PcPost):
def setUp(self):
self.do_login(self.host, self.mobile, self.psw, self.domain)
# 岗位list——岗位管理页面
def test_getJobList(self):
interfaceUrl = "/Contact/Apicp/Job/List"
data = {
"page": 1,
"limit": 10
}
r = self.PcPost(interfaceUrl,data)
return r
# 根据岗位名称获取岗位ID
def getJobID(self, jobName):
self.do_login(self.host, self.mobile, self.psw, self.domain)
jobList = self.test_getJobList()['result']['list']
for i in range(len(jobList)):
if (jobList[i]['jobName'] == jobName):
return jobList[i]['jobId']
else:
print("不存在'" + jobName + "'")
#角色list——角色管理页面
def test_getRoleList(self):
interfaceUrl = "/Contact/Apicp/Role/List"
data = {
"page": 1,
"limit": 10
}
r = self.PcPost(interfaceUrl,data)
return r
# 根据角色名称获取角色ID
def getRoleID(self, roleName):
self.do_login(self.host, self.mobile, self.psw, self.domain)
roleList = self.test_getRoleList()['result']['list']
for i in range(len(roleList)):
if (roleList[i]['roleName'] == roleName):
return roleList[i]['roleId']
else:
print("不存在'" + roleName + "'")
# 获取员工的积分信息(组织、岗位、角色、积分等级。。。)-员工积分页面
def getMemberInfo(self, memUsername):
self.do_login(self.host, self.mobile, self.psw, self.domain)
interfaceUrl = "/Integral/Apicp/Integral/MemberList"
data = {
"memUsername": memUsername
}
result = self.PcPost(interfaceUrl, data)
return result
#根据组织名字获取组织ID,返回组织ID
def get_dpID(self,dpName):
self.do_login(self.host, self.mobile, self.psw, self.domain)
interfaceUrl = "/contact/Apicp/Department/Search"
data = {
"keyword": dpName
}
result = self.PcPost(interfaceUrl, data)
dpId = result['result']['list'][0]['department_id']
return dpId
# 获取该员工组织的ID,以list格式返回
def member_dpID(self):
result = self.getMemberInfo("小红红")
memberInfo = result['result']['list'][0]
dpName = memberInfo['dpName']
dpNameList = dpName.split(';') #将字符串转化为数组
dpIdList = []
for i in range(len(dpNameList)):
dpId = self.get_dpID(dpNameList[i]).split()
# 将dpId加入到dpIdList中
dpIdList[len(dpIdList):len(dpIdList)] = dpId
return dpIdList
# 积分策略:获取业务应用的触发行为的key和触发条件的key,并构造成字典
# 参数:businessKey
def getTriggerKey(self,businessKey):
self.do_login(self.host, self.mobile, self.psw, self.domain)
interfaceUrl = "/Integral/Apicp/Integral/DefaultList"
data = {
"businessKey": businessKey
}
r = self.PcPost(interfaceUrl, data)
result = r['result']
dictTriggersKey = {} # 构造字典
for i in range(len(result)):
businessAct = result[i]['businessAct'] # 触发行为
triggers = result[i]['triggers'] # 获得triggers数据
triggerKeyList = [] # 清空上一条数组数据
for j in range(len(triggers)):
triggerKey = triggers[j]['triggerKey'].split() # 获取单个key
triggerKeyList[len(triggerKeyList):len(triggerKeyList)] = triggerKey # 将单个key组成数组
dictTriggersKey[businessAct] = triggerKeyList #构造成字典
return dictTriggersKey
# 积分策略:获取业务应用的触发行为的value,并构造成字典
# 参数:businessKey
def getTriggerValue(self, businessKey):
self.do_login(self.host, self.mobile, self.psw, self.domain)
interfaceUrl = "/Integral/Apicp/Integral/DefaultList"
data = {
"businessKey": businessKey
}
r = self.PcPost(interfaceUrl, data)
result = r['result']
dictTriggersValue = {} # 构造字典
for i in range(len(result)):
businessAct = result[i]['businessAct'] # 触发行为
triggers = result[i]['triggers'] # 获得triggers数据
for j in range(len(triggers)):
triggerKey = triggers[j]['triggerKey'] # 获取单个key
triggerValue = triggers[j]['triggerValue'] # 获取单个value
triggerdic = businessAct + "-" + triggerKey
dictTriggersValue[triggerdic] = triggerValue #构造成字典
return dictTriggersValue
# 积分策略:获取业务应用的触发行为的limitConditions,并构造成字典
# 参数:businessKey
def getLimitConditions(self, businessKey):
self.do_login(self.host, self.mobile, self.psw, self.domain)
interfaceUrl = "/Integral/Apicp/Integral/DefaultList"
data = {
"businessKey": businessKey
}
r = self.PcPost(interfaceUrl, data)
result = r['result']
dictLimitConditions = {} # 构造字典
for i in range(len(result)):
businessAct = result[i]['businessAct'] # 触发行为
triggers = result[i]['triggers'] # 获得triggers数据
for j in range(len(triggers)):
triggerKey = triggers[j]['triggerKey'] # 获取单个key
limitConditions = triggers[j]['limitConditions'] # 获取单个value
triggerdic = businessAct + "-" + triggerKey
dictLimitConditions[triggerdic] = limitConditions #构造成字典
return dictLimitConditions