create_menus.py 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. from feapder.db.mongodb import MongoDB
  2. class Details:
  3. _to_db = None
  4. _to_db_xs = None
  5. db_name = 'mgp_list'
  6. # 定义mongo链接
  7. @property
  8. def to_db(self):
  9. if not self._to_db:
  10. self._to_db = MongoDB()
  11. return self._to_db
  12. @property
  13. def to_db_xs(self):
  14. if not self._to_db_xs:
  15. self._to_db_xs = MongoDB(port=27001,db='editor')
  16. return self._to_db_xs
  17. def main(self,page):
  18. menus_list = []
  19. data = self.to_db_xs.find("luaconfig",{"modifyuser":"maguopeng","param_common":{"$elemMatch": {"$regex": "中国南方航空采购招标网", "$options": "$i"}}})
  20. # print(data)
  21. for item in data:
  22. # print(item)
  23. channls = item.get("param_common")[2]
  24. code = item.get("code")
  25. href = item.get("param_common")[11]
  26. print("Menu"+"(",f"'{channls}',",f"'{code}',\n",f"'{href}',",page,"),")
  27. # menus_list.append(f'''Menu({channls},{code},{href},{page})''')
  28. # print(menus_list)
  29. Details().main(2)