• 基于Python+Django的开药系统【源码+LW+PPT+部署讲解】


    作者主页:编程千纸鹤

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

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

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

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

    文末获取源码 

    项目编号:BS-Python-052

    一,环境介绍

    语言环境:Python3.8

    数据库:Mysql: mysql5.7

    WEB框架:Django

    开发工具:IDEA或PyCharm

    二,项目简介

    互联网的兴起从本质上改变了整个社会对信息的管理方式,国内各大市场从上个世纪90年代互联网兴起之时,就产生了通过网络进行系统管理的想法。但是由于在互联网上的信誉难以认证、网络的法规政策不健全等一系列的原因,限制了网上信息管理发展的步伐。进入21世纪以后,随着整个社会的发展、进步,制约网上交流的各个瓶颈问题逐一被击破,比如QQ、微信等各大平台也纷纷的加入到洪潮之中。

    开药系统是在的数据存储主要通过MySQL。用户在使用应用时产生的数据通过Python语言传递给数据库。通过此方式促进开药信息管理和数据传输效率,提供一个内容丰富、功能多样、易于操作的平台。述了数据库的设计,系统的详细设计部分主要论述了几个主要模块的详细设计过程。

    管理员功能用例:

    医生功能用例:

    系统整体E-R图:

    三,系统展示

    四,核心代码展示

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

    五,相关作品展示

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

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

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

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

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

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

     

     

  • 相关阅读:
    python:xml.etree.ElementTree 读 Freeplane.mm文件,生成测试案例.csv文件
    财神爷直播间 不露脸直播间搭建素材和教程
    【数据分享】2023年全国地级市点位数据(免费获取\shp格式\excel格式)
    Go with Protobuf
    目标检测算法——安全帽识别数据集(附下载链接)
    C. Add One--Divide by Zero 2021 and Codeforces Round #714 (Div. 2)
    Nautilus Chain上线主网,为DeFi和流支付的未来构建基础
    纯前端个人主页分享
    CarSim仿真快速入门(十八)-CarSim2021中的混合动力和纯电动系统
    java计算机毕业设计框架的电脑测评系统源码+数据库+lw文档+系统
  • 原文地址:https://blog.csdn.net/BS009/article/details/141086055