logger.info('创建admin用户成功!') else: logger.info('已有用户,无需创建admin') except Exception as e: logger.error('程序异常 --> [%s]' % str(e)) # 初始化用户组对象 try: for item_dict in USER_GROUP_LIST: key = item_dict['k'] value = item_dict['v'] if len(UserGroup.objects(key=key)) == 0: group = UserGroup() group.key = key group.value = value group.save() logger.info('初始化用户组成功!') except Exception as e: logger.error('初始化用户组异常![%s]' % e.message) # 初始化菜单对象 try: for menu_item in MENU_LIST: main_menu = menu_item['main'] if not Menu.objects(type=MENU_MAIN, p_key=main_menu[2], c_key=main_menu[3]): Menu.gen_new_menu(main_menu[0], main_menu[1], main_menu[2], main_menu[3], main_menu[4]) logger.info('生成主菜单:[%s][%s][%s][%s][%s]' % (main_menu[0], main_menu[1], main_menu[2], main_menu[3], main_menu[4])) sub_menu = menu_item['sub'] for sub_menu_item in sub_menu: if not Menu.objects(type=MENU_SUB, p_key=sub_menu_item[2], c_key=sub_menu_item[3]):
logger.info('创建admin用户成功!') else: logger.info('已有用户,无需创建admin') except Exception as e: logger.error('程序异常 --> [%s]' % str(e)) # 初始化用户组对象 try: for item_dict in USER_GROUP_LIST: key = item_dict['k'] value = item_dict['v'] if len(UserGroup.objects(key=key)) == 0: group = UserGroup() group.key = key group.value = value group.save() logger.info('初始化用户组成功!') except Exception as e: logger.error('初始化用户组异常![%s]' % e.message) # 初始化菜单对象 try: for menu_item in MENU_LIST: main_menu = menu_item['main'] if not Menu.objects( type=MENU_MAIN, p_key=main_menu[2], c_key=main_menu[3]): Menu.gen_new_menu(main_menu[0], main_menu[1], main_menu[2], main_menu[3], main_menu[4]) logger.info('生成主菜单:[%s][%s][%s][%s][%s]' % (main_menu[0], main_menu[1], main_menu[2],