123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- 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 get_auth_game_info(user_id):
- """获取用户拥有的所有用户拥有的游戏"""
- db = MysqlUtils()
- # 1.获取用户名字
- rsp = requests.get('http://api.zanxiangnet.com/erp/api/user/search/3?powerLevelMin=0')
- user_name = None
- for _ in rsp.json()['data']:
- if str(_['userId']) == str(user_id):
- user_name = _['nickName']
- # 2.获取所有游戏id
- sql = f'''
- SELECT d.id ,d.name,min(DATE_FORMAT(a.start_date,"%Y-%m-%d"))
- FROM quchen_text.advertiser_vx a
- left join db_mp.mp_mp_conf b on a.name =b.wx_name
- left join db_mp.mp_conf_agent c on c.advertiser_conf_id = b.id
- left join db_mp.h_game d on c.app_id = d.id
- where pitcher ='{user_name}' and d.id is not null
- group by id
- '''
- user_ids = db.quchen_text.get_data_list(sql)
- return user_ids
- def get_auth_game_name(user_id):
- """获取用户拥有的所有用户拥有的游戏"""
- db = MysqlUtils()
- # 1.获取用户名字
- rsp = requests.get('http://api.zanxiangnet.com/erp/api/user/search/3?powerLevelMin=0')
- user_name = None
- for _ in rsp.json()['data']:
- if str(_['userId']) == str(user_id):
- user_name = _['nickName']
- # 2.获取所有游戏id
- sql = f'''
- SELECT d.name
- FROM quchen_text.advertiser_vx a
- left join db_mp.mp_mp_conf b on a.name =b.wx_name
- left join db_mp.mp_conf_agent c on c.advertiser_conf_id = b.id
- left join db_mp.h_game d on c.app_id = d.id
- where pitcher ='{user_name}' and d.name is not null
- group by name
- '''
- user_ids = db.quchen_text.get_data_list(sql)
- return user_ids
- 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])}")
- get_auth_game_name(196)
|