当前位置:   article > 正文

基于Python实现校园影院平台系统[源码+LW+部署讲解视频]

基于Python实现校园影院平台系统[源码+LW+部署讲解视频]

作者简介:Java领域优质创作者、CSDN博客专家 、CSDN内容合伙人、掘金特邀作者、阿里云博客专家、51CTO特邀作者、多年架构师设计经验、多年校企合作经验,被多个学校常年聘为校外企业导师,指导学生毕业设计并参与学生毕业答辩指导,有较为丰富的相关经验。期待与各位高校教师、企业讲师以及同行交流合作

主要内容:Java项目、Python项目、前端项目、PHP、ASP.NET、人工智能与大数据、单片机开发、物联网设计与开发设计、简历模板、学习资料、面试题库、技术互助、就业指导等

业务范围:免费功能设计、开题报告、任务书、中期检查PPT、系统功能实现、代码编写、论文编写和辅导、论文降重、长期答辩答疑辅导、腾讯会议一对一专业讲解辅导答辩、模拟答辩演练、和理解代码逻辑思路等

收藏点赞不迷路  关注作者有好处

文末获取源码 

项目编号:BS-Python-070

一,环境介绍

语言环境:Python3.8

数据库:Mysql: mysql5.7

WEB框架:Django

开发工具:IDEA或PyCharm

项目获取地址:基于Python实现校园影院

二,项目简介

随着社会的不断进步与发展,人们对生活质量要求逐步提升。如果开发一款柚子校园影院,可以让管理员和用户在最短的时间里享受到最好的服务;而开发本系统,又能够提高系统整体工作水平,简化工作程序,这对管理员和用户来说都是一件非常乐意的事情。

本论文针对柚子校园影院的特点,以Python为核心,以MySQL为数据库,B/S为系统构架,对柚子校园影院进行设计和开发。通过使用本系统可有效地减少运营成本,提高管理效率。

20世纪,随着科学技术的飞速发展,数字化和信息化成为了一个新的发展趋势,信息化的管理方式成为了各个行业的追求的目标,而信息化的管理方式更是成为了人们追求的目标。目前,我国高等院校工程技术和电子管理学已经将信息化技术作为必修课。

在当今社会,人们的生活节奏逐渐加快,人们对经济的要求逐渐降低,越来越多的人开始追求简单、快捷的方式。随着经济的发展,人民的生活水平也提高了,用户有了更多的时间去消费。然而,柚子校园影院管理模式的改进却是一项比较繁杂的工作,因此,管理人员要充分发挥信息化管理的作用,提高柚子校园影院的整体管理能力和整体素质。

在科技飞速发展的今天,柚子校园影院管理体系已全面更新,管理体系的更新,不但能让用户享受到更为高品质的服务,同时也能提升柚子校园影院管理的工作效率。通过管理上的便利,使管理上也更加有序。然而,当前大多仍采用大规模的人工管理方式,这种管理方式耗费了较多的人力物力,而且很难维持。而本系统要采用一种易于使用、处理速度快、计算准确且适应的服务需求的经营模式。这种新型的经营管理体系将有助于今后的发展,改进当前的经营状况,提升用户的工作效率,同时为柚子校园影院创造更高的效率。

功能模块设计

三,系统展示

前端页面

后台管理员

