password getpass( nt密码 )
result __user_service.login(username,password) # getpass可以隐藏密码
# 登录成功
if result:
# 查询角色
role __user_service.search_user_role(username)
while True:
os.system( cls )
if role 新闻编辑 :
print( test )
elif role 管理员 :
print(Fore.LIGHTGREEN_EX, nt1.新闻管理 )
print(Fore.LIGHTGREEN_EX, nt2.用户管理 )
print(Fore.LIGHTRED_EX, ntback.退出登录 )
print(Fore.LIGHTRED_EX, ntexit.退出系统 )
print(Style.RESET_ALL)
opt input( nt输入操作编号 )
if opt 1 :
while True:
os.system( cls )
print(Fore.LIGHTGREEN_EX, nt1.审批新闻 )
print(Fore.LIGHTGREEN_EX, nt2.删除新闻 )
print(Fore.LIGHTRED_EX, ntback.返回上一层 )
print(Style.RESET_ALL)
opt input( nt输入操作编号 ) # TODO:新闻操作
if opt 1 :
page 1
while True:
os.system( cls )
count_page __news_service.search_unreview_count_page()
result __news_service.search_unreview_list(page)
for index in range(len(result)):
one result[index]
print(Fore.LIGHTBLUE_EX, nt%dt%st%st%st%s %
(index 1, one[1], one[2], one[3], one[4]))
print(Fore.LIGHTBLUE_EX, nt---------------------- )
print(Fore.LIGHTBLUE_EX, nt%d/%d % (page, count_page))
print(Fore.LIGHTBLUE_EX, nt---------------------- )
print(Fore.LIGHTRED_EX, ntback.返回上一层 )
print(Fore.LIGHTRED_EX, ntprev.上一页 )
print(Fore.LIGHTRED_EX, ntnext.下一页 )
print(Style.RESET_ALL)
opt input( nt输入操作编号 )
if opt back :
break
elif opt prev and page 1:
page - 1
elif opt next and page count_page:
page 1
elif int(opt) 1 and int(opt) 10:
news_id result[int(opt)-1][0]
__news_service.update_unreview_news(news_id)
elif opt 2 :
page 1
while True:
os.system( cls )
count_page __news_service.search_count_page()
result __news_service.search_list(page)
for index in range(len(result)):
one result[index]
print(Fore.LIGHTBLUE_EX, nt%dt%st%st%st%s %
(index 1, one[1], one[2], one[3], one[4]))
print(Fore.LIGHTBLUE_EX, nt---------------------- )
print(Fore.LIGHTBLUE_EX, nt%d/%d % (page, count_page))
print(Fore.LIGHTBLUE_EX, nt---------------------- )
print(Fore.LIGHTRED_EX, ntback.返回上一层 )
print(Fore.LIGHTRED_EX, ntprev.上一页 )
print(Fore.LIGHTRED_EX, ntnext.下一页 )
print(Style.RESET_ALL)
opt input( nt输入操作编号 )
if opt back :
break
elif opt prev and page 1:
page - 1
elif opt next and page count_page:
page 1
elif int(opt) 1 and int(opt) 10:
news_id result[int(opt)-1][0]
__news_service.delete_by_id(news_id)
elif opt back :
break
elif opt 2 :
while True:
os.system( cls )
print(Fore.LIGHTGREEN_EX, nt1.添加用户 )
print(Fore.LIGHTGREEN_EX, nt2.修改用户 )
print(Fore.LIGHTGREEN_EX, nt3.删除用户 )
print(Fore.LIGHTRED_EX, ntback.返回上一层 )
print(Style.RESET_ALL)
opt input( nt输入操作编号 )
if opt back :
break
elif opt 1 :
os.system( cls )
username input( nt用户名 )
password getpass( nt密码 )
repassword getpass( nt确认密码 )
if password! repassword:
print( nt两次密码不一致 3秒自动返回 )
time.sleep(3)
continue
email input( nt邮箱 )
result __role_service.search_list()
for index in range(len(result)):
one result[index]
print(Fore.LIGHTBLUE_EX, nt%d.%s % (index 1, one[1])) # 输出已有角色
print(Style.RESET_ALL)
opt input( nt角色编号 )
role_id result[int(opt)-1][0]
__user_service.insert(username,password,email,role_id)
print( nt保存成功 3秒自动返回 )
time.sleep(3)
elif opt 2 :
page 1
while True:
os.system( cls )
count_page __user_service.search_count_page()
result __user_service.search_list(page)
for index in range(len(result)):
one result[index]
print(Fore.LIGHTBLUE_EX, nt%dt%st%s %
(index 1, one[1], one[2]))
print(Fore.LIGHTBLUE_EX, nt---------------------- )
print(Fore.LIGHTBLUE_EX, nt%d/%d % (page, count_page))
print(Fore.LIGHTBLUE_EX, nt---------------------- )
print(Fore.LIGHTRED_EX, ntback.返回上一层 )
print(Fore.LIGHTRED_EX, ntprev.上一页 )
print(Fore.LIGHTRED_EX, ntnext.下一页 )
print(Style.RESET_ALL)
opt input( nt输入操作编号 )
if opt back :
break
elif opt prev and page 1:
page - 1
elif opt next and page count_page:
page 1
elif int(opt) 1 and int(opt) 10:
os.system( cls )
user_id result[int(opt)-1][0]
username input( nt新用户名 )
password getpass( nt新密码 )
repassword getpass( nt再次输入密码 )
if password! repassword:
print(Fore.LIGHTRED_EX, nt两次密码不一致 3秒自动返回 )
print(Style.RESET_ALL)
time.sleep(3)
continue
email input( nt新邮箱 )
result __role_service.search_list()
for index in range(len(result)):
one result[index]
print(Fore.LIGHTBLUE_EX, nt%d.%s % (index 1, one[1])) # 输出已有角色
print(Style.RESET_ALL)
opt input( nt角色编号 )
role_id result[int(opt) - 1][0]
opt input( nt是否保存(Y/N) )
if opt Y or opt y : # TODO:用户操作
__user_service.update(user_id,username,password,email,role_id)
print( nt保存成功 3秒自动返回 )
time.sleep(3)
elif opt 3 :
page 1
while True:
os.system( cls )
count_page __user_service.search_count_page()
result __user_service.search_list(page)
for index in range(len(result)):
one result[index]
print(Fore.LIGHTBLUE_EX, nt%dt%st%s %
(index 1, one[1], one[2]))
print(Fore.LIGHTBLUE_EX, nt---------------------- )
print(Fore.LIGHTBLUE_EX, nt%d/%d % (page, count_page))
print(Fore.LIGHTBLUE_EX, nt---------------------- )
print(Fore.LIGHTRED_EX, ntback.返回上一层 )
print(Fore.LIGHTRED_EX, ntprev.上一页 )
print(Fore.LIGHTRED_EX, ntnext.下一页 )
print(Style.RESET_ALL)
opt input( nt输入操作编号 )
if opt back :
break
elif opt prev and page 1:
page - 1
elif opt next and page count_page:
page 1
elif int(opt) 1 and int(opt) 10:
os.system( cls )
user_id result[int(opt)-1][0]
__user_service.delete_by_id(user_id)
print( nt删除成功 3秒自动返回 )
time.sleep(3)
elif opt back :
break
elif opt exit :
sys.exit(0)
else:
print( nt登录失败 3秒自动返回 )
time.sleep(3)
elif opt 2 :
sys.exit(0) # 退出系统