12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- from model.DataBaseUtils import MysqlUtils
- import requests
- def get_auth_user(user_id):
- """获取用户拥有所有用户(包括自己)的权限"""
- rsp = requests.get(url=f'http://api.zanxiangnet.com/erp/api/user/subUser/3/{user_id}')
- nick_name_list = []
- for _ in rsp.json()['data']:
- nick_name_list.append(_['nickName'])
- return nick_name_list
- def get_auth_channel(user_id):
- """获取用户拥有的所有公众号权限"""
- db = MysqlUtils()
- # 普通权限------java,获取本人对应拥有的公众号
- rsp = requests.get(f'http://api.zanxiangnet.com/system/api/mp/mpAccount/subAccountWithUser/3/{user_id}')
- channel_list = rsp.json()['data']
- data1 = []
- if channel_list:
- for _ in channel_list:
- data1.append(_['nickName'])
- sql2 = f"""select GROUP_CONCAT(channel_ids) from user_channel_group_auth a
- left join channel_group b on a.channel_group_id=b.id
- where user_id={user_id}"""
- data2 = db.quchen_text.getOne(sql2)
- data3 = []
- if data2:
- rsp = requests.get('http://api.zanxiangnet.com/system/api/mp/mpAccount/search/3')
- channel_list = []
- channel_dict = {}
- for _ in rsp.json()['data']:
- channel_list.append((_['id'], _['nickName']))
- channel_dict[_['id']] = _['nickName']
- data2_2 = tuple(data2.split(','))
- for _ in data2_2:
- data3.append(channel_dict[int(_)])
- return tuple(data1 + data3)
- def super_auth():
- "获取超级数据权限的用户列表"
- rsp = requests.get('http://api.zanxiangnet.com/erp/api/user/search/3?powerLevelMin=99')
- user_list = []
- for _ in rsp.json()['data']:
- user_list.append(_['userId'])
- return user_list
- if __name__ == '__main__':
- # print(get_auth_channel(109))
- # print(get_role(78))
- print(f"ssed{tuple([1, 3, 4])}")
|