from colorama import Fore,Style
from getpass import getpass
from service.user_service import UserService
from service.news_service import NewsService
from service.role_service import RoleService
from service.type_service import TypeService
import os
import sys
import time
__user_service=UserService()
__news_service=NewsService()
__role_service=RoleService()
__type_service=TypeService()
while True:
os.system("cls")
print(Fore.LIGHTBLUE_EX,"\n\t====================")
print(Fore.LIGHTBLUE_EX,"\n\t欢迎使用新闻管理系统")
print(Fore.LIGHTBLUE_EX,"\n\t====================")
print(Fore.LIGHTGREEN_EX,"\n\t1.登录系统")
print(Fore.LIGHTGREEN_EX,"\n\t2.退出系统")
print(Style.RESET_ALL)
opt=input("\n\t输入操作编号:")
if opt=="1":
username=input("\n\t用户名;")
password=getpass("\n\t密码;")
result=__user_service.login(username,password)
if result==True:
role=__user_service.surch_user_role(username)
while True:
os.system("cls")
if role=="新闻编辑":
print(Fore.LIGHTGREEN_EX, "\n\t1.发表新闻")
print(Fore.LIGHTGREEN_EX, "\n\t2.编辑新闻")
print(Fore.LIGHTRED_EX, "\n\tback.退出登录")
print(Fore.LIGHTRED_EX, "\n\texit.退出系统")
print(Style.RESET_ALL)
opt = input("\n\t输入操作编号:")
if opt=="1":
os.system("cls")
title=input("\n\t新闻标题:")
userid=__user_service.search_userid(username)
result=__type_service.search_list()
for index in range(len(result)):
one = result[index]
print(Fore.LIGHTBLUE_EX, "\n\t%d,%s" % (index + 1, one[1]))
print(Style.RESET_ALL)
opt = input("\n\t类型编号:")
type_id = result[int(opt) - 1][0]
#TODO 新闻正文内容
path=input("\n\t输入文件路径:")
file=open(path,"r")
content=file.read()
file.close()
is_top=input("\n\t置顶级别(0-5):")
is_commite=input("\n\t是否提交(Y/N):")
if is_commite=="Y" or is_commite=="y":
__news_service.insert(title, userid, type_id, content, is_top)
print("\n\t保存成功(3秒自动返回)")
time.sleep(3)
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, "\n\t%d,\t%s,\t%s,\t%s" % (index + 1, one[1], one[2], one[3]))
print(Fore.LIGHTBLUE_EX, "\n\t-----------------")
print(Fore.LIGHTBLUE_EX, "\n\t%d/%d" % (page, count_page))
print(Fore.LIGHTBLUE_EX, "\n\t-----------------")
print(Fore.LIGHTRED_EX, "\n\tback.返回上一层")
print(Fore.LIGHTRED_EX, "\n\tprev.上一页")
print(Fore.LIGHTRED_EX, "\n\tnext.下一页")
print(Style.RESET_ALL)
opt = input("\n\t输入操作编号:")
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")
news_id = result[int(opt) - 1][0]
result=__news_service.search_by_id(news_id)
title=result[0]
type=result[1]
is_top=result[2]
print("\n\t新闻原标题: %s"%(title))
new_title=input("\n\t新标题:")
print("\n\t原类型: %s"%(type))
result = __type_service.search_list()
for index in range(len(result)):
one = result[index]
print(Fore.LIGHTBLUE_EX, "\n\t%d,%s" % (index + 1, one[1]))
print(Style.RESET_ALL)
opt = input("\n\t类型编号:")
type_id = result[int(opt) - 1][0]
#TODO 输入新闻内容
path=input("\n\t输入内容路径:")
file=open(path,"r")
content=file.read()
file.close()
print("\n\t原置顶级别: %s" % (is_top))
new_is_top=input("\n\t置顶级别(0-5):")
is_commite = input("\n\t是否提交(Y/N):")
if is_commite == "Y" or is_commite == "y":
__news_service.update(news_id,new_title,type_id,content,new_is_top)
print("\n\t保存成功(3秒自动返回)")
time.sleep(3)
elif opt=="back":
break;
elif opt=="exit":
sys.exit(0)
elif role=="管理员":
print(Fore.LIGHTGREEN_EX,"\n\t1.新闻管理")
print(Fore.LIGHTGREEN_EX,"\n\t2.用户管理")
print(Fore.LIGHTRED_EX,"\n\tback.退出登录")
print(Fore.LIGHTRED_EX,"\n\texit.退出系统")
print(Style.RESET_ALL)
opt=input("\n\t输入操作编号:")
if opt=="1":
while True:
os.system("cls")
print(Fore.LIGHTGREEN_EX,"\n\t1.审批新闻")
print(Fore.LIGHTGREEN_EX,"\n\t2.删除新闻")
print(Fore.LIGHTRED_EX,"\n\tback.返回上一层")
print(Style.RESET_ALL)
opt=input("\n\t输入操作编号:")
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,"\n\t%d,\t%s,\t%s,\t%s"%(index+1,one[1],one[2],one[3]))
print(Fore.LIGHTBLUE_EX, "\n\t-----------------")
print(Fore.LIGHTBLUE_EX, "\n\t%d/%d"%(page,count_page))
没有合适的资源?快使用搜索试试~ 我知道了~
后台新闻管理系统(python)
共14个文件
py:14个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 71 浏览量
2023-06-15
06:58:41
上传
评论
收藏 9KB ZIP 举报
温馨提示
后台新闻管理系统(python) 控制台面板程序,无页面
资源推荐
资源详情
资源评论
收起资源包目录
NEWS-master.zip (14个子文件)
NEWS-master
news_dao.py 6KB
mysql_db.py 314B
redis_news_dao.py 910B
app.py 19KB
news_service.py 2KB
mongo_db.py 130B
user_dao.py 4KB
mongo_news_dao.py 1KB
redis_db.py 185B
user_service.py 1KB
role_dao.py 463B
role_service.py 204B
type_dao.py 490B
type_service.py 208B
共 14 条
- 1
资源评论
Roc-xb
- 粉丝: 12w+
- 资源: 8207
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功