def count_all_pages(self): pages = execute_select_sql( self.count_pages_sql.replace("WHERE role_id = %s", ""), Config.page_size ) return pages
def get_all_roles(self): role_info = execute_select_sql(self.get_role_sql.replace("WHERE id = %s", "")) return role_info
def get_all_users(self, page): users_info = execute_select_sql( self.get_users_sql.replace("WHERE r.role = %s", ""), (page - 1) * Config.page_size, Config.page_size ) return users_info
def get_user(self, user_id): user_info = execute_select_sql(self.get_user_sql, user_id) return user_info
def check_username(self, username): result = execute_select_sql(self.check_username_sql, username) return result
def check_user(self, username, password): user_info = execute_select_sql(self.check_user_sql, username, Config.secret_key, password) if user_info: return {"user_id": user_info[0][0], "username": user_info[0][1], "role": user_info[0][2]} return False
def get_all_news(self, page): results = execute_select_sql( self.get_news_sql.replace("WHERE n.state = %s", ""), (page - 1) * Config.page_size, Config.page_size) return results
def get_all_type(self): results = execute_select_sql(self.get_all_type_sql) return results
def count_pending_pages(self): pages = execute_select_sql(self.count_pages_sql, Config.page_size, "待审批") return pages
def get_pending_news(self, page): results = execute_select_sql(self.get_news_sql, "待审批", (page - 1) * Config.page_size, Config.page_size) return results
def search_mongo_id(self, news_id): mongo_id = execute_select_sql(self.get_news_mongo_id, news_id)[0][0] return mongo_id
def get_news_for_edit(self, news_id): result = execute_select_sql(self.get_news_for_edit_sql, news_id) return result
def get_news_detail(self, news_id): result = execute_select_sql(self.get_news_detail_sql, news_id) return result