Example #1
0
 def count_all_pages(self):
     pages = execute_select_sql(
         self.count_pages_sql.replace("WHERE role_id = %s", ""), Config.page_size
     )
     return pages
Example #2
0
 def get_all_roles(self):
     role_info = execute_select_sql(self.get_role_sql.replace("WHERE id = %s", ""))
     return role_info
Example #3
0
 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
Example #4
0
 def get_user(self, user_id):
     user_info = execute_select_sql(self.get_user_sql, user_id)
     return user_info
Example #5
0
 def check_username(self, username):
     result = execute_select_sql(self.check_username_sql, username)
     return result
Example #6
0
 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
Example #7
0
 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
Example #8
0
 def get_all_type(self):
     results = execute_select_sql(self.get_all_type_sql)
     return results
Example #9
0
 def count_pending_pages(self):
     pages = execute_select_sql(self.count_pages_sql, Config.page_size,
                                "待审批")
     return pages
Example #10
0
 def get_pending_news(self, page):
     results = execute_select_sql(self.get_news_sql, "待审批",
                                  (page - 1) * Config.page_size,
                                  Config.page_size)
     return results
Example #11
0
 def search_mongo_id(self, news_id):
     mongo_id = execute_select_sql(self.get_news_mongo_id, news_id)[0][0]
     return mongo_id
Example #12
0
 def get_news_for_edit(self, news_id):
     result = execute_select_sql(self.get_news_for_edit_sql, news_id)
     return result
Example #13
0
 def get_news_detail(self, news_id):
     result = execute_select_sql(self.get_news_detail_sql, news_id)
     return result