四,核心代码展示

  1. #coding:utf-8
  2. __author__ = "ila"
  3. import base64, copy, logging, os, sys, time, xlrd, json, datetime, configparser
  4. from django.http import JsonResponse
  5. from django.apps import apps
  6. from django.db.models.aggregates import Count,Sum
  7. from .models import dianyinggoupiao
  8. from util.codes import *
  9. from util.auth import Auth
  10. from util.common import Common
  11. import util.message as mes
  12. from django.db import connection
  13. import random
  14. from django.core.mail import send_mail
  15. from django.conf import settings
  16. from django.shortcuts import redirect
  17. from django.db.models import Q
  18. from util.baidubce_api import BaiDuBce
  19. from .config_model import config
  20. def dianyinggoupiao_register(request):
  21. if request.method in ["POST", "GET"]:
  22. msg = {'code': normal_code, "msg": mes.normal_code}
  23. req_dict = request.session.get("req_dict")
  24. error = dianyinggoupiao.createbyreq(dianyinggoupiao, dianyinggoupiao, req_dict)
  25. if error != None:
  26. msg['code'] = crud_error_code
  27. msg['msg'] = "用户已存在,请勿重复注册!"
  28. return JsonResponse(msg)
  29. def dianyinggoupiao_login(request):
  30. if request.method in ["POST", "GET"]:
  31. msg = {'code': normal_code, "msg": mes.normal_code}
  32. req_dict = request.session.get("req_dict")
  33. datas = dianyinggoupiao.getbyparams(dianyinggoupiao, dianyinggoupiao, req_dict)
  34. if not datas:
  35. msg['code'] = password_error_code
  36. msg['msg'] = mes.password_error_code
  37. return JsonResponse(msg)
  38. try:
  39. __sfsh__= dianyinggoupiao.__sfsh__
  40. except:
  41. __sfsh__=None
  42. if __sfsh__=='是':
  43. if datas[0].get('sfsh')!='是':
  44. msg['code']=other_code
  45. msg['msg'] = "账号已锁定,请联系管理员审核!"
  46. return JsonResponse(msg)
  47. req_dict['id'] = datas[0].get('id')
  48. return Auth.authenticate(Auth, dianyinggoupiao, req_dict)
  49. def dianyinggoupiao_logout(request):
  50. if request.method in ["POST", "GET"]:
  51. msg = {
  52. "msg": "登出成功",
  53. "code": 0
  54. }
  55. return JsonResponse(msg)
  56. def dianyinggoupiao_resetPass(request):
  57. '''
  58. '''
  59. if request.method in ["POST", "GET"]:
  60. msg = {"code": normal_code, "msg": mes.normal_code}
  61. req_dict = request.session.get("req_dict")
  62. columns= dianyinggoupiao.getallcolumn( dianyinggoupiao, dianyinggoupiao)
  63. try:
  64. __loginUserColumn__= dianyinggoupiao.__loginUserColumn__
  65. except:
  66. __loginUserColumn__=None
  67. username=req_dict.get(list(req_dict.keys())[0])
  68. if __loginUserColumn__:
  69. username_str=__loginUserColumn__
  70. else:
  71. username_str=username
  72. if 'mima' in columns:
  73. password_str='mima'
  74. else:
  75. password_str='password'
  76. init_pwd = '123456'
  77. recordsParam = {}
  78. recordsParam[username_str] = req_dict.get("username")
  79. records=dianyinggoupiao.getbyparams(dianyinggoupiao, dianyinggoupiao, recordsParam)
  80. if len(records)<1:
  81. msg['code'] = 400
  82. msg['msg'] = '用户不存在'
  83. return JsonResponse(msg)
  84. eval('''dianyinggoupiao.objects.filter({}='{}').update({}='{}')'''.format(username_str,username,password_str,init_pwd))
  85. return JsonResponse(msg)
  86. def dianyinggoupiao_session(request):
  87. '''
  88. '''
  89. if request.method in ["POST", "GET"]:
  90. msg = {"code": normal_code,"msg": mes.normal_code, "data": {}}
  91. req_dict={"id":request.session.get('params').get("id")}
  92. msg['data'] = dianyinggoupiao.getbyparams(dianyinggoupiao, dianyinggoupiao, req_dict)[0]
  93. return JsonResponse(msg)
  94. def dianyinggoupiao_default(request):
  95. if request.method in ["POST", "GET"]:
  96. msg = {"code": normal_code,"msg": mes.normal_code, "data": {}}
  97. req_dict = request.session.get("req_dict")
  98. req_dict.update({"isdefault":"是"})
  99. data=dianyinggoupiao.getbyparams(dianyinggoupiao, dianyinggoupiao, req_dict)
  100. if len(data)>0:
  101. msg['data'] = data[0]
  102. else:
  103. msg['data'] = {}
  104. return JsonResponse(msg)
  105. def dianyinggoupiao_page(request):
  106. '''
  107. '''
  108. if request.method in ["POST", "GET"]:
  109. msg = {"code": normal_code, "msg": mes.normal_code, "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
  110. req_dict = request.session.get("req_dict")
  111. #获取全部列名
  112. columns= dianyinggoupiao.getallcolumn( dianyinggoupiao, dianyinggoupiao)
  113. #当前登录用户所在表
  114. tablename = request.session.get("tablename")
  115. #authColumn=list(__authTables__.keys())[0]
  116. #authTable=__authTables__.get(authColumn)
  117. # if authTable==tablename:
  118. #params = request.session.get("params")
  119. #req_dict[authColumn]=params.get(authColumn)
  120. '''__authSeparate__此属性为真,params添加userid,后台只查询个人数据'''
  121. try:
  122. __authSeparate__=dianyinggoupiao.__authSeparate__
  123. except:
  124. __authSeparate__=None
  125. if __authSeparate__=="是":
  126. tablename=request.session.get("tablename")
  127. if tablename!="users" and 'userid' in columns:
  128. try:
  129. req_dict['userid']=request.session.get("params").get("id")
  130. except:
  131. pass
  132. #当项目属性hasMessage为”是”,生成系统自动生成留言板的表messages,同时该表的表属性hasMessage也被设置为”是”,字段包括userid(用户id),username(用户名),content(留言内容),reply(回复)
  133. #接口page需要区分权限,普通用户查看自己的留言和回复记录,管理员查看所有的留言和回复记录
  134. try:
  135. __hasMessage__=dianyinggoupiao.__hasMessage__
  136. except:
  137. __hasMessage__=None
  138. if __hasMessage__=="是":
  139. tablename=request.session.get("tablename")
  140. if tablename!="users":
  141. req_dict["userid"]=request.session.get("params").get("id")
  142. # 判断当前表的表属性isAdmin,为真则是管理员表
  143. # 当表属性isAdmin=”是”,刷出来的用户表也是管理员,即page和list可以查看所有人的考试记录(同时应用于其他表)
  144. __isAdmin__ = None
  145. allModels = apps.get_app_config('main').get_models()
  146. for m in allModels:
  147. if m.__tablename__==tablename:
  148. try:
  149. __isAdmin__ = m.__isAdmin__
  150. except:
  151. __isAdmin__ = None
  152. break
  153. # 当前表也是有管理员权限的表
  154. if __isAdmin__ == "是" and 'dianyinggoupiao' != 'forum':
  155. if req_dict.get("userid") and 'dianyinggoupiao' != 'chat':
  156. del req_dict["userid"]
  157. else:
  158. #非管理员权限的表,判断当前表字段名是否有userid
  159. if tablename!="users" and 'dianyinggoupiao'[:7]!='discuss'and "userid" in dianyinggoupiao.getallcolumn(dianyinggoupiao,dianyinggoupiao):
  160. req_dict["userid"] = request.session.get("params").get("id")
  161. #当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致],则对应的表有个隐藏属性authTable为”是”,那么该用户查看该表信息时,只能查看自己的
  162. try:
  163. __authTables__=dianyinggoupiao.__authTables__
  164. except:
  165. __authTables__=None
  166. if __authTables__!=None and __authTables__!={}:
  167. try:
  168. del req_dict['userid']
  169. # tablename=request.session.get("tablename")
  170. # if tablename=="users":
  171. # del req_dict['userid']
  172. except:
  173. pass
  174. for authColumn,authTable in __authTables__.items():
  175. if authTable==tablename:
  176. params = request.session.get("params")
  177. req_dict[authColumn]=params.get(authColumn)
  178. username=params.get(authColumn)
  179. break
  180. q = Q()
  181. msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
  182. msg['data']['pageSize'] =dianyinggoupiao.page(dianyinggoupiao, dianyinggoupiao, req_dict, request, q)
  183. return JsonResponse(msg)
  184. def dianyinggoupiao_autoSort(request):
  185. '''
  186. .智能推荐功能(表属性:[intelRecom(是/否)],新增clicktime[前端不显示该字段]字段(调用info/detail接口的时候更新),按clicktime排序查询)
  187. 主要信息列表(如商品列表,新闻列表)中使用,显示最近点击的或最新添加的5条记录就行
  188. '''
  189. if request.method in ["POST", "GET"]:
  190. msg = {"code": normal_code, "msg": mes.normal_code, "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
  191. req_dict = request.session.get("req_dict")
  192. if "clicknum" in dianyinggoupiao.getallcolumn(dianyinggoupiao,dianyinggoupiao):
  193. req_dict['sort']='clicknum'
  194. elif "browseduration" in dianyinggoupiao.getallcolumn(dianyinggoupiao,dianyinggoupiao):
  195. req_dict['sort']='browseduration'
  196. else:
  197. req_dict['sort']='clicktime'
  198. req_dict['order']='desc'
  199. msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
  200. msg['data']['pageSize'] = dianyinggoupiao.page(dianyinggoupiao,dianyinggoupiao, req_dict)
  201. return JsonResponse(msg)
  202. def dianyinggoupiao_list(request):
  203. '''
  204. 前台分页
  205. '''
  206. if request.method in ["POST", "GET"]:
  207. msg = {"code": normal_code, "msg": mes.normal_code, "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
  208. req_dict = request.session.get("req_dict")
  209. if req_dict.__contains__('vipread'):
  210. del req_dict['vipread']
  211. #获取全部列名
  212. columns= dianyinggoupiao.getallcolumn( dianyinggoupiao, dianyinggoupiao)
  213. #表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
  214. try:
  215. __foreEndList__=dianyinggoupiao.__foreEndList__
  216. except:
  217. __foreEndList__=None
  218. if __foreEndList__=="前要登":
  219. tablename=request.session.get("tablename")
  220. if tablename!="users" and 'userid' in columns:
  221. try:
  222. req_dict['userid']=request.session.get("params").get("id")
  223. except:
  224. pass
  225. #forrEndListAuth
  226. try:
  227. __foreEndListAuth__=dianyinggoupiao.__foreEndListAuth__
  228. except:
  229. __foreEndListAuth__=None
  230. #authSeparate
  231. try:
  232. __authSeparate__=dianyinggoupiao.__authSeparate__
  233. except:
  234. __authSeparate__=None
  235. if __foreEndListAuth__ =="是" and __authSeparate__=="是":
  236. tablename=request.session.get("tablename")
  237. if tablename!="users":
  238. req_dict['userid']=request.session.get("params",{"id":0}).get("id")
  239. tablename = request.session.get("tablename")
  240. if tablename == "users" and req_dict.get("userid") != None:#判断是否存在userid列名
  241. del req_dict["userid"]
  242. else:
  243. __isAdmin__ = None
  244. allModels = apps.get_app_config('main').get_models()
  245. for m in allModels:
  246. if m.__tablename__==tablename:
  247. try:
  248. __isAdmin__ = m.__isAdmin__
  249. except:
  250. __isAdmin__ = None
  251. break
  252. if __isAdmin__ == "是":
  253. if req_dict.get("userid"):
  254. # del req_dict["userid"]
  255. pass
  256. else:
  257. #非管理员权限的表,判断当前表字段名是否有userid
  258. if "userid" in columns:
  259. try:
  260. pass
  261. except:
  262. pass
  263. #当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致],则对应的表有个隐藏属性authTable为”是”,那么该用户查看该表信息时,只能查看自己的
  264. try:
  265. __authTables__=dianyinggoupiao.__authTables__
  266. except:
  267. __authTables__=None
  268. if __authTables__!=None and __authTables__!={} and __foreEndListAuth__=="是":
  269. try:
  270. del req_dict['userid']
  271. except:
  272. pass
  273. for authColumn,authTable in __authTables__.items():
  274. if authTable==tablename:
  275. params = request.session.get("params")
  276. req_dict[authColumn]=params.get(authColumn)
  277. username=params.get(authColumn)
  278. break
  279. if dianyinggoupiao.__tablename__[:7]=="discuss":
  280. try:
  281. del req_dict['userid']
  282. except:
  283. pass
  284. q = Q()
  285. msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
  286. msg['data']['pageSize'] = dianyinggoupiao.page(dianyinggoupiao, dianyinggoupiao, req_dict, request, q)
  287. return JsonResponse(msg)
  288. def dianyinggoupiao_save(request):
  289. '''
  290. 后台新增
  291. '''
  292. if request.method in ["POST", "GET"]:
  293. msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
  294. req_dict = request.session.get("req_dict")
  295. if 'clicktime' in req_dict.keys():
  296. del req_dict['clicktime']
  297. tablename=request.session.get("tablename")
  298. __isAdmin__ = None
  299. allModels = apps.get_app_config('main').get_models()
  300. for m in allModels:
  301. if m.__tablename__==tablename:
  302. try:
  303. __isAdmin__ = m.__isAdmin__
  304. except:
  305. __isAdmin__ = None
  306. break
  307. #获取全部列名
  308. columns= dianyinggoupiao.getallcolumn( dianyinggoupiao, dianyinggoupiao)
  309. if tablename!='users' and req_dict.get("userid")!=None and 'userid' in columns and __isAdmin__!='是':
  310. params=request.session.get("params")
  311. req_dict['userid']=params.get('id')
  312. if 'addtime' in req_dict.keys():
  313. del req_dict['addtime']
  314. error= dianyinggoupiao.createbyreq(dianyinggoupiao,dianyinggoupiao, req_dict)
  315. if error!=None:
  316. msg['code'] = crud_error_code
  317. msg['msg'] = error
  318. return JsonResponse(msg)
  319. def dianyinggoupiao_add(request):
  320. '''
  321. 前台新增
  322. '''
  323. if request.method in ["POST", "GET"]:
  324. msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
  325. req_dict = request.session.get("req_dict")
  326. #获取全部列名
  327. columns= dianyinggoupiao.getallcolumn( dianyinggoupiao, dianyinggoupiao)
  328. try:
  329. __authSeparate__=dianyinggoupiao.__authSeparate__
  330. except:
  331. __authSeparate__=None
  332. if __authSeparate__=="是":
  333. tablename=request.session.get("tablename")
  334. if tablename!="users" and 'userid' in columns:
  335. try:
  336. req_dict['userid']=request.session.get("params").get("id")
  337. except:
  338. pass
  339. try:
  340. __foreEndListAuth__=dianyinggoupiao.__foreEndListAuth__
  341. except:
  342. __foreEndListAuth__=None
  343. if __foreEndListAuth__ and __foreEndListAuth__!="否":
  344. tablename=request.session.get("tablename")
  345. if tablename!="users":
  346. req_dict['userid']=request.session.get("params").get("id")
  347. if 'addtime' in req_dict.keys():
  348. del req_dict['addtime']
  349. error= dianyinggoupiao.createbyreq(dianyinggoupiao,dianyinggoupiao, req_dict)
  350. if error!=None:
  351. msg['code'] = crud_error_code
  352. msg['msg'] = error
  353. return JsonResponse(msg)
  354. def dianyinggoupiao_thumbsup(request,id_):
  355. '''
  356. 点赞:表属性thumbsUp[是/否],刷表新增thumbsupnum赞和crazilynum踩字段,
  357. '''
  358. if request.method in ["POST", "GET"]:
  359. msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
  360. req_dict = request.session.get("req_dict")
  361. id_=int(id_)
  362. type_=int(req_dict.get("type",0))
  363. rets=dianyinggoupiao.getbyid(dianyinggoupiao,dianyinggoupiao,id_)
  364. update_dict={
  365. "id":id_,
  366. }
  367. if type_==1:#赞
  368. update_dict["thumbsupnum"]=int(rets[0].get('thumbsupnum'))+1
  369. elif type_==2:#踩
  370. update_dict["crazilynum"]=int(rets[0].get('crazilynum'))+1
  371. error = dianyinggoupiao.updatebyparams(dianyinggoupiao,dianyinggoupiao, update_dict)
  372. if error!=None:
  373. msg['code'] = crud_error_code
  374. msg['msg'] = error
  375. return JsonResponse(msg)
  376. def dianyinggoupiao_info(request,id_):
  377. '''
  378. '''
  379. if request.method in ["POST", "GET"]:
  380. msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
  381. data = dianyinggoupiao.getbyid(dianyinggoupiao,dianyinggoupiao, int(id_))
  382. if len(data)>0:
  383. msg['data']=data[0]
  384. if msg['data'].__contains__("reversetime"):
  385. msg['data']['reversetime'] = msg['data']['reversetime'].strftime("%Y-%m-%d %H:%M:%S")
  386. #浏览点击次数
  387. try:
  388. __browseClick__= dianyinggoupiao.__browseClick__
  389. except:
  390. __browseClick__=None
  391. if __browseClick__=="是" and "clicknum" in dianyinggoupiao.getallcolumn(dianyinggoupiao,dianyinggoupiao):
  392. try:
  393. clicknum=int(data[0].get("clicknum",0))+1
  394. except:
  395. clicknum=0+1
  396. click_dict={"id":int(id_),"clicknum":clicknum}
  397. ret=dianyinggoupiao.updatebyparams(dianyinggoupiao,dianyinggoupiao,click_dict)
  398. if ret!=None:
  399. msg['code'] = crud_error_code
  400. msg['msg'] = ret
  401. return JsonResponse(msg)
  402. def dianyinggoupiao_detail(request,id_):
  403. '''
  404. '''
  405. if request.method in ["POST", "GET"]:
  406. msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
  407. data =dianyinggoupiao.getbyid(dianyinggoupiao,dianyinggoupiao, int(id_))
  408. if len(data)>0:
  409. msg['data']=data[0]
  410. if msg['data'].__contains__("reversetime"):
  411. msg['data']['reversetime'] = msg['data']['reversetime'].strftime("%Y-%m-%d %H:%M:%S")
  412. #浏览点击次数
  413. try:
  414. __browseClick__= dianyinggoupiao.__browseClick__
  415. except:
  416. __browseClick__=None
  417. if __browseClick__=="是" and "clicknum" in dianyinggoupiao.getallcolumn(dianyinggoupiao,dianyinggoupiao):
  418. try:
  419. clicknum=int(data[0].get("clicknum",0))+1
  420. except:
  421. clicknum=0+1
  422. click_dict={"id":int(id_),"clicknum":clicknum}
  423. ret=dianyinggoupiao.updatebyparams(dianyinggoupiao,dianyinggoupiao,click_dict)
  424. if ret!=None:
  425. msg['code'] = crud_error_code
  426. msg['msg'] = retfo
  427. return JsonResponse(msg)
  428. def dianyinggoupiao_update(request):
  429. '''
  430. '''
  431. if request.method in ["POST", "GET"]:
  432. msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
  433. req_dict = request.session.get("req_dict")
  434. if req_dict.get("mima") and "mima" not in dianyinggoupiao.getallcolumn(dianyinggoupiao,dianyinggoupiao) :
  435. del req_dict["mima"]
  436. if req_dict.get("password") and "password" not in dianyinggoupiao.getallcolumn(dianyinggoupiao,dianyinggoupiao) :
  437. del req_dict["password"]
  438. try:
  439. del req_dict["clicknum"]
  440. except:
  441. pass
  442. error = dianyinggoupiao.updatebyparams(dianyinggoupiao, dianyinggoupiao, req_dict)
  443. if error!=None:
  444. msg['code'] = crud_error_code
  445. msg['msg'] = error
  446. return JsonResponse(msg)
  447. def dianyinggoupiao_delete(request):
  448. '''
  449. 批量删除
  450. '''
  451. if request.method in ["POST", "GET"]:
  452. msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
  453. req_dict = request.session.get("req_dict")
  454. error=dianyinggoupiao.deletes(dianyinggoupiao,
  455. dianyinggoupiao,
  456. req_dict.get("ids")
  457. )
  458. if error!=None:
  459. msg['code'] = crud_error_code
  460. msg['msg'] = error
  461. return JsonResponse(msg)
  462. def dianyinggoupiao_vote(request,id_):
  463. '''
  464. 浏览点击次数(表属性[browseClick:是/否],点击字段(clicknum),调用info/detail接口的时候后端自动+1)、投票功能(表属性[vote:是/否],投票字段(votenum),调用vote接口后端votenum+1)
  465. 统计商品或新闻的点击次数;提供新闻的投票功能
  466. '''
  467. if request.method in ["POST", "GET"]:
  468. msg = {"code": normal_code, "msg": mes.normal_code}
  469. data= dianyinggoupiao.getbyid(dianyinggoupiao, dianyinggoupiao, int(id_))
  470. for i in data:
  471. votenum=i.get('votenum')
  472. if votenum!=None:
  473. params={"id":int(id_),"votenum":votenum+1}
  474. error=dianyinggoupiao.updatebyparams(dianyinggoupiao,dianyinggoupiao,params)
  475. if error!=None:
  476. msg['code'] = crud_error_code
  477. msg['msg'] = error
  478. return JsonResponse(msg)
  479. def dianyinggoupiao_importExcel(request):
  480. if request.method in ["POST", "GET"]:
  481. msg = {"code": normal_code, "msg": "成功", "data": {}}
  482. excel_file = request.FILES.get("file", "")
  483. file_type = excel_file.name.split('.')[1]
  484. if file_type in ['xlsx', 'xls']:
  485. data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())
  486. table = data.sheets()[0]
  487. rows = table.nrows
  488. try:
  489. for row in range(1, rows):
  490. row_values = table.row_values(row)
  491. req_dict = {}
  492. dianyinggoupiao.createbyreq(dianyinggoupiao, dianyinggoupiao, req_dict)
  493. except:
  494. pass
  495. else:
  496. msg = {
  497. "msg": "文件类型错误",
  498. "code": 500
  499. }
  500. return JsonResponse(msg)
  501. def dianyinggoupiao_sendemail(request):
  502. if request.method in ["POST", "GET"]:
  503. req_dict = request.session.get("req_dict")
  504. code = random.sample(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 4)
  505. to = []
  506. to.append(req_dict['email'])
  507. send_mail('用户注册', '您的注册验证码是【'+''.join(code)+'】,请不要把验证码泄漏给其他人,如非本人请勿操作。', 'yclw9@qq.com', to, fail_silently = False)
  508. cursor = connection.cursor()
  509. cursor.execute("insert into emailregistercode(email,role,code) values('"+req_dict['email']+"','用户','"+''.join(code)+"')")
  510. msg = {
  511. "msg": "发送成功",
  512. "code": 0
  513. }
  514. return JsonResponse(msg)
  515. # 推荐算法接口
  516. def dianyinggoupiao_autoSort2(request):
  517. if request.method in ["POST", "GET"]:
  518. req_dict = request.session.get("req_dict")
  519. cursor = connection.cursor()
  520. leixing = set()
  521. try:
  522. cursor.execute("select inteltype from storeup where userid = %d"%(request.session.get("params").get("id"))+" and tablename = 'dianyinggoupiao' order by addtime desc")
  523. rows = cursor.fetchall()
  524. for row in rows:
  525. for item in row:
  526. if item != None:
  527. leixing.add(item)
  528. except:
  529. leixing = set()
  530. L = []
  531. cursor.execute("select * from dianyinggoupiao where $intelRecomColumn in ('%s"%("','").join(leixing)+"') union all select * from dianyinggoupiao where $intelRecomColumn not in('%s"%("','").join(leixing)+"')")
  532. desc = cursor.description
  533. data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
  534. for online_dict in data_dict:
  535. for key in online_dict:
  536. if 'datetime.datetime' in str(type(online_dict[key])):
  537. online_dict[key] = online_dict[key].strftime(
  538. "%Y-%m-%d %H:%M:%S")
  539. else:
  540. pass
  541. L.append(online_dict)
  542. return JsonResponse({"code": 0, "msg": '', "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":5,"list": L[0:int(req_dict["limit"])]}})
  543. def dianyinggoupiao_value(request, xColumnName, yColumnName, timeStatType):
  544. if request.method in ["POST", "GET"]:
  545. msg = {"code": normal_code, "msg": "成功", "data": {}}
  546. where = ' where 1 = 1 '
  547. token = request.META.get('HTTP_TOKEN')
  548. decode_str = eval(base64.b64decode(token).decode("utf8"))
  549. if decode_str['tablename'] == 'yonghu':
  550. where = where + " and yonghuzhanghao ='{0}' ".format(decode_str['params']['yonghuzhanghao'])
  551. sql = ''
  552. if timeStatType == '日':
  553. sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM dianyinggoupiao {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d') LIMIT 10".format(xColumnName, yColumnName, where, '%Y-%m-%d')
  554. if timeStatType == '月':
  555. sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM dianyinggoupiao {2} GROUP BY DATE_FORMAT({0}, '%Y-%m') LIMIT 10".format(xColumnName, yColumnName, where, '%Y-%m')
  556. if timeStatType == '年':
  557. sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM dianyinggoupiao {2} GROUP BY DATE_FORMAT({0}, '%Y') LIMIT 10".format(xColumnName, yColumnName, where, '%Y')
  558. L = []
  559. cursor = connection.cursor()
  560. cursor.execute(sql)
  561. desc = cursor.description
  562. data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
  563. for online_dict in data_dict:
  564. for key in online_dict:
  565. if 'datetime.datetime' in str(type(online_dict[key])):
  566. online_dict[key] = online_dict[key].strftime(
  567. "%Y-%m-%d %H:%M:%S")
  568. else:
  569. pass
  570. L.append(online_dict)
  571. msg['data'] = L
  572. return JsonResponse(msg)
  573. def dianyinggoupiao_o_value(request, xColumnName, yColumnName):
  574. if request.method in ["POST", "GET"]:
  575. msg = {"code": normal_code, "msg": "成功", "data": {}}
  576. where = ' where 1 = 1 '
  577. token = request.META.get('HTTP_TOKEN')
  578. decode_str = eval(base64.b64decode(token).decode("utf8"))
  579. if decode_str['tablename'] == 'yonghu':
  580. where = where + " and yonghuzhanghao ='{0}' ".format(decode_str['params']['yonghuzhanghao'])
  581. sql = "SELECT {0}, sum({1}) AS total FROM dianyinggoupiao {2} GROUP BY {0} LIMIT 10".format(xColumnName, yColumnName, where)
  582. L = []
  583. cursor = connection.cursor()
  584. cursor.execute(sql)
  585. desc = cursor.description
  586. data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
  587. for online_dict in data_dict:
  588. for key in online_dict:
  589. if 'datetime.datetime' in str(type(online_dict[key])):
  590. online_dict[key] = online_dict[key].strftime(
  591. "%Y-%m-%d %H:%M:%S")
  592. else:
  593. pass
  594. L.append(online_dict)
  595. msg['data'] = L
  596. return JsonResponse(msg)
  597. def dianyinggoupiao_group(request, columnName):
  598. if request.method in ["POST", "GET"]:
  599. msg = {"code": normal_code, "msg": "成功", "data": {}}
  600. where = ' where 1 = 1 '
  601. token = request.META.get('HTTP_TOKEN')
  602. decode_str = eval(base64.b64decode(token).decode("utf8"))
  603. if decode_str['tablename'] == 'yonghu':
  604. where = where + " and yonghuzhanghao ='{0}' ".format(decode_str['params']['yonghuzhanghao'])
  605. sql = "SELECT COUNT(*) AS total, " + columnName + " FROM dianyinggoupiao " + where + " GROUP BY " + columnName + " LIMIT 10"
  606. L = []
  607. cursor = connection.cursor()
  608. cursor.execute(sql)
  609. desc = cursor.description
  610. data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
  611. for online_dict in data_dict:
  612. for key in online_dict:
  613. if 'datetime.datetime' in str(type(online_dict[key])):
  614. online_dict[key] = online_dict[key].strftime("%Y-%m-%d")
  615. else:
  616. pass
  617. L.append(online_dict)
  618. msg['data'] = L
  619. return JsonResponse(msg)

五,相关作品展示

基于Java开发、Python开发、PHP开发、C#开发等相关语言开发的实战项目

基于Nodejs、Vue等前端技术开发的前端实战项目

基于微信小程序和安卓APP应用开发的相关作品

基于51单片机等嵌入式物联网开发应用

基于各类算法实现的AI智能应用

基于大数据实现的各类数据管理和推荐系统

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/1021751
推荐阅读
相关标签
  

闽ICP备14008679号