import requests # --- test 获取token --- # url = 'http://58.34.94.177:29101/v1/token' url = 'http://127.0.0.1:9000/v1/token' data = { 'username': 'admin', # 登录账户 'password': '123456', # 登录密码 } response = requests.post(url=url, json=data) code = response.json().get('code') token = response.headers.get('authorization') # print(response.json()) # """ # { # 'code': 0, # 'message': 'authorization passed.', # 'data': { # 'uid': '65dc4187e6e1bf491a4aad1f', # 'username': 'admin', # 'role': '超级管理员', # 'role_type': 1, # 'token': 'xxxxxxxx' # } # } # """ # --- test 1001 新增用户 --- # url = 'http://58.34.94.177:29101/v6/api' # data = { # 'code': 1001, # 接口号 # 'username': 'aabbcc', # 登录账户(必须项) # 'password': 'aabbcc', # 登录密码(可选项)(默认值:baosteel@2024) # 'role_type': 1, # 角色类型(可选项)(1: 超级管理员 2: 普通管理员 3: 普通用户) # 'name': 'aabbcc', # 姓名(可选项) # 'cid': '112233', # 身份证号(可选项) # 'phone': '112233', # 手机号(可选项) # 'sex': 0, # 性别(可选项)(0:未设置 1:男 2:女) # 'department': 'aabbcc', # 部门(可选项) # 'wid': 'aabbcc', # 工号(可选项) # } # response = requests.post(url=url, json=data, headers={'authorization': token}) # print(response.json()) # --- test 1002 查询用户列表 --- # url = 'http://58.34.94.177:29101/v6/api' url = 'http://127.0.0.1:9000/v6/api' data = { 'code': 1002, # 接口号 'page': 1, # 页码 'size': 3, # 每页条数 'name': 'a', # 模糊姓名(可选项) 'phone': '', # 手机号(可选项) 'role_type': ['2'], # 角色类型(可选项) 1 超级管理员 2 普通管理员 3 普通用户(默认值) } response = requests.post(url=url, json=data, headers={'authorization': token}) print(response.json()) """ { 'code': 0, 'data': [ { 'uuid': '65dbeb1c49fbe311a3a01d34', 'name': 'aabbcc', 'cid': '112233', 'phone': '112233', 'sex': 0, # 性别 (0:未设置 1:男 2:女) 'department': 'aabbcc', 'wid': 'aabbcc', 'state': 0, # 禁用状态 (0:激活 1:禁用) 'allow_at': 1708911388 # 注册审批时间时间戳 } ] } """ # --- test 1003 删除指定用户 --- # url = 'http://58.34.94.177:29101/v6/api' # data = { # 'code': 1003, # 接口号 # 'uuid': '65db84b35e305885648ec062', # 用户id(必须项) # } # response = requests.post(url=url, json=data, headers={'authorization': token}) # print(response.json()) # --- test 1004 禁用指定用户 --- # url = 'http://58.34.94.177:29101/v6/api' # data = { # 'code': 1004, # 接口号 # 'uuid': '65decb7744b74ae33732d813', # 用户id(必须项) # } # response = requests.post(url=url, json=data, headers={'authorization': token}) # print(response.json()) # --- test 1005 启用指定用户 --- # url = 'http://58.34.94.177:29101/v6/api' # data = { # 'code': 1005, # 接口号 # 'uuid': '65decb7744b74ae33732d813', # 用户id(必须项) # } # response = requests.post(url=url, json=data, headers={'authorization': token}) # print(response.json()) # --- test 1006 获取指定用户详情 --- # url = 'http://58.34.94.177:29101/v6/api' # data = { # 'code': 1006, # 接口号 # 'uuid': '65dd775c44b74ae33732d7f7', # 用户id(必须项) # } # response = requests.post(url=url, json=data, headers={'authorization': token}) # print(response.json()) # --- test 1007 修改指定用户信息 --- # url = 'http://58.34.94.177:29101/v6/api' # data = { # 'code': 1007, # 接口号 # 'uuid': '65dd775c44b74ae33732d7f7', # 用户id(必须项) # # 'username': 'aabbcc', # 登录账户(必须项) # # 'password': 'aabbcc', # 登录密码(可选项)(默认值:baosteel@2024) # # 'role_type': 3, # 角色类型(可选项)(1: 超级管理员 2: 普通管理员 3: 普通用户) # 'name': 'aabbcc', # 姓名(可选项) # # 'cid': '112233', # 身份证号(可选项) # # 'phone': '112233', # 手机号(可选项) # # 'sex': 0, # 性别(可选项)(0:未设置 1:男 2:女) # # 'department': 'aabbcc', # 部门(可选项) # # 'wid': 'aabbcc', # 工号(可选项) # } # response = requests.post(url=url, json=data, headers={'authorization': token}) # print(response.json())