def CreateDropRequest(self, isInit, params=None): db.drop_all() db.create_all() s = db.session() try: s.add(InitSql(isInit=False)) s.commit() role_id = uuid.uuid4() role = Role( role_id=role_id, name=self.role_name, mark=default['role_mark'] ) s.add(role) s.commit() password = self.__get_code() if not isInit: admin = Admin( admin_id=uuid.uuid4(), username=self.user_name, password=Config().get_md5(password), avatarUrl='', role_id=role_id ) else: admin = Admin( admin_id=params['admin_id'], username=self.user_name, password=params['password'], avatarUrl='', role_id=role_id ) s.add(admin) s.commit() self.__init_menus(s, init_menu) folder = Folder( folder_id=uuid.uuid4(), admin_id=None, name=u'系统文件', is_sys=True ) s.add(folder) s.commit() sql = s.query(InitSql).one() sql.isInit = True s.commit() return { 'username': '******', 'password': password } except Exception as e: s.rollback() print e return str(e.message)
def CreateFolderRequest(self, params): ''' 新建文件夹 ''' s = db.session() try: item = Folder( folder_id=uuid.uuid4(), pid=params['pid'], name=params['name'], admin_id=params['admin_id'], is_sys=params['is_sys'] ) s.add(item) s.commit() return item.to_json() except Exception as e: s.rollback() print e return str(e.message)
def CreateFolderRequest(self, params): ''' 新建文件夹 ''' s = db.session() try: item = Folder(folder_id=uuid.uuid4(), parent_id=params['parent_id'], name=params['name']) s.add(item) s.commit() return True except Exception as e: s.rollback() print e return str(e.message)
def CreateDropRequest(self, is_init, params=None): db.session.remove() db.drop_all() db.create_all() s = db.session() try: role_id = str(uuid.uuid4()) role = Role(role_id=role_id, name=self.role_name, mark=default['role_mark']) self.__init_menus(role, s, init_menu) password = self.__get_code() if not is_init: admin = Admin(admin_id=str(uuid.uuid4()), username=self.user_name, password=_config.get_md5(password), role_id=role_id) else: admin = Admin(admin_id=params['admin_id'], username=self.user_name, password=params['password'], role_id=role_id) folder = Folder(folder_id=str(uuid.uuid4()), name=self.folder_name) init = InitSql(is_init=True) s.add_all([role, admin, folder, init]) s.commit() return {'username': self.user_name, 'password': password} except Exception as e: print(e) s.rollback() s.add(InitSql(is_init=False)) s.commit() return str(e)