1.优化,当游戏为魔法门H5时,游戏区服一览表没有数据展示的问题

This commit is contained in:
李伟 2022-03-21 10:05:02 +08:00
parent 84cec75d5b
commit bac49d2f72

View File

@ -63,7 +63,7 @@ async def edit_data_attr(
return schemas.Msg(code=0, msg='ok', data=data_in) return schemas.Msg(code=0, msg='ok', data=data_in)
#
# @router.post("/add_select_map") # @router.post("/add_select_map")
# async def add_map( # async def add_map(
# request: Request, # request: Request,
@ -88,26 +88,36 @@ async def edit_data_attr(
# await crud.select_map.save(db, data_in) # await crud.select_map.save(db, data_in)
# return schemas.Msg(code=0, msg='ok', data=data_in) # return schemas.Msg(code=0, msg='ok', data=data_in)
#在gametoos同步区服了所以不需要这段代码
@router.post("/add_select_map") # @router.post("/add_select_map")
async def add_select_map( # async def add_select_map(
request: Request, # game: str,
game: str, # url: str,
file: bytes = File(...), # #file: bytes = File(...),
db: AsyncIOMotorDatabase = Depends(get_database), # db: AsyncIOMotorDatabase = Depends(get_database),
current_user: schemas.UserDB = Depends(deps.get_current_user) # current_user: schemas.UserDB = Depends(deps.get_current_user)
) -> schemas.Msg: # ) -> schemas.Msg:
"""添加属性值选择映射""" # """添加游戏区服信息选择映射"""
dfs = pd.read_excel(file, engine='openpyxl', sheet_name=None) # dfs = pd.read_excel(file, engine='openpyxl', sheet_name=None)
for attr_name, df in dfs.items(): # for attr_name, df in dfs.items():
#将id这列转换成字符串类型 # #将id这列转换成字符串类型
if len(df) >0: # if len(df) >0:
df['id'] = df['id'].astype(str) # df['id'] = df['id'].astype(str)
map_ = df.to_dict('records') # map_ = df.to_dict('records')
data_in = schemas.SelectMap(game=game, attr_name=attr_name, map_=map_) # data_in = schemas.SelectMap(game=game, attr_name=attr_name, map_=map_)
await crud.select_map.save(db, data_in) # await crud.select_map.save(db, data_in)
return schemas.Msg(code=0, msg='ok', data=1) # return schemas.Msg(code=0, msg='ok', data=1)
# response = requests.get(url)
# data = json.loads(response.text)
# attr_name = 'svrindex'
# map_list = []
# for k, v in data.items():
# map_dict = {}
# map_dict[k] = v['servername']
# map_list.append(map_dict)
# data_in = schemas.SelectMap(game=game, attr_name=attr_name, map_=map_list)
# await crud.select_map.save(db, data_in)
# return schemas.Msg(code=0, msg='ok', data=1)
@router.get("/select_list") @router.get("/select_list")
async def select_list( async def select_list(
@ -117,6 +127,9 @@ async def select_list(
current_user: schemas.UserDB = Depends(deps.get_current_user) current_user: schemas.UserDB = Depends(deps.get_current_user)
) -> schemas.Msg: ) -> schemas.Msg:
"""属性值选择映射列表""" """属性值选择映射列表"""
#当游戏为魔法门H5时把game的值改为数据库中对应的值mdb中的值和ck中的值是不一样的
if game == 'mfmh5':
game='mzmfmh5'
resp = await crud.select_map.get_list(db, game) resp = await crud.select_map.get_list(db, game)
return schemas.Msg(code=0, msg='ok', data=resp) return schemas.Msg(code=0, msg='ok', data=resp)