玖 玖 6 months ago
commit 60fda48c78

@ -0,0 +1,717 @@
#coding:utf-8
__author__ = "ila"
import base64, copy, logging, os, time, xlrd
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import gongsi
from util.codes import *
from util.auth import Auth
from util.common import Common
import util.message as mes
from django.db import connection
import random
from django.core.mail import send_mail
from alipay import AliPayConfig, AliPay
from django.conf import settings
from django.shortcuts import redirect
def gongsi_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = gongsi.createbyreq(gongsi, gongsi, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def gongsi_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = gongsi.getbyparams(gongsi, gongsi, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= gongsi.__sfsh__
except:
__sfsh__=None
if __sfsh__=='':
if datas[0].get('sfsh')=='':
msg['code']=other_code
msg['msg'] = "账号已锁定,请联系管理员审核!"
return JsonResponse(msg)
req_dict['id'] = datas[0].get('id')
return Auth.authenticate(Auth, gongsi, req_dict)
def gongsi_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def gongsi_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
columns= gongsi.getallcolumn( gongsi, gongsi)
try:
__loginUserColumn__= gongsi.__loginUserColumn__
except:
__loginUserColumn__=None
username=req_dict.get(list(req_dict.keys())[0])
if __loginUserColumn__:
username_str=__loginUserColumn__
else:
username_str=username
if 'mima' in columns:
password_str='mima'
else:
password_str='password'
init_pwd = '123456'
eval('''gongsi.objects.filter({}='{}').update({}='{}')'''.format(username_str,username,password_str,init_pwd))
return JsonResponse(msg)
def gongsi_session(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code,"msg": mes.normal_code, "data": {}}
req_dict={"id":request.session.get('params').get("id")}
msg['data'] = gongsi.getbyparams(gongsi, gongsi, req_dict)[0]
return JsonResponse(msg)
def gongsi_default(request):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code,"msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
req_dict.update({"isdefault":""})
data=gongsi.getbyparams(gongsi, gongsi, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def gongsi_page(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = request.session.get("req_dict")
#获取全部列名
columns= gongsi.getallcolumn( gongsi, gongsi)
#当前登录用户所在表
tablename = request.session.get("tablename")
#authColumn=list(__authTables__.keys())[0]
#authTable=__authTables__.get(authColumn)
# if authTable==tablename:
#params = request.session.get("params")
#req_dict[authColumn]=params.get(authColumn)
'''__authSeparate__此属性为真params添加userid后台只查询个人数据'''
try:
__authSeparate__=gongsi.__authSeparate__
except:
__authSeparate__=None
if __authSeparate__=="":
tablename=request.session.get("tablename")
if tablename!="users" and 'userid' in columns:
try:
req_dict['userid']=request.session.get("params").get("id")
except:
pass
#当项目属性hasMessage为”是”生成系统自动生成留言板的表messages同时该表的表属性hasMessage也被设置为”是”,字段包括userid用户idusername(用户名)content留言内容reply回复
#接口page需要区分权限普通用户查看自己的留言和回复记录管理员查看所有的留言和回复记录
try:
__hasMessage__=gongsi.__hasMessage__
except:
__hasMessage__=None
if __hasMessage__=="":
tablename=request.session.get("tablename")
if tablename!="users":
req_dict["userid"]=request.session.get("params").get("id")
# 判断当前表的表属性isAdmin,为真则是管理员表
# 当表属性isAdmin=”是”,刷出来的用户表也是管理员即page和list可以查看所有人的考试记录(同时应用于其他表)
__isAdmin__ = None
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__==tablename:
try:
__isAdmin__ = m.__isAdmin__
except:
__isAdmin__ = None
break
# 当前表也是有管理员权限的表
if __isAdmin__ == "":
if req_dict.get("userid"):
del req_dict["userid"]
else:
#非管理员权限的表,判断当前表字段名是否有userid
if tablename!="users" and 'gongsi'[:7]!='discuss'and "userid" in gongsi.getallcolumn(gongsi,gongsi):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=gongsi.__authTables__
except:
__authTables__=None
if __authTables__!=None and __authTables__!={}:
try:
del req_dict['userid']
except:
pass
for authColumn,authTable in __authTables__.items():
if authTable==tablename:
params = request.session.get("params")
req_dict[authColumn]=params.get(authColumn)
break
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] =gongsi.page(gongsi, gongsi, req_dict)
return JsonResponse(msg)
def gongsi_autoSort(request):
'''
智能推荐功能(表属性[intelRecom/],新增clicktime[前端不显示该字段]字段调用info/detail接口的时候更新按clicktime排序查询)
主要信息列表如商品列表新闻列表中使用显示最近点击的或最新添加的5条记录就行
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = request.session.get("req_dict")
if "clicknum" in gongsi.getallcolumn(gongsi,gongsi):
req_dict['sort']='clicknum'
else:
req_dict['sort']='clicktime'
req_dict['order']='desc'
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = gongsi.page(gongsi,gongsi, req_dict)
return JsonResponse(msg)
def gongsi_list(request):
'''
前台分页
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = request.session.get("req_dict")
#获取全部列名
columns= gongsi.getallcolumn( gongsi, gongsi)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=gongsi.__foreEndList__
except:
__foreEndList__=None
if __foreEndList__=="前要登":
tablename=request.session.get("tablename")
if tablename!="users" and 'userid' in columns:
try:
req_dict['userid']=request.session.get("params").get("id")
except:
pass
#forrEndListAuth
try:
__foreEndListAuth__=gongsi.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=gongsi.__authSeparate__
except:
__authSeparate__=None
if __foreEndListAuth__ =="" and __authSeparate__=="":
tablename=request.session.get("tablename")
if tablename!="users":
req_dict['userid']=request.session.get("params",{"id":0}).get("id")
tablename = request.session.get("tablename")
if tablename == "users" and req_dict.get("userid") != None:#判断是否存在userid列名
del req_dict["userid"]
else:
__isAdmin__ = None
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__==tablename:
try:
__isAdmin__ = m.__isAdmin__
except:
__isAdmin__ = None
break
if __isAdmin__ == "":
if req_dict.get("userid"):
del req_dict["userid"]
else:
#非管理员权限的表,判断当前表字段名是否有userid
if "userid" in columns:
try:
# 本接口可以匿名访问,所以try判断是否为匿名
req_dict['userid']=request.session.get("params").get("id")
except:
pass
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=gongsi.__authTables__
except:
__authTables__=None
if __authTables__!=None and __authTables__!={} and __foreEndListAuth__=="":
try:
del req_dict['userid']
except:
pass
for authColumn,authTable in __authTables__.items():
if authTable==tablename:
params = request.session.get("params")
req_dict[authColumn]=params.get(authColumn)
break
if gongsi.__tablename__[:7]=="discuss":
try:
del req_dict['userid']
except:
pass
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = gongsi.page(gongsi, gongsi, req_dict)
return JsonResponse(msg)
def gongsi_save(request):
'''
后台新增
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
tablename=request.session.get("tablename")
__isAdmin__ = None
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__==tablename:
try:
__isAdmin__ = m.__isAdmin__
except:
__isAdmin__ = None
break
#获取全部列名
columns= gongsi.getallcolumn( gongsi, gongsi)
if tablename!='users' and req_dict.get("userid")!=None and 'userid' in columns and __isAdmin__!='':
params=request.session.get("params")
req_dict['userid']=params.get('id')
error= gongsi.createbyreq(gongsi,gongsi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gongsi_add(request):
'''
前台新增
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
#获取全部列名
columns= gongsi.getallcolumn( gongsi, gongsi)
try:
__authSeparate__=gongsi.__authSeparate__
except:
__authSeparate__=None
if __authSeparate__=="":
tablename=request.session.get("tablename")
if tablename!="users" and 'userid' in columns:
try:
req_dict['userid']=request.session.get("params").get("id")
except:
pass
try:
__foreEndListAuth__=gongsi.__foreEndListAuth__
except:
__foreEndListAuth__=None
if __foreEndListAuth__ and __foreEndListAuth__!="":
tablename=request.session.get("tablename")
if tablename!="users":
req_dict['userid']=request.session.get("params").get("id")
error= gongsi.createbyreq(gongsi,gongsi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gongsi_thumbsup(request,id_):
'''
点赞表属性thumbsUp[/]刷表新增thumbsupnum赞和crazilynum踩字段
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
id_=int(id_)
type_=int(req_dict.get("type",0))
rets=gongsi.getbyid(gongsi,gongsi,id_)
update_dict={
"id":id_,
}
if type_==1:#赞
update_dict["thumbsupnum"]=int(rets[0].get('thumbsupnum'))+1
elif type_==2:#踩
update_dict["crazilynum"]=int(rets[0].get('crazilynum'))+1
error = gongsi.updatebyparams(gongsi,gongsi, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gongsi_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = gongsi.getbyid(gongsi,gongsi, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= gongsi.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in gongsi.getallcolumn(gongsi,gongsi):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=gongsi.updatebyparams(gongsi,gongsi,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def gongsi_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =gongsi.getbyid(gongsi,gongsi, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= gongsi.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in gongsi.getallcolumn(gongsi,gongsi):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=gongsi.updatebyparams(gongsi,gongsi,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def gongsi_update(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
if req_dict.get("mima") and req_dict.get("password"):
if "mima" not in gongsi.getallcolumn(gongsi,gongsi) :
del req_dict["mima"]
if "password" not in gongsi.getallcolumn(gongsi,gongsi) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = gongsi.updatebyparams(gongsi, gongsi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gongsi_delete(request):
'''
批量删除
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
error=gongsi.deletes(gongsi,
gongsi,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gongsi_vote(request,id_):
'''
浏览点击次数表属性[browseClick:/]点击字段clicknum调用info/detail接口的时候后端自动+1投票功能表属性[vote:/]投票字段votenum,调用vote接口后端votenum+1
统计商品或新闻的点击次数提供新闻的投票功能
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
data= gongsi.getbyid(gongsi, gongsi, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=gongsi.updatebyparams(gongsi,gongsi,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gongsi_importExcel(request):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
excel_file = request.FILES.get("file", "")
file_type = excel_file.name.split('.')[1]
if file_type in ['xlsx', 'xls']:
data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())
table = data.sheets()[0]
rows = table.nrows
try:
for row in range(1, rows):
row_values = table.row_values(row)
req_dict = {}
gongsi.createbyreq(gongsi, gongsi, req_dict)
except:
pass
else:
msg.code = 500
msg.msg = "文件类型错误"
return JsonResponse(msg)
def gongsi_sendemail(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
code = random.sample(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 4)
to = []
to.append(req_dict['email'])
send_mail('用户注册', '您的注册验证码是【'+''.join(code)+'】,请不要把验证码泄漏给其他人,如非本人请勿操作。', 'yclw9@qq.com', to, fail_silently = False)
cursor = connection.cursor()
cursor.execute("insert into emailregistercode(email,role,code) values('"+req_dict['email']+"','用户','"+''.join(code)+"')")
msg = {
"msg": "发送成功",
"code": 0
}
return JsonResponse(msg)
def gongsi_autoSort2(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
cursor = connection.cursor()
leixing = set()
try:
cursor.execute("select goodtype from orders where userid = %d"%(request.session.get("params").get("id"))+" and tablename = 'gongsi' order by addtime desc")
rows = cursor.fetchall()
for row in rows:
for item in row:
leixing.add(item)
except:
leixing = set()
L = []
cursor.execute("select * from gongsi where $intelRecomColumn in ('%s"%("','").join(leixing)+"') union all select * from gongsi where $intelRecomColumn not in('%s"%("','").join(leixing)+"')")
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
return JsonResponse({"code": 0, "msg": '', "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":5,"list": L[0:6]}})
def gongsi_value(request, xColumnName, yColumnName, timeStatType):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
sql = ''
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM gongsi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d')".format(xColumnName, yColumnName, where, '%Y-%m-%d')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM gongsi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m')".format(xColumnName, yColumnName, where, '%Y-%m')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM gongsi {2} GROUP BY DATE_FORMAT({0}, '%Y')".format(xColumnName, yColumnName, where, '%Y')
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def gongsi_o_value(request, xColumnName, yColumnName):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
sql = "SELECT {0}, sum({1}) AS total FROM gongsi {2} GROUP BY {0}".format(xColumnName, yColumnName, where)
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def gongsi_alipay(request):
if request.method in ["POST", "GET"]:
alipay = AliPay(
appid=settings.ALIPAY_APP_ID,
app_notify_url=None,
app_private_key_string=settings.APP_PRIVATE_KEY_STRING,
alipay_public_key_string=settings.ALIPAY_PUBLIC_KEY_STRING,
sign_type=settings.ALIPAY_SIGN_TYPE,
debug=True,
config=AliPayConfig(timeout=15)
)
req_dict = request.session.get("req_dict")
order_string = alipay.api_alipay_trade_page_pay(
out_trade_no=req_dict['tradeno'],
total_amount=req_dict['totalamount'],
subject=req_dict['subject'],
return_url='http://localhost:8080/django3qu6u/gongsi/notify',
#notify_url=''
)
pay_url = 'https://openapi.alipaydev.com/gateway.do?' + order_string
pay_url = '<form name="punchout_form" method="post" action="{0}"><input type="hidden" name="biz_content" ><input type="submit" value="立即支付" style="display: none"></form>'.format(pay_url)
return JsonResponse({'code': 0, "data": pay_url})
def gongsi_notify(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
out_trade_no = req_dict['out_trade_no']
cursor = connection.cursor()
return redirect('http://localhost:8080/django3qu6u/admin/dist/index.html#/gongsi')

@ -0,0 +1,725 @@
#coding:utf-8
__author__ = "ila"
import base64, copy, logging, os, time, xlrd
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import gongsixinxi
from util.codes import *
from util.auth import Auth
from util.common import Common
import util.message as mes
from django.db import connection
import random
from django.core.mail import send_mail
from alipay import AliPayConfig, AliPay
from django.conf import settings
from django.shortcuts import redirect
def gongsixinxi_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = gongsixinxi.createbyreq(gongsixinxi, gongsixinxi, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def gongsixinxi_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = gongsixinxi.getbyparams(gongsixinxi, gongsixinxi, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= gongsixinxi.__sfsh__
except:
__sfsh__=None
if __sfsh__=='':
if datas[0].get('sfsh')=='':
msg['code']=other_code
msg['msg'] = "账号已锁定,请联系管理员审核!"
return JsonResponse(msg)
req_dict['id'] = datas[0].get('id')
return Auth.authenticate(Auth, gongsixinxi, req_dict)
def gongsixinxi_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def gongsixinxi_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
columns= gongsixinxi.getallcolumn( gongsixinxi, gongsixinxi)
try:
__loginUserColumn__= gongsixinxi.__loginUserColumn__
except:
__loginUserColumn__=None
username=req_dict.get(list(req_dict.keys())[0])
if __loginUserColumn__:
username_str=__loginUserColumn__
else:
username_str=username
if 'mima' in columns:
password_str='mima'
else:
password_str='password'
init_pwd = '123456'
eval('''gongsixinxi.objects.filter({}='{}').update({}='{}')'''.format(username_str,username,password_str,init_pwd))
return JsonResponse(msg)
def gongsixinxi_session(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code,"msg": mes.normal_code, "data": {}}
req_dict={"id":request.session.get('params').get("id")}
msg['data'] = gongsixinxi.getbyparams(gongsixinxi, gongsixinxi, req_dict)[0]
return JsonResponse(msg)
def gongsixinxi_default(request):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code,"msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
req_dict.update({"isdefault":""})
data=gongsixinxi.getbyparams(gongsixinxi, gongsixinxi, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def gongsixinxi_page(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = request.session.get("req_dict")
#获取全部列名
columns= gongsixinxi.getallcolumn( gongsixinxi, gongsixinxi)
#当前登录用户所在表
tablename = request.session.get("tablename")
#authColumn=list(__authTables__.keys())[0]
#authTable=__authTables__.get(authColumn)
# if authTable==tablename:
#params = request.session.get("params")
#req_dict[authColumn]=params.get(authColumn)
'''__authSeparate__此属性为真params添加userid后台只查询个人数据'''
try:
__authSeparate__=gongsixinxi.__authSeparate__
except:
__authSeparate__=None
if __authSeparate__=="":
tablename=request.session.get("tablename")
if tablename!="users" and 'userid' in columns:
try:
req_dict['userid']=request.session.get("params").get("id")
except:
pass
#当项目属性hasMessage为”是”生成系统自动生成留言板的表messages同时该表的表属性hasMessage也被设置为”是”,字段包括userid用户idusername(用户名)content留言内容reply回复
#接口page需要区分权限普通用户查看自己的留言和回复记录管理员查看所有的留言和回复记录
try:
__hasMessage__=gongsixinxi.__hasMessage__
except:
__hasMessage__=None
if __hasMessage__=="":
tablename=request.session.get("tablename")
if tablename!="users":
req_dict["userid"]=request.session.get("params").get("id")
# 判断当前表的表属性isAdmin,为真则是管理员表
# 当表属性isAdmin=”是”,刷出来的用户表也是管理员即page和list可以查看所有人的考试记录(同时应用于其他表)
__isAdmin__ = None
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__==tablename:
try:
__isAdmin__ = m.__isAdmin__
except:
__isAdmin__ = None
break
# 当前表也是有管理员权限的表
if __isAdmin__ == "":
if req_dict.get("userid"):
del req_dict["userid"]
else:
#非管理员权限的表,判断当前表字段名是否有userid
if tablename!="users" and 'gongsixinxi'[:7]!='discuss'and "userid" in gongsixinxi.getallcolumn(gongsixinxi,gongsixinxi):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=gongsixinxi.__authTables__
except:
__authTables__=None
if __authTables__!=None and __authTables__!={}:
try:
del req_dict['userid']
except:
pass
for authColumn,authTable in __authTables__.items():
if authTable==tablename:
params = request.session.get("params")
req_dict[authColumn]=params.get(authColumn)
break
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] =gongsixinxi.page(gongsixinxi, gongsixinxi, req_dict)
return JsonResponse(msg)
def gongsixinxi_autoSort(request):
'''
智能推荐功能(表属性[intelRecom/],新增clicktime[前端不显示该字段]字段调用info/detail接口的时候更新按clicktime排序查询)
主要信息列表如商品列表新闻列表中使用显示最近点击的或最新添加的5条记录就行
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = request.session.get("req_dict")
if "clicknum" in gongsixinxi.getallcolumn(gongsixinxi,gongsixinxi):
req_dict['sort']='clicknum'
else:
req_dict['sort']='clicktime'
req_dict['order']='desc'
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = gongsixinxi.page(gongsixinxi,gongsixinxi, req_dict)
return JsonResponse(msg)
def gongsixinxi_list(request):
'''
前台分页
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = request.session.get("req_dict")
#获取全部列名
columns= gongsixinxi.getallcolumn( gongsixinxi, gongsixinxi)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=gongsixinxi.__foreEndList__
except:
__foreEndList__=None
if __foreEndList__=="前要登":
tablename=request.session.get("tablename")
if tablename!="users" and 'userid' in columns:
try:
req_dict['userid']=request.session.get("params").get("id")
except:
pass
#forrEndListAuth
try:
__foreEndListAuth__=gongsixinxi.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=gongsixinxi.__authSeparate__
except:
__authSeparate__=None
if __foreEndListAuth__ =="" and __authSeparate__=="":
tablename=request.session.get("tablename")
if tablename!="users":
req_dict['userid']=request.session.get("params",{"id":0}).get("id")
tablename = request.session.get("tablename")
if tablename == "users" and req_dict.get("userid") != None:#判断是否存在userid列名
del req_dict["userid"]
else:
__isAdmin__ = None
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__==tablename:
try:
__isAdmin__ = m.__isAdmin__
except:
__isAdmin__ = None
break
if __isAdmin__ == "":
if req_dict.get("userid"):
del req_dict["userid"]
else:
#非管理员权限的表,判断当前表字段名是否有userid
if "userid" in columns:
try:
# 本接口可以匿名访问,所以try判断是否为匿名
req_dict['userid']=request.session.get("params").get("id")
except:
pass
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=gongsixinxi.__authTables__
except:
__authTables__=None
if __authTables__!=None and __authTables__!={} and __foreEndListAuth__=="":
try:
del req_dict['userid']
except:
pass
for authColumn,authTable in __authTables__.items():
if authTable==tablename:
params = request.session.get("params")
req_dict[authColumn]=params.get(authColumn)
break
if gongsixinxi.__tablename__[:7]=="discuss":
try:
del req_dict['userid']
except:
pass
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = gongsixinxi.page(gongsixinxi, gongsixinxi, req_dict)
return JsonResponse(msg)
def gongsixinxi_save(request):
'''
后台新增
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
tablename=request.session.get("tablename")
__isAdmin__ = None
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__==tablename:
try:
__isAdmin__ = m.__isAdmin__
except:
__isAdmin__ = None
break
#获取全部列名
columns= gongsixinxi.getallcolumn( gongsixinxi, gongsixinxi)
if tablename!='users' and req_dict.get("userid")!=None and 'userid' in columns and __isAdmin__!='':
params=request.session.get("params")
req_dict['userid']=params.get('id')
error= gongsixinxi.createbyreq(gongsixinxi,gongsixinxi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gongsixinxi_add(request):
'''
前台新增
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
#获取全部列名
columns= gongsixinxi.getallcolumn( gongsixinxi, gongsixinxi)
try:
__authSeparate__=gongsixinxi.__authSeparate__
except:
__authSeparate__=None
if __authSeparate__=="":
tablename=request.session.get("tablename")
if tablename!="users" and 'userid' in columns:
try:
req_dict['userid']=request.session.get("params").get("id")
except:
pass
try:
__foreEndListAuth__=gongsixinxi.__foreEndListAuth__
except:
__foreEndListAuth__=None
if __foreEndListAuth__ and __foreEndListAuth__!="":
tablename=request.session.get("tablename")
if tablename!="users":
req_dict['userid']=request.session.get("params").get("id")
error= gongsixinxi.createbyreq(gongsixinxi,gongsixinxi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gongsixinxi_thumbsup(request,id_):
'''
点赞表属性thumbsUp[/]刷表新增thumbsupnum赞和crazilynum踩字段
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
id_=int(id_)
type_=int(req_dict.get("type",0))
rets=gongsixinxi.getbyid(gongsixinxi,gongsixinxi,id_)
update_dict={
"id":id_,
}
if type_==1:#赞
update_dict["thumbsupnum"]=int(rets[0].get('thumbsupnum'))+1
elif type_==2:#踩
update_dict["crazilynum"]=int(rets[0].get('crazilynum'))+1
error = gongsixinxi.updatebyparams(gongsixinxi,gongsixinxi, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gongsixinxi_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = gongsixinxi.getbyid(gongsixinxi,gongsixinxi, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= gongsixinxi.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in gongsixinxi.getallcolumn(gongsixinxi,gongsixinxi):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=gongsixinxi.updatebyparams(gongsixinxi,gongsixinxi,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def gongsixinxi_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =gongsixinxi.getbyid(gongsixinxi,gongsixinxi, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= gongsixinxi.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in gongsixinxi.getallcolumn(gongsixinxi,gongsixinxi):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=gongsixinxi.updatebyparams(gongsixinxi,gongsixinxi,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def gongsixinxi_update(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
if req_dict.get("mima") and req_dict.get("password"):
if "mima" not in gongsixinxi.getallcolumn(gongsixinxi,gongsixinxi) :
del req_dict["mima"]
if "password" not in gongsixinxi.getallcolumn(gongsixinxi,gongsixinxi) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = gongsixinxi.updatebyparams(gongsixinxi, gongsixinxi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gongsixinxi_delete(request):
'''
批量删除
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
error=gongsixinxi.deletes(gongsixinxi,
gongsixinxi,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gongsixinxi_vote(request,id_):
'''
浏览点击次数表属性[browseClick:/]点击字段clicknum调用info/detail接口的时候后端自动+1投票功能表属性[vote:/]投票字段votenum,调用vote接口后端votenum+1
统计商品或新闻的点击次数提供新闻的投票功能
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
data= gongsixinxi.getbyid(gongsixinxi, gongsixinxi, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=gongsixinxi.updatebyparams(gongsixinxi,gongsixinxi,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gongsixinxi_importExcel(request):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
excel_file = request.FILES.get("file", "")
file_type = excel_file.name.split('.')[1]
if file_type in ['xlsx', 'xls']:
data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())
table = data.sheets()[0]
rows = table.nrows
try:
for row in range(1, rows):
row_values = table.row_values(row)
req_dict = {}
gongsixinxi.createbyreq(gongsixinxi, gongsixinxi, req_dict)
except:
pass
else:
msg.code = 500
msg.msg = "文件类型错误"
return JsonResponse(msg)
def gongsixinxi_sendemail(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
code = random.sample(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 4)
to = []
to.append(req_dict['email'])
send_mail('用户注册', '您的注册验证码是【'+''.join(code)+'】,请不要把验证码泄漏给其他人,如非本人请勿操作。', 'yclw9@qq.com', to, fail_silently = False)
cursor = connection.cursor()
cursor.execute("insert into emailregistercode(email,role,code) values('"+req_dict['email']+"','用户','"+''.join(code)+"')")
msg = {
"msg": "发送成功",
"code": 0
}
return JsonResponse(msg)
def gongsixinxi_autoSort2(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
cursor = connection.cursor()
leixing = set()
try:
cursor.execute("select goodtype from orders where userid = %d"%(request.session.get("params").get("id"))+" and tablename = 'gongsixinxi' order by addtime desc")
rows = cursor.fetchall()
for row in rows:
for item in row:
leixing.add(item)
except:
leixing = set()
L = []
cursor.execute("select * from gongsixinxi where $intelRecomColumn in ('%s"%("','").join(leixing)+"') union all select * from gongsixinxi where $intelRecomColumn not in('%s"%("','").join(leixing)+"')")
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
return JsonResponse({"code": 0, "msg": '', "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":5,"list": L[0:6]}})
def gongsixinxi_value(request, xColumnName, yColumnName, timeStatType):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and gongsizhanghao ='{0}' ".format(decode_str['params']['gongsizhanghao'])
sql = ''
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM gongsixinxi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d')".format(xColumnName, yColumnName, where, '%Y-%m-%d')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM gongsixinxi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m')".format(xColumnName, yColumnName, where, '%Y-%m')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM gongsixinxi {2} GROUP BY DATE_FORMAT({0}, '%Y')".format(xColumnName, yColumnName, where, '%Y')
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def gongsixinxi_o_value(request, xColumnName, yColumnName):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and gongsizhanghao ='{0}' ".format(decode_str['params']['gongsizhanghao'])
sql = "SELECT {0}, sum({1}) AS total FROM gongsixinxi {2} GROUP BY {0}".format(xColumnName, yColumnName, where)
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def gongsixinxi_alipay(request):
if request.method in ["POST", "GET"]:
alipay = AliPay(
appid=settings.ALIPAY_APP_ID,
app_notify_url=None,
app_private_key_string=settings.APP_PRIVATE_KEY_STRING,
alipay_public_key_string=settings.ALIPAY_PUBLIC_KEY_STRING,
sign_type=settings.ALIPAY_SIGN_TYPE,
debug=True,
config=AliPayConfig(timeout=15)
)
req_dict = request.session.get("req_dict")
order_string = alipay.api_alipay_trade_page_pay(
out_trade_no=req_dict['tradeno'],
total_amount=req_dict['totalamount'],
subject=req_dict['subject'],
return_url='http://localhost:8080/django3qu6u/gongsixinxi/notify',
#notify_url=''
)
pay_url = 'https://openapi.alipaydev.com/gateway.do?' + order_string
pay_url = '<form name="punchout_form" method="post" action="{0}"><input type="hidden" name="biz_content" ><input type="submit" value="立即支付" style="display: none"></form>'.format(pay_url)
return JsonResponse({'code': 0, "data": pay_url})
def gongsixinxi_notify(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
out_trade_no = req_dict['out_trade_no']
cursor = connection.cursor()
return redirect('http://localhost:8080/django3qu6u/admin/dist/index.html#/gongsixinxi')

@ -0,0 +1,717 @@
#coding:utf-8
__author__ = "ila"
import base64, copy, logging, os, time, xlrd
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import qiuzhizhe
from util.codes import *
from util.auth import Auth
from util.common import Common
import util.message as mes
from django.db import connection
import random
from django.core.mail import send_mail
from alipay import AliPayConfig, AliPay
from django.conf import settings
from django.shortcuts import redirect
def qiuzhizhe_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = qiuzhizhe.createbyreq(qiuzhizhe, qiuzhizhe, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def qiuzhizhe_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = qiuzhizhe.getbyparams(qiuzhizhe, qiuzhizhe, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= qiuzhizhe.__sfsh__
except:
__sfsh__=None
if __sfsh__=='':
if datas[0].get('sfsh')=='':
msg['code']=other_code
msg['msg'] = "账号已锁定,请联系管理员审核!"
return JsonResponse(msg)
req_dict['id'] = datas[0].get('id')
return Auth.authenticate(Auth, qiuzhizhe, req_dict)
def qiuzhizhe_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def qiuzhizhe_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
columns= qiuzhizhe.getallcolumn( qiuzhizhe, qiuzhizhe)
try:
__loginUserColumn__= qiuzhizhe.__loginUserColumn__
except:
__loginUserColumn__=None
username=req_dict.get(list(req_dict.keys())[0])
if __loginUserColumn__:
username_str=__loginUserColumn__
else:
username_str=username
if 'mima' in columns:
password_str='mima'
else:
password_str='password'
init_pwd = '123456'
eval('''qiuzhizhe.objects.filter({}='{}').update({}='{}')'''.format(username_str,username,password_str,init_pwd))
return JsonResponse(msg)
def qiuzhizhe_session(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code,"msg": mes.normal_code, "data": {}}
req_dict={"id":request.session.get('params').get("id")}
msg['data'] = qiuzhizhe.getbyparams(qiuzhizhe, qiuzhizhe, req_dict)[0]
return JsonResponse(msg)
def qiuzhizhe_default(request):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code,"msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
req_dict.update({"isdefault":""})
data=qiuzhizhe.getbyparams(qiuzhizhe, qiuzhizhe, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def qiuzhizhe_page(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = request.session.get("req_dict")
#获取全部列名
columns= qiuzhizhe.getallcolumn( qiuzhizhe, qiuzhizhe)
#当前登录用户所在表
tablename = request.session.get("tablename")
#authColumn=list(__authTables__.keys())[0]
#authTable=__authTables__.get(authColumn)
# if authTable==tablename:
#params = request.session.get("params")
#req_dict[authColumn]=params.get(authColumn)
'''__authSeparate__此属性为真params添加userid后台只查询个人数据'''
try:
__authSeparate__=qiuzhizhe.__authSeparate__
except:
__authSeparate__=None
if __authSeparate__=="":
tablename=request.session.get("tablename")
if tablename!="users" and 'userid' in columns:
try:
req_dict['userid']=request.session.get("params").get("id")
except:
pass
#当项目属性hasMessage为”是”生成系统自动生成留言板的表messages同时该表的表属性hasMessage也被设置为”是”,字段包括userid用户idusername(用户名)content留言内容reply回复
#接口page需要区分权限普通用户查看自己的留言和回复记录管理员查看所有的留言和回复记录
try:
__hasMessage__=qiuzhizhe.__hasMessage__
except:
__hasMessage__=None
if __hasMessage__=="":
tablename=request.session.get("tablename")
if tablename!="users":
req_dict["userid"]=request.session.get("params").get("id")
# 判断当前表的表属性isAdmin,为真则是管理员表
# 当表属性isAdmin=”是”,刷出来的用户表也是管理员即page和list可以查看所有人的考试记录(同时应用于其他表)
__isAdmin__ = None
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__==tablename:
try:
__isAdmin__ = m.__isAdmin__
except:
__isAdmin__ = None
break
# 当前表也是有管理员权限的表
if __isAdmin__ == "":
if req_dict.get("userid"):
del req_dict["userid"]
else:
#非管理员权限的表,判断当前表字段名是否有userid
if tablename!="users" and 'qiuzhizhe'[:7]!='discuss'and "userid" in qiuzhizhe.getallcolumn(qiuzhizhe,qiuzhizhe):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=qiuzhizhe.__authTables__
except:
__authTables__=None
if __authTables__!=None and __authTables__!={}:
try:
del req_dict['userid']
except:
pass
for authColumn,authTable in __authTables__.items():
if authTable==tablename:
params = request.session.get("params")
req_dict[authColumn]=params.get(authColumn)
break
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] =qiuzhizhe.page(qiuzhizhe, qiuzhizhe, req_dict)
return JsonResponse(msg)
def qiuzhizhe_autoSort(request):
'''
智能推荐功能(表属性[intelRecom/],新增clicktime[前端不显示该字段]字段调用info/detail接口的时候更新按clicktime排序查询)
主要信息列表如商品列表新闻列表中使用显示最近点击的或最新添加的5条记录就行
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = request.session.get("req_dict")
if "clicknum" in qiuzhizhe.getallcolumn(qiuzhizhe,qiuzhizhe):
req_dict['sort']='clicknum'
else:
req_dict['sort']='clicktime'
req_dict['order']='desc'
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = qiuzhizhe.page(qiuzhizhe,qiuzhizhe, req_dict)
return JsonResponse(msg)
def qiuzhizhe_list(request):
'''
前台分页
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = request.session.get("req_dict")
#获取全部列名
columns= qiuzhizhe.getallcolumn( qiuzhizhe, qiuzhizhe)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=qiuzhizhe.__foreEndList__
except:
__foreEndList__=None
if __foreEndList__=="前要登":
tablename=request.session.get("tablename")
if tablename!="users" and 'userid' in columns:
try:
req_dict['userid']=request.session.get("params").get("id")
except:
pass
#forrEndListAuth
try:
__foreEndListAuth__=qiuzhizhe.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=qiuzhizhe.__authSeparate__
except:
__authSeparate__=None
if __foreEndListAuth__ =="" and __authSeparate__=="":
tablename=request.session.get("tablename")
if tablename!="users":
req_dict['userid']=request.session.get("params",{"id":0}).get("id")
tablename = request.session.get("tablename")
if tablename == "users" and req_dict.get("userid") != None:#判断是否存在userid列名
del req_dict["userid"]
else:
__isAdmin__ = None
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__==tablename:
try:
__isAdmin__ = m.__isAdmin__
except:
__isAdmin__ = None
break
if __isAdmin__ == "":
if req_dict.get("userid"):
del req_dict["userid"]
else:
#非管理员权限的表,判断当前表字段名是否有userid
if "userid" in columns:
try:
# 本接口可以匿名访问,所以try判断是否为匿名
req_dict['userid']=request.session.get("params").get("id")
except:
pass
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=qiuzhizhe.__authTables__
except:
__authTables__=None
if __authTables__!=None and __authTables__!={} and __foreEndListAuth__=="":
try:
del req_dict['userid']
except:
pass
for authColumn,authTable in __authTables__.items():
if authTable==tablename:
params = request.session.get("params")
req_dict[authColumn]=params.get(authColumn)
break
if qiuzhizhe.__tablename__[:7]=="discuss":
try:
del req_dict['userid']
except:
pass
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = qiuzhizhe.page(qiuzhizhe, qiuzhizhe, req_dict)
return JsonResponse(msg)
def qiuzhizhe_save(request):
'''
后台新增
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
tablename=request.session.get("tablename")
__isAdmin__ = None
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__==tablename:
try:
__isAdmin__ = m.__isAdmin__
except:
__isAdmin__ = None
break
#获取全部列名
columns= qiuzhizhe.getallcolumn( qiuzhizhe, qiuzhizhe)
if tablename!='users' and req_dict.get("userid")!=None and 'userid' in columns and __isAdmin__!='':
params=request.session.get("params")
req_dict['userid']=params.get('id')
error= qiuzhizhe.createbyreq(qiuzhizhe,qiuzhizhe, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def qiuzhizhe_add(request):
'''
前台新增
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
#获取全部列名
columns= qiuzhizhe.getallcolumn( qiuzhizhe, qiuzhizhe)
try:
__authSeparate__=qiuzhizhe.__authSeparate__
except:
__authSeparate__=None
if __authSeparate__=="":
tablename=request.session.get("tablename")
if tablename!="users" and 'userid' in columns:
try:
req_dict['userid']=request.session.get("params").get("id")
except:
pass
try:
__foreEndListAuth__=qiuzhizhe.__foreEndListAuth__
except:
__foreEndListAuth__=None
if __foreEndListAuth__ and __foreEndListAuth__!="":
tablename=request.session.get("tablename")
if tablename!="users":
req_dict['userid']=request.session.get("params").get("id")
error= qiuzhizhe.createbyreq(qiuzhizhe,qiuzhizhe, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def qiuzhizhe_thumbsup(request,id_):
'''
点赞表属性thumbsUp[/]刷表新增thumbsupnum赞和crazilynum踩字段
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
id_=int(id_)
type_=int(req_dict.get("type",0))
rets=qiuzhizhe.getbyid(qiuzhizhe,qiuzhizhe,id_)
update_dict={
"id":id_,
}
if type_==1:#赞
update_dict["thumbsupnum"]=int(rets[0].get('thumbsupnum'))+1
elif type_==2:#踩
update_dict["crazilynum"]=int(rets[0].get('crazilynum'))+1
error = qiuzhizhe.updatebyparams(qiuzhizhe,qiuzhizhe, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def qiuzhizhe_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = qiuzhizhe.getbyid(qiuzhizhe,qiuzhizhe, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= qiuzhizhe.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in qiuzhizhe.getallcolumn(qiuzhizhe,qiuzhizhe):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=qiuzhizhe.updatebyparams(qiuzhizhe,qiuzhizhe,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def qiuzhizhe_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =qiuzhizhe.getbyid(qiuzhizhe,qiuzhizhe, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= qiuzhizhe.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in qiuzhizhe.getallcolumn(qiuzhizhe,qiuzhizhe):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=qiuzhizhe.updatebyparams(qiuzhizhe,qiuzhizhe,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def qiuzhizhe_update(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
if req_dict.get("mima") and req_dict.get("password"):
if "mima" not in qiuzhizhe.getallcolumn(qiuzhizhe,qiuzhizhe) :
del req_dict["mima"]
if "password" not in qiuzhizhe.getallcolumn(qiuzhizhe,qiuzhizhe) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = qiuzhizhe.updatebyparams(qiuzhizhe, qiuzhizhe, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def qiuzhizhe_delete(request):
'''
批量删除
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
error=qiuzhizhe.deletes(qiuzhizhe,
qiuzhizhe,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def qiuzhizhe_vote(request,id_):
'''
浏览点击次数表属性[browseClick:/]点击字段clicknum调用info/detail接口的时候后端自动+1投票功能表属性[vote:/]投票字段votenum,调用vote接口后端votenum+1
统计商品或新闻的点击次数提供新闻的投票功能
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
data= qiuzhizhe.getbyid(qiuzhizhe, qiuzhizhe, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=qiuzhizhe.updatebyparams(qiuzhizhe,qiuzhizhe,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def qiuzhizhe_importExcel(request):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
excel_file = request.FILES.get("file", "")
file_type = excel_file.name.split('.')[1]
if file_type in ['xlsx', 'xls']:
data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())
table = data.sheets()[0]
rows = table.nrows
try:
for row in range(1, rows):
row_values = table.row_values(row)
req_dict = {}
qiuzhizhe.createbyreq(qiuzhizhe, qiuzhizhe, req_dict)
except:
pass
else:
msg.code = 500
msg.msg = "文件类型错误"
return JsonResponse(msg)
def qiuzhizhe_sendemail(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
code = random.sample(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 4)
to = []
to.append(req_dict['email'])
send_mail('用户注册', '您的注册验证码是【'+''.join(code)+'】,请不要把验证码泄漏给其他人,如非本人请勿操作。', 'yclw9@qq.com', to, fail_silently = False)
cursor = connection.cursor()
cursor.execute("insert into emailregistercode(email,role,code) values('"+req_dict['email']+"','用户','"+''.join(code)+"')")
msg = {
"msg": "发送成功",
"code": 0
}
return JsonResponse(msg)
def qiuzhizhe_autoSort2(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
cursor = connection.cursor()
leixing = set()
try:
cursor.execute("select goodtype from orders where userid = %d"%(request.session.get("params").get("id"))+" and tablename = 'qiuzhizhe' order by addtime desc")
rows = cursor.fetchall()
for row in rows:
for item in row:
leixing.add(item)
except:
leixing = set()
L = []
cursor.execute("select * from qiuzhizhe where $intelRecomColumn in ('%s"%("','").join(leixing)+"') union all select * from qiuzhizhe where $intelRecomColumn not in('%s"%("','").join(leixing)+"')")
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
return JsonResponse({"code": 0, "msg": '', "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":5,"list": L[0:6]}})
def qiuzhizhe_value(request, xColumnName, yColumnName, timeStatType):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
sql = ''
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM qiuzhizhe {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d')".format(xColumnName, yColumnName, where, '%Y-%m-%d')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM qiuzhizhe {2} GROUP BY DATE_FORMAT({0}, '%Y-%m')".format(xColumnName, yColumnName, where, '%Y-%m')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM qiuzhizhe {2} GROUP BY DATE_FORMAT({0}, '%Y')".format(xColumnName, yColumnName, where, '%Y')
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def qiuzhizhe_o_value(request, xColumnName, yColumnName):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
sql = "SELECT {0}, sum({1}) AS total FROM qiuzhizhe {2} GROUP BY {0}".format(xColumnName, yColumnName, where)
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def qiuzhizhe_alipay(request):
if request.method in ["POST", "GET"]:
alipay = AliPay(
appid=settings.ALIPAY_APP_ID,
app_notify_url=None,
app_private_key_string=settings.APP_PRIVATE_KEY_STRING,
alipay_public_key_string=settings.ALIPAY_PUBLIC_KEY_STRING,
sign_type=settings.ALIPAY_SIGN_TYPE,
debug=True,
config=AliPayConfig(timeout=15)
)
req_dict = request.session.get("req_dict")
order_string = alipay.api_alipay_trade_page_pay(
out_trade_no=req_dict['tradeno'],
total_amount=req_dict['totalamount'],
subject=req_dict['subject'],
return_url='http://localhost:8080/django3qu6u/qiuzhizhe/notify',
#notify_url=''
)
pay_url = 'https://openapi.alipaydev.com/gateway.do?' + order_string
pay_url = '<form name="punchout_form" method="post" action="{0}"><input type="hidden" name="biz_content" ><input type="submit" value="立即支付" style="display: none"></form>'.format(pay_url)
return JsonResponse({'code': 0, "data": pay_url})
def qiuzhizhe_notify(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
out_trade_no = req_dict['out_trade_no']
cursor = connection.cursor()
return redirect('http://localhost:8080/django3qu6u/admin/dist/index.html#/qiuzhizhe')

@ -0,0 +1,663 @@
# coding:utf-8
__author__ = "ila"
import copy, re, time
import logging as log
from django.db import models
from django.forms.models import model_to_dict
from django.core.paginator import Paginator
from django.db.models import ProtectedError
from threadlocals.threadlocals import get_current_request
from django.db.models import Sum, Max, Min, Avg,Count
# model基础类
class BaseModel(models.Model):
class Meta:
abstract = True
def __Retrieve(self, model):
datas = model.objects.all()
return self.to_list(datas, datas)
def retrieve(self, model):
datas=self.__Retrieve(model, model)
for i in datas:
addtime=i.get("addtime")
if addtime:
addtime=str(addtime)[:19].replace("T"," ")
i["addtime"]=addtime
return datas
def __Page(self, model, params):
'''
刷表专用
http://ip:port/${schemaName}/${tableName}/page
page 当前页
pagesize 每页记录的长度
sort 排序字段,写死在这,如果刷表出错立马崩溃
order 升序默认asc或者降序desc
:param req_dict:
:return:
'''
start_time = end_time = None
between_str=''
paramss=copy.deepcopy(params)
for k,v in paramss.items():
if k[-5:]=='start':
start_time=copy.deepcopy(v)
between_str = '.filter({}__range= [start_time, end_time])'.format(copy.deepcopy(k[:-5]))
del params[k]
if k[-3:]=='end':
end_time=copy.deepcopy(v)
del params[k]
sort = copy.deepcopy(params.get('sort'))
if sort is None:
sort='id'
order = copy.deepcopy(params.get('order'))
page = copy.deepcopy(params.get('page')) if params.get('page') != None else 1
limit = copy.deepcopy(params.get('limit')) if params.get('limit') != None else 666
try:
del params['sort']
except:
pass
try:
del params['order']
except:
pass
try:
del params['page']
except:
pass
try:
del params['limit']
except:
pass
try:
__sort__ = model.__sort__
except:
__sort__ = None
# 手工实现模糊搜索orz
fuzzy_key, fuzzy_val,contain_str = None, None,''
print(params)
condition = {}
for k, v in params.items():
if "%" in str(v):
fuzzy_key = copy.deepcopy(k)
fuzzy_val = copy.deepcopy(v)
fuzzy_val = fuzzy_val.replace("%", "")
if fuzzy_key != None:
# del params[fuzzy_key]
contain_str +='.filter({}__icontains="{}")'.format(fuzzy_key,fuzzy_val)
else:
condition[copy.deepcopy(k)] = copy.deepcopy(v)
# if fuzzy_key != None:
# del params[fuzzy_key]
# contain_str='.filter({}__icontains="{}")'.format(fuzzy_key,fuzzy_val)
# __authSeparate__此属性为真params添加userid只查询个人数据
# try:
# __authSeparate__ = model.__authSeparate__
# except:
# __authSeparate__ = None
# #所有属性为"是"时才有效
# if __authSeparate__=='是':
# request = get_current_request()
# params["userid"] = request.session.get("params").get("id")
order_by_str=''
if sort != None or __sort__ != None:
if sort == None:
sort = __sort__
if order == 'desc':
order_by_str = '.order_by("-{}")'.format(sort)
else:
order_by_str = '.order_by("{}")'.format(sort)
datas = eval(
'''model.objects.filter(**condition){}{}{}.all()'''.format(contain_str, between_str, order_by_str))
p = Paginator(datas, int(limit))
try:
p2 = p.page(int(page))
datas = p2.object_list
except:
datas=[]
pages = p.num_pages
try:
newData = self.to_list(datas, datas)
except Exception as e:
print(Exception, ":", e)
newData = []
total = p.count
# __authTables__
if params.get("tablename") == 'users':
return newData, datas.page, pages, datas.total, datas.per_page
newDataa = []
if hasattr(self, "__authTables__") and self.__authTables__ != {}:
par_keys = params.keys()
authtables_keys = self.__authTables__.keys()
list1 = list(set(par_keys).intersection(set(authtables_keys)))
if len(list1) > 0:
for i in newData:
if i.get(list1[0]) == params.get(list1[0]):
newDataa.append(i)
else:
newDataa = newData
else:
newDataa = newData
filed_list=[]
from django.apps import apps
modelobj = apps.get_model('main', model.__tablename__)
for field in modelobj._meta.fields:
if 'DateTimeField' in type(field).__name__ :
filed_list.append(field.name)
for index,i in enumerate(newData):
for k,v in i.items():
if k in filed_list :
newData[index][k]=str(v)[:19]
return newDataa, page, pages, total, limit
def page(self, model, params):
return self.__Page(self, model, params)
def __GetByColumn(self, model, columnName):
# data1= model.query.options(load_only(column)).all()
datas = model.objects.values(columnName).all()
print(datas)
data_set = set()
for i in datas:
data_set.add(i.get(columnName))
return list(data_set)
def getbyColumn(self, model, columnName):
'''
获取某表的某个字段的内容列表去重
:param model:
:param column:
:return:
'''
return self.__GetByColumn(self, model, columnName)
def __CreateByReq(self, model, params):
'''
根据请求参数创建对应模型记录的公共方法
:param model:
:param params:
:return:
'''
if model.__tablename__ != 'users':
params['id'] = int(float(time.time()) * 1000)
column_list = []
for col in model._meta.fields:
if str(col.get_internal_type()).lower() == "bigintegerfield":
column_list.append(col.name)
for k, v in params.items():
if k in column_list:
try:
params[k] = int(v)
except:
params[k] = 0
column_list = []
for col in model._meta.fields:
if str(col.get_internal_type()).lower() == "integerfield":
column_list.append(col.name)
for k, v in params.items():
if k in column_list :
try:
params[k] = int(v)
except:
params[k] = 0
column_list = []
for col in model._meta.fields:
if str(col.get_internal_type()).lower() == "floatfield":
column_list.append(col.name)
for k, v in params.items():
if k in column_list :
try:
params[k] = float(v)
except:
params[k] = 0.0
column_list = []
for col in model._meta.fields:
if 'char' in str(col.get_internal_type()).lower():
column_list.append(col.name)
for k, v in params.items():
if k in column_list and v == '':
params[k] = ""
column_list = []
for col in model._meta.fields:
if str(col.get_internal_type()).lower() == "datetimefield" or str(col.get_internal_type()).lower() == "datefield":
column_list.append(col.name)
params_=copy.deepcopy(params)
for k, v in params_.items():
if k in column_list and v == '':
del params[k]
userid = False
for col in model._meta.fields:
if str(col.name) == 'userid':
if col.null == False:
userid = True
if userid == True:
if params.get("userid") == "" or params.get("userid") == None:
request = get_current_request()
params['userid'] = request.session.get("params").get('id')
for col in model._meta.fields:
if str(col.name) not in params.keys():
if col.null == False:
if "VarChar" in str(col.get_internal_type()) or "Char" in str(col.get_internal_type()):
params[str(col.name)] = ""
column_list = []
for col in model._meta.fields:
column_list.append(col.name)
paramss={}
for k, v in params.items():
if k in column_list:
paramss[k] = v
m = model(**paramss)
try:
ret = m.save()
log.info("ret========>{}".format(ret))
return None
except Exception as e:
return "{}:{}".format(Exception, e)
def createbyreq(self, model, params):
'''
根据请求参数创建对应模型记录
:param model:
:param params:
:return:
'''
return self.__CreateByReq(model, model, params)
def __GetById(self, model, id):
'''
根据id获取数据公共方法
:param id:
:return:
'''
data = model.objects.filter(id=id).all()
return self.to_list(model, data)
def getbyid(self, model, id):
'''
根据id获取数据
:param model:
:param id:
:return:
'''
return self.__GetById(model, model, id)
def __GetByParams(self, model, params):
try:
__loginUser__ = model.__loginUser__
except:
__loginUser__ = None
if __loginUser__ != None:
if params.get('username'):
params[model.__loginUser__] = copy.deepcopy(params.get('username'))
del params['username']
if model.__tablename__ != 'users':
if params.get('password'):
params['mima'] = copy.deepcopy(params.get('password'))
del params['password']
# 前端传了无用参数和传错参数名,在这里修改
paramss = {}
columnList = self.getallcolumn(model, model)
for k, v in params.items():
if k in columnList:
paramss[k] = v
datas_ = model.objects.filter(**paramss).all()
return self.to_list(datas_, datas_)
def getbyparams(self, model, params):
return self.__GetByParams(model, model, params)
def __GetBetweenParams(self, model, columnName, params):
'''
:param model:
:param params:
:return:
'''
print("__GetBetweenParams params=============>",params)
remindstart = copy.deepcopy(params.get("remindstart"))
remindend = copy.deepcopy(params.get("remindend"))
try:
del params["remindstart"]
del params["remindend"]
del params["type"]
except:
pass
# todo where是否合法
datas = eval("model.objects.filter(**params).filter({}__range= [remindstart, remindend]).all()".format(columnName))
print("datas===========>",datas)
try:
data = [i if i.items else model_to_dict(i) for i in datas]
except:
try:
data = [model_to_dict(i) for i in datas]
except:
data = datas
return data
def getbetweenparams(self, model, columnName, params):
'''
区域内查询
:param model:
:param params:
:return:
'''
return self.__GetBetweenParams(self, model, columnName, params)
def __GetComputedByColumn(self, model, columnName):
return model.objects.aggregate(
sum=Sum(columnName),
max=Max(columnName),
min=Min(columnName),
avg=Avg(columnName),
)
def getcomputedbycolumn(self, model, columnName):
'''
求和最大最小平均值
:param model:
:param columnName:
:return:
'''
return self.__GetComputedByColumn(self, model, columnName)
def __GroupByColumnName(self, model, columnName):
'''
django指定获取那些列:values
统计values里每一个字符串出现的次数
:param model:
:param columnName:
:return:
'''
datas = model.objects.values(columnName).annotate(total=Count(columnName)).all()
try:
data = [model_to_dict(i) for i in datas]
except:
data = datas
data = [{columnName: x.get(columnName), "total": int(x.get("total"))} for x in data]
return data
def groupbycolumnname(self, model, columnName):
'''
类别统计
:param model:
:param params:
:return:
'''
return self.__GroupByColumnName(self, model, columnName)
def __GetValueByxyColumnName(self, model, xColumnName, yColumnName):
'''
按值统计接口
SELECT ${xColumnName}, ${yColumnName} total FROM ${tableName} order by ${yColumnName} desc limit 10
:param model:
:param xColumnName:
:param yColumnName:
:return:
'''
datas = model.objects.values(xColumnName).\
annotate(total=Sum(yColumnName)).all()[:10]
try:
data = list(datas)
except Exception as e:
print(Exception,":",e)
data = datas
return data
def getvaluebyxycolumnname(self, model, xColumnName, yColumnName):
'''
:param model:
:param xColumnName:
:param yColumnName:
:return:
'''
return self.__GetValueByxyColumnName(self, model, xColumnName, yColumnName)
def __UpdateByParams(self, model, params):
'''
根据接口传参更新对应id记录的公共方法
:param model:
:param params:
:return:
'''
id_ = copy.deepcopy(params['id'])
del params['id']
# 去掉多传的参数
column_list = self.getallcolumn(model,model) # 获取所有字段名
newParams = {}
for k, v in params.items():
if k in column_list:
ret1 = re.findall("\d{4}-\d{2}-\d{2}", str(v))
ret2 = re.findall("\d{2}:\d{2}:\d{2}", str(v))
if len(ret1) > 0 and len(ret2) > 0:
newParams[k] ="{} {}".format( ret1[0],ret2[0])
else:
newParams[k] = v
column_list = []
for col in model._meta.fields:
if str(col.get_internal_type()).lower() == "bigintegerfield":
column_list.append(col.name)
for k, v in newParams.items():
if k in column_list:
try:
newParams[k] = int(v)
except:
newParams[k] = 0
column_list = []
for col in model._meta.fields:
if str(col.get_internal_type()).lower() == "integerfield":
column_list.append(col.name)
for k, v in newParams.items():
if k in column_list :
try:
newParams[k] = int(v)
except:
newParams[k] = 0
column_list = []
for col in model._meta.fields:
if str(col.get_internal_type()).lower() == "floatfield":
column_list.append(col.name)
for k, v in newParams.items():
if k in column_list :
try:
newParams[k] = float(v)
except:
newParams[k] = 0.0
column_list = []
for col in model._meta.fields:
if 'char' in str(col.get_internal_type()).lower():
column_list.append(col.name)
for k, v in newParams.items():
if k in column_list and v == '':
newParams[k] = ""
column_list = []
for col in model._meta.fields:
if str(col.get_internal_type()).lower() == "datetimefield":
column_list.append(col.name)
for k, v in newParams.items():
if k in column_list and v == '':
newParams[k] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
column_list = []
for col in model._meta.fields:
if str(col.get_internal_type()).lower() == "datefield":
column_list.append(col.name)
for k, v in newParams.items():
if k in column_list and v == '':
newParams[k] = time.strftime("%Y-%m-%d", time.localtime(time.time()))
column_list = []
for col in model._meta.fields:
column_list.append(col.name)
paramss = {}
for k, v in newParams.items():
if k in column_list:
paramss[k] = v
try:
model.objects.filter(id=int(id_)).update(
**paramss
)
return None
except Exception as e:
print(Exception, ":", e)
return e
def updatebyparams(self, model, params):
'''
根据接口传参更新对应id记录
:param params:
:return:
'''
return self.__UpdateByParams(model, model, params)
def __Deletes(self, model,ids:list):
'''
删除记录先查询再删除查询结果公共方法
:param user:
:return:
'''
try:
model.objects.filter(id__in =ids).delete()
return None
except Exception as e:
print(Exception, ":", e)
return e
def deletes(self,model, ids:list):
'''
删除记录先查询再删除查询结果
:param user:
:return:
'''
return self.__Deletes(model,model, ids)
def __DeleteByParams(self, model, newParams: dict):
'''
批量删除的内部方法
:param model:
:param params:
:return:
'''
column_list = []
for col in model._meta.fields:
if str(col.get_internal_type()).lower() == "integerfield":
column_list.append(col.name)
for k, v in newParams.items():
if k in column_list:
try:
newParams[k] = int(v)
except:
newParams[k] = 0
column_list = []
for col in model._meta.fields:
if str(col.get_internal_type()).lower() == "bigintegerfield":
column_list.append(col.name)
for k, v in newParams.items():
if k in column_list:
try:
newParams[k] = int(v)
except:
newParams[k] = 0
column_list = []
for col in model._meta.fields:
if str(col.get_internal_type()).lower() == "floatfield":
column_list.append(col.name)
for k, v in newParams.items():
if k in column_list:
try:
newParams[k] = float(v)
except:
newParams[k] = 0.0
try:
ret = model.objects.filter(**newParams).delete()
log.info("delete===============>{}".format(ret))
return None
except ProtectedError:
return str(ProtectedError)
def deletebyparams(self, model, ids: list):
'''
根据数组传参批量删除一个或多个id的记录
:param model:
:param params:
:return:
'''
return self.__DeleteByParams(model, model, ids)
def to_list(self, datas):
dataList = []
try:
dataList = [model_to_dict(i) for i in datas]
# for i in datas_:
# datas.append(model_to_dict(i))
except Exception as e:
print(Exception, ":", e)
return dataList
def getallcolumn(self, model):
"""
获取当前模型的所有字段
:returns dict:
"""
column_list = []
for col in model._meta.fields:
column_list.append(col.name)
return column_list

@ -0,0 +1,485 @@
#coding:utf-8
__author__ = "ila"
from django.db import models
from .model import BaseModel
from datetime import datetime
class qiuzhizhe(BaseModel):
__doc__ = u'''qiuzhizhe'''
__tablename__ = 'qiuzhizhe'
__loginUser__='zhanghao'
__authTables__={}
__authPeople__=''#用户表表属性loginUserColumn对应的值就是用户名字段mima就是密码字段
__loginUserColumn__='zhanghao'#用户表表属性loginUserColumn对应的值就是用户名字段mima就是密码字段
__sfsh__=''#表sfsh(是否审核,”是”或”否”)字段和sfhf(审核回复)字段,后台列表(page)的操作中要多一个”审核”按钮点击”审核”弹出一个页面包含”是否审核”和”审核回复”点击确定调用update接口修改sfsh和sfhf两个字段。
__authSeparate__=''#后台列表权限
__thumbsUp__=''#表属性thumbsUp[是/否]新增thumbsupnum赞和crazilynum踩字段
__intelRecom__=''#智能推荐功能(表属性:[intelRecom是/否)],新增clicktime[前端不显示该字段]字段调用info/detail接口的时候更新按clicktime排序查询)
__browseClick__=''#表属性[browseClick:是/否]点击字段clicknum调用info/detail接口的时候后端自动+1、投票功能表属性[vote:是/否]投票字段votenum,调用vote接口后端votenum+1
__foreEndListAuth__=''#前台列表权限foreEndListAuth[是/否]当foreEndListAuth=是刷的表新增用户字段userid前台list列表接口仅能查看自己的记录和add接口后台赋值userid的值
__foreEndList__=''#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
__isAdmin__=''#表属性isAdmin=”是”,刷出来的用户表也是管理员即page和list可以查看所有人的考试记录(同时应用于其他表)
addtime = models.DateTimeField(auto_now_add=False, verbose_name=u'创建时间')
zhanghao=models.CharField ( max_length=255,null=False,unique=True, verbose_name='账号' )
mima=models.CharField ( max_length=255,null=False, unique=False, verbose_name='密码' )
xingming=models.CharField ( max_length=255,null=False, unique=False, verbose_name='姓名' )
nianling=models.IntegerField ( null=True, unique=False, verbose_name='年龄' )
xingbie=models.CharField ( max_length=255, null=True, unique=False, verbose_name='性别' )
shouji=models.CharField ( max_length=255, null=True, unique=False, verbose_name='手机' )
zhaopian=models.CharField ( max_length=255, null=True, unique=False, verbose_name='照片' )
'''
zhanghao=VARCHAR
mima=VARCHAR
xingming=VARCHAR
nianling=Integer
xingbie=VARCHAR
shouji=VARCHAR
zhaopian=VARCHAR
'''
class Meta:
db_table = 'qiuzhizhe'
verbose_name = verbose_name_plural = '求职者'
class gongsi(BaseModel):
__doc__ = u'''gongsi'''
__tablename__ = 'gongsi'
__loginUser__='gongsizhanghao'
__authTables__={}
__authPeople__=''#用户表表属性loginUserColumn对应的值就是用户名字段mima就是密码字段
__loginUserColumn__='gongsizhanghao'#用户表表属性loginUserColumn对应的值就是用户名字段mima就是密码字段
__sfsh__=''#表sfsh(是否审核,”是”或”否”)字段和sfhf(审核回复)字段,后台列表(page)的操作中要多一个”审核”按钮点击”审核”弹出一个页面包含”是否审核”和”审核回复”点击确定调用update接口修改sfsh和sfhf两个字段。
__authSeparate__=''#后台列表权限
__thumbsUp__=''#表属性thumbsUp[是/否]新增thumbsupnum赞和crazilynum踩字段
__intelRecom__=''#智能推荐功能(表属性:[intelRecom是/否)],新增clicktime[前端不显示该字段]字段调用info/detail接口的时候更新按clicktime排序查询)
__browseClick__=''#表属性[browseClick:是/否]点击字段clicknum调用info/detail接口的时候后端自动+1、投票功能表属性[vote:是/否]投票字段votenum,调用vote接口后端votenum+1
__foreEndListAuth__=''#前台列表权限foreEndListAuth[是/否]当foreEndListAuth=是刷的表新增用户字段userid前台list列表接口仅能查看自己的记录和add接口后台赋值userid的值
__foreEndList__=''#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
__isAdmin__=''#表属性isAdmin=”是”,刷出来的用户表也是管理员即page和list可以查看所有人的考试记录(同时应用于其他表)
addtime = models.DateTimeField(auto_now_add=False, verbose_name=u'创建时间')
gongsizhanghao=models.CharField ( max_length=255,null=False,unique=True, verbose_name='公司账号' )
mima=models.CharField ( max_length=255,null=False, unique=False, verbose_name='密码' )
gongsimingcheng=models.CharField ( max_length=255,null=False, unique=False, verbose_name='公司名称' )
gongsilingyu=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司领域' )
gongsiguimo=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司规模' )
gongsileixing=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司类型' )
gongsitupian=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司图片' )
gongsidizhi=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司地址' )
'''
gongsizhanghao=VARCHAR
mima=VARCHAR
gongsimingcheng=VARCHAR
gongsilingyu=VARCHAR
gongsiguimo=VARCHAR
gongsileixing=VARCHAR
gongsitupian=VARCHAR
gongsidizhi=VARCHAR
'''
class Meta:
db_table = 'gongsi'
verbose_name = verbose_name_plural = '公司'
class gerenjianli(BaseModel):
__doc__ = u'''gerenjianli'''
__tablename__ = 'gerenjianli'
__authTables__={'zhanghao':'qiuzhizhe',}
__authPeople__=''#用户表表属性loginUserColumn对应的值就是用户名字段mima就是密码字段
__sfsh__=''#表sfsh(是否审核,”是”或”否”)字段和sfhf(审核回复)字段,后台列表(page)的操作中要多一个”审核”按钮点击”审核”弹出一个页面包含”是否审核”和”审核回复”点击确定调用update接口修改sfsh和sfhf两个字段。
__authSeparate__=''#后台列表权限
__thumbsUp__=''#表属性thumbsUp[是/否]新增thumbsupnum赞和crazilynum踩字段
__intelRecom__=''#智能推荐功能(表属性:[intelRecom是/否)],新增clicktime[前端不显示该字段]字段调用info/detail接口的时候更新按clicktime排序查询)
__browseClick__=''#表属性[browseClick:是/否]点击字段clicknum调用info/detail接口的时候后端自动+1、投票功能表属性[vote:是/否]投票字段votenum,调用vote接口后端votenum+1
__foreEndListAuth__=''#前台列表权限foreEndListAuth[是/否]当foreEndListAuth=是刷的表新增用户字段userid前台list列表接口仅能查看自己的记录和add接口后台赋值userid的值
__foreEndList__=''#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
__isAdmin__=''#表属性isAdmin=”是”,刷出来的用户表也是管理员即page和list可以查看所有人的考试记录(同时应用于其他表)
addtime = models.DateTimeField(auto_now_add=False, verbose_name=u'创建时间')
zhanghao=models.CharField ( max_length=255, null=True, unique=False, verbose_name='账号' )
xingming=models.CharField ( max_length=255, null=True, unique=False, verbose_name='姓名' )
xingbie=models.CharField ( max_length=255, null=True, unique=False, verbose_name='性别' )
shouji=models.CharField ( max_length=255, null=True, unique=False, verbose_name='手机' )
zhaopian=models.CharField ( max_length=255, null=True, unique=False, verbose_name='照片' )
zhuanye=models.CharField ( max_length=255,null=False, unique=False, verbose_name='专业' )
xueli=models.CharField ( max_length=255,null=False, unique=False, verbose_name='学历' )
xuexiao=models.CharField ( max_length=255,null=False, unique=False, verbose_name='学校' )
chushengriqi=models.DateField ( null=True, unique=False, verbose_name='出生日期' )
yingyushuiping=models.CharField ( max_length=255, null=True, unique=False, verbose_name='英语水平' )
gongzuonianxian=models.CharField ( max_length=255, null=True, unique=False, verbose_name='工作年限' )
juzhudizhi=models.CharField ( max_length=255, null=True, unique=False, verbose_name='居住地址' )
gerenjineng=models.TextField ( null=True, unique=False, verbose_name='个人技能' )
yixianggangwei=models.CharField ( max_length=255, null=True, unique=False, verbose_name='意向岗位' )
yixiangfangxiang=models.CharField ( max_length=255, null=True, unique=False, verbose_name='意向方向' )
yixiangchengshi=models.CharField ( max_length=255, null=True, unique=False, verbose_name='意向城市' )
yixiangxinshui=models.CharField ( max_length=255, null=True, unique=False, verbose_name='意向薪水' )
ziwomiaoshu=models.TextField ( null=True, unique=False, verbose_name='自我描述' )
'''
zhanghao=VARCHAR
xingming=VARCHAR
xingbie=VARCHAR
shouji=VARCHAR
zhaopian=VARCHAR
zhuanye=VARCHAR
xueli=VARCHAR
xuexiao=VARCHAR
chushengriqi=Date
yingyushuiping=VARCHAR
gongzuonianxian=VARCHAR
juzhudizhi=VARCHAR
gerenjineng=Text
yixianggangwei=VARCHAR
yixiangfangxiang=VARCHAR
yixiangchengshi=VARCHAR
yixiangxinshui=VARCHAR
ziwomiaoshu=Text
'''
class Meta:
db_table = 'gerenjianli'
verbose_name = verbose_name_plural = '个人简历'
class gongsixinxi(BaseModel):
__doc__ = u'''gongsixinxi'''
__tablename__ = 'gongsixinxi'
__authTables__={'gongsizhanghao':'gongsi',}
__authPeople__=''#用户表表属性loginUserColumn对应的值就是用户名字段mima就是密码字段
__sfsh__=''#表sfsh(是否审核,”是”或”否”)字段和sfhf(审核回复)字段,后台列表(page)的操作中要多一个”审核”按钮点击”审核”弹出一个页面包含”是否审核”和”审核回复”点击确定调用update接口修改sfsh和sfhf两个字段。
__authSeparate__=''#后台列表权限
__thumbsUp__=''#表属性thumbsUp[是/否]新增thumbsupnum赞和crazilynum踩字段
__intelRecom__=''#智能推荐功能(表属性:[intelRecom是/否)],新增clicktime[前端不显示该字段]字段调用info/detail接口的时候更新按clicktime排序查询)
__browseClick__=''#表属性[browseClick:是/否]点击字段clicknum调用info/detail接口的时候后端自动+1、投票功能表属性[vote:是/否]投票字段votenum,调用vote接口后端votenum+1
__foreEndListAuth__=''#前台列表权限foreEndListAuth[是/否]当foreEndListAuth=是刷的表新增用户字段userid前台list列表接口仅能查看自己的记录和add接口后台赋值userid的值
__foreEndList__=''#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
__isAdmin__=''#表属性isAdmin=”是”,刷出来的用户表也是管理员即page和list可以查看所有人的考试记录(同时应用于其他表)
addtime = models.DateTimeField(auto_now_add=False, verbose_name=u'创建时间')
gongsizhanghao=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司账号' )
gongsimingcheng=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司名称' )
fengmian=models.CharField ( max_length=255, null=True, unique=False, verbose_name='封面' )
gongsidizhi=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司地址' )
gongsilingyu=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司领域' )
gongsiguimo=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司规模' )
gongsileixing=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司类型' )
chuangliriqi=models.DateField ( null=True, unique=False, verbose_name='创立日期' )
fuzeren=models.CharField ( max_length=255, null=True, unique=False, verbose_name='负责人' )
lianxifangshi=models.CharField ( max_length=255, null=True, unique=False, verbose_name='联系方式' )
yuangongrenshu=models.CharField ( max_length=255, null=True, unique=False, verbose_name='员工人数' )
gongsijieshao=models.TextField ( null=True, unique=False, verbose_name='公司介绍' )
thumbsupnum=models.IntegerField ( null=True, unique=False,default='0', verbose_name='' )
crazilynum=models.IntegerField ( null=True, unique=False,default='0', verbose_name='' )
clicktime=models.DateTimeField ( null=True, unique=False, verbose_name='最近点击时间' )
clicknum=models.IntegerField ( null=True, unique=False,default='0', verbose_name='点击次数' )
'''
gongsizhanghao=VARCHAR
gongsimingcheng=VARCHAR
fengmian=VARCHAR
gongsidizhi=VARCHAR
gongsilingyu=VARCHAR
gongsiguimo=VARCHAR
gongsileixing=VARCHAR
chuangliriqi=Date
fuzeren=VARCHAR
lianxifangshi=VARCHAR
yuangongrenshu=VARCHAR
gongsijieshao=Text
thumbsupnum=Integer
crazilynum=Integer
clicktime=DateTime
clicknum=Integer
'''
class Meta:
db_table = 'gongsixinxi'
verbose_name = verbose_name_plural = '公司信息'
class zhaopinxinxi(BaseModel):
__doc__ = u'''zhaopinxinxi'''
__tablename__ = 'zhaopinxinxi'
__authTables__={'gongsizhanghao':'gongsi',}
__authPeople__=''#用户表表属性loginUserColumn对应的值就是用户名字段mima就是密码字段
__sfsh__=''#表sfsh(是否审核,”是”或”否”)字段和sfhf(审核回复)字段,后台列表(page)的操作中要多一个”审核”按钮点击”审核”弹出一个页面包含”是否审核”和”审核回复”点击确定调用update接口修改sfsh和sfhf两个字段。
__authSeparate__=''#后台列表权限
__thumbsUp__=''#表属性thumbsUp[是/否]新增thumbsupnum赞和crazilynum踩字段
__intelRecom__=''#智能推荐功能(表属性:[intelRecom是/否)],新增clicktime[前端不显示该字段]字段调用info/detail接口的时候更新按clicktime排序查询)
__browseClick__=''#表属性[browseClick:是/否]点击字段clicknum调用info/detail接口的时候后端自动+1、投票功能表属性[vote:是/否]投票字段votenum,调用vote接口后端votenum+1
__foreEndListAuth__=''#前台列表权限foreEndListAuth[是/否]当foreEndListAuth=是刷的表新增用户字段userid前台list列表接口仅能查看自己的记录和add接口后台赋值userid的值
__foreEndList__=''#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
__isAdmin__=''#表属性isAdmin=”是”,刷出来的用户表也是管理员即page和list可以查看所有人的考试记录(同时应用于其他表)
addtime = models.DateTimeField(auto_now_add=False, verbose_name=u'创建时间')
gangweibianhao=models.CharField ( max_length=255,null=False,unique=True, verbose_name='岗位编号' )
gangweimingcheng=models.CharField ( max_length=255,null=False, unique=False, verbose_name='岗位名称' )
shangbandizhi=models.CharField ( max_length=255,null=False, unique=False, verbose_name='上班地址' )
jingyanyaoqiu=models.TextField ( null=False, unique=False, verbose_name='经验要求' )
xueliyaoqiu=models.CharField ( max_length=255,null=False, unique=False, verbose_name='学历要求' )
zhaopinrenshu=models.IntegerField ( null=False, unique=False, verbose_name='招聘人数' )
gangweifuli=models.TextField ( null=True, unique=False, verbose_name='岗位福利' )
xinzidaiyu=models.CharField ( max_length=255, null=True, unique=False, verbose_name='薪资待遇' )
gongzuonianxian=models.CharField ( max_length=255,null=False, unique=False, verbose_name='工作年限' )
tupian=models.CharField ( max_length=255, null=True, unique=False, verbose_name='图片' )
fabushijian=models.DateField ( null=True, unique=False, verbose_name='发布时间' )
gongsizhanghao=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司账号' )
gongsimingcheng=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司名称' )
gongsilingyu=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司领域' )
gongsiguimo=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司规模' )
gongsileixing=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司类型' )
zhiweixinxi=models.TextField ( null=True, unique=False, verbose_name='职位信息' )
thumbsupnum=models.IntegerField ( null=True, unique=False,default='0', verbose_name='' )
crazilynum=models.IntegerField ( null=True, unique=False,default='0', verbose_name='' )
clicktime=models.DateTimeField ( null=True, unique=False, verbose_name='最近点击时间' )
clicknum=models.IntegerField ( null=True, unique=False,default='0', verbose_name='点击次数' )
'''
gangweibianhao=VARCHAR
gangweimingcheng=VARCHAR
shangbandizhi=VARCHAR
jingyanyaoqiu=Text
xueliyaoqiu=VARCHAR
zhaopinrenshu=Integer
gangweifuli=Text
xinzidaiyu=VARCHAR
gongzuonianxian=VARCHAR
tupian=VARCHAR
fabushijian=Date
gongsizhanghao=VARCHAR
gongsimingcheng=VARCHAR
gongsilingyu=VARCHAR
gongsiguimo=VARCHAR
gongsileixing=VARCHAR
zhiweixinxi=Text
thumbsupnum=Integer
crazilynum=Integer
clicktime=DateTime
clicknum=Integer
'''
class Meta:
db_table = 'zhaopinxinxi'
verbose_name = verbose_name_plural = '招聘信息'
class toudijianli(BaseModel):
__doc__ = u'''toudijianli'''
__tablename__ = 'toudijianli'
__authTables__={'zhanghao':'qiuzhizhe','gongsizhanghao':'gongsi',}
__authPeople__=''#用户表表属性loginUserColumn对应的值就是用户名字段mima就是密码字段
__sfsh__=''#表sfsh(是否审核,”是”或”否”)字段和sfhf(审核回复)字段,后台列表(page)的操作中要多一个”审核”按钮点击”审核”弹出一个页面包含”是否审核”和”审核回复”点击确定调用update接口修改sfsh和sfhf两个字段。
__authSeparate__=''#后台列表权限
__thumbsUp__=''#表属性thumbsUp[是/否]新增thumbsupnum赞和crazilynum踩字段
__intelRecom__=''#智能推荐功能(表属性:[intelRecom是/否)],新增clicktime[前端不显示该字段]字段调用info/detail接口的时候更新按clicktime排序查询)
__browseClick__=''#表属性[browseClick:是/否]点击字段clicknum调用info/detail接口的时候后端自动+1、投票功能表属性[vote:是/否]投票字段votenum,调用vote接口后端votenum+1
__foreEndListAuth__=''#前台列表权限foreEndListAuth[是/否]当foreEndListAuth=是刷的表新增用户字段userid前台list列表接口仅能查看自己的记录和add接口后台赋值userid的值
__foreEndList__=''#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
__isAdmin__=''#表属性isAdmin=”是”,刷出来的用户表也是管理员即page和list可以查看所有人的考试记录(同时应用于其他表)
addtime = models.DateTimeField(auto_now_add=False, verbose_name=u'创建时间')
zhanghao=models.CharField ( max_length=255, null=True, unique=False, verbose_name='账号' )
xingming=models.CharField ( max_length=255, null=True, unique=False, verbose_name='姓名' )
zhaopian=models.CharField ( max_length=255, null=True, unique=False, verbose_name='照片' )
jianliwenjian=models.CharField ( max_length=255, null=True, unique=False, verbose_name='简历文件' )
gangweimingcheng=models.CharField ( max_length=255, null=True, unique=False, verbose_name='岗位名称' )
toudishijian=models.DateTimeField ( null=True, unique=False, verbose_name='投递时间' )
gongsizhanghao=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司账号' )
gongsimingcheng=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司名称' )
crossuserid=models.BigIntegerField ( null=True, unique=False, verbose_name='跨表用户id' )
crossrefid=models.BigIntegerField ( null=True, unique=False, verbose_name='跨表主键id' )
sfsh=models.CharField ( max_length=255, null=True, unique=False,default='', verbose_name='是否审核' )
shhf=models.TextField ( null=True, unique=False, verbose_name='审核回复' )
'''
zhanghao=VARCHAR
xingming=VARCHAR
zhaopian=VARCHAR
jianliwenjian=VARCHAR
gangweimingcheng=VARCHAR
toudishijian=DateTime
gongsizhanghao=VARCHAR
gongsimingcheng=VARCHAR
crossuserid=BigInteger
crossrefid=BigInteger
sfsh=VARCHAR
shhf=Text
'''
class Meta:
db_table = 'toudijianli'
verbose_name = verbose_name_plural = '投递简历'
class mianshiyaoqing(BaseModel):
__doc__ = u'''mianshiyaoqing'''
__tablename__ = 'mianshiyaoqing'
__authTables__={'gongsizhanghao':'gongsi','zhanghao':'qiuzhizhe',}
__authPeople__=''#用户表表属性loginUserColumn对应的值就是用户名字段mima就是密码字段
__sfsh__=''#表sfsh(是否审核,”是”或”否”)字段和sfhf(审核回复)字段,后台列表(page)的操作中要多一个”审核”按钮点击”审核”弹出一个页面包含”是否审核”和”审核回复”点击确定调用update接口修改sfsh和sfhf两个字段。
__authSeparate__=''#后台列表权限
__thumbsUp__=''#表属性thumbsUp[是/否]新增thumbsupnum赞和crazilynum踩字段
__intelRecom__=''#智能推荐功能(表属性:[intelRecom是/否)],新增clicktime[前端不显示该字段]字段调用info/detail接口的时候更新按clicktime排序查询)
__browseClick__=''#表属性[browseClick:是/否]点击字段clicknum调用info/detail接口的时候后端自动+1、投票功能表属性[vote:是/否]投票字段votenum,调用vote接口后端votenum+1
__foreEndListAuth__=''#前台列表权限foreEndListAuth[是/否]当foreEndListAuth=是刷的表新增用户字段userid前台list列表接口仅能查看自己的记录和add接口后台赋值userid的值
__foreEndList__=''#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
__isAdmin__=''#表属性isAdmin=”是”,刷出来的用户表也是管理员即page和list可以查看所有人的考试记录(同时应用于其他表)
addtime = models.DateTimeField(auto_now_add=False, verbose_name=u'创建时间')
gangweimingcheng=models.CharField ( max_length=255, null=True, unique=False, verbose_name='岗位名称' )
tongzhineirong=models.TextField ( null=False, unique=False, verbose_name='通知内容' )
tongzhishijian=models.DateTimeField ( null=True, unique=False, verbose_name='通知时间' )
gongsizhanghao=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司账号' )
gongsimingcheng=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司名称' )
zhanghao=models.CharField ( max_length=255, null=True, unique=False, verbose_name='账号' )
xingming=models.CharField ( max_length=255, null=True, unique=False, verbose_name='姓名' )
crossuserid=models.BigIntegerField ( null=True, unique=False, verbose_name='跨表用户id' )
crossrefid=models.BigIntegerField ( null=True, unique=False, verbose_name='跨表主键id' )
sfsh=models.CharField ( max_length=255, null=True, unique=False,default='', verbose_name='是否审核' )
shhf=models.TextField ( null=True, unique=False, verbose_name='审核回复' )
'''
gangweimingcheng=VARCHAR
tongzhineirong=Text
tongzhishijian=DateTime
gongsizhanghao=VARCHAR
gongsimingcheng=VARCHAR
zhanghao=VARCHAR
xingming=VARCHAR
crossuserid=BigInteger
crossrefid=BigInteger
sfsh=VARCHAR
shhf=Text
'''
class Meta:
db_table = 'mianshiyaoqing'
verbose_name = verbose_name_plural = '面试邀请'
class mianshijieguo(BaseModel):
__doc__ = u'''mianshijieguo'''
__tablename__ = 'mianshijieguo'
__authTables__={'gongsizhanghao':'gongsi','zhanghao':'qiuzhizhe',}
__authPeople__=''#用户表表属性loginUserColumn对应的值就是用户名字段mima就是密码字段
__sfsh__=''#表sfsh(是否审核,”是”或”否”)字段和sfhf(审核回复)字段,后台列表(page)的操作中要多一个”审核”按钮点击”审核”弹出一个页面包含”是否审核”和”审核回复”点击确定调用update接口修改sfsh和sfhf两个字段。
__authSeparate__=''#后台列表权限
__thumbsUp__=''#表属性thumbsUp[是/否]新增thumbsupnum赞和crazilynum踩字段
__intelRecom__=''#智能推荐功能(表属性:[intelRecom是/否)],新增clicktime[前端不显示该字段]字段调用info/detail接口的时候更新按clicktime排序查询)
__browseClick__=''#表属性[browseClick:是/否]点击字段clicknum调用info/detail接口的时候后端自动+1、投票功能表属性[vote:是/否]投票字段votenum,调用vote接口后端votenum+1
__foreEndListAuth__=''#前台列表权限foreEndListAuth[是/否]当foreEndListAuth=是刷的表新增用户字段userid前台list列表接口仅能查看自己的记录和add接口后台赋值userid的值
__foreEndList__=''#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
__isAdmin__=''#表属性isAdmin=”是”,刷出来的用户表也是管理员即page和list可以查看所有人的考试记录(同时应用于其他表)
addtime = models.DateTimeField(auto_now_add=False, verbose_name=u'创建时间')
biaoti=models.CharField ( max_length=255, null=True, unique=False, verbose_name='标题' )
gangweimingcheng=models.CharField ( max_length=255, null=True, unique=False, verbose_name='岗位名称' )
jieguo=models.TextField ( null=False, unique=False, verbose_name='结果' )
shijian=models.DateTimeField ( null=True, unique=False, verbose_name='时间' )
gongsizhanghao=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司账号' )
gongsimingcheng=models.CharField ( max_length=255, null=True, unique=False, verbose_name='公司名称' )
zhanghao=models.CharField ( max_length=255, null=True, unique=False, verbose_name='账号' )
xingming=models.CharField ( max_length=255, null=True, unique=False, verbose_name='姓名' )
crossuserid=models.BigIntegerField ( null=True, unique=False, verbose_name='跨表用户id' )
crossrefid=models.BigIntegerField ( null=True, unique=False, verbose_name='跨表主键id' )
'''
biaoti=VARCHAR
gangweimingcheng=VARCHAR
jieguo=Text
shijian=DateTime
gongsizhanghao=VARCHAR
gongsimingcheng=VARCHAR
zhanghao=VARCHAR
xingming=VARCHAR
crossuserid=BigInteger
crossrefid=BigInteger
'''
class Meta:
db_table = 'mianshijieguo'
verbose_name = verbose_name_plural = '面试结果'
class tongzhigonggao(BaseModel):
__doc__ = u'''tongzhigonggao'''
__tablename__ = 'tongzhigonggao'
__authTables__={}
__authPeople__=''#用户表表属性loginUserColumn对应的值就是用户名字段mima就是密码字段
__sfsh__=''#表sfsh(是否审核,”是”或”否”)字段和sfhf(审核回复)字段,后台列表(page)的操作中要多一个”审核”按钮点击”审核”弹出一个页面包含”是否审核”和”审核回复”点击确定调用update接口修改sfsh和sfhf两个字段。
__authSeparate__=''#后台列表权限
__thumbsUp__=''#表属性thumbsUp[是/否]新增thumbsupnum赞和crazilynum踩字段
__intelRecom__=''#智能推荐功能(表属性:[intelRecom是/否)],新增clicktime[前端不显示该字段]字段调用info/detail接口的时候更新按clicktime排序查询)
__browseClick__=''#表属性[browseClick:是/否]点击字段clicknum调用info/detail接口的时候后端自动+1、投票功能表属性[vote:是/否]投票字段votenum,调用vote接口后端votenum+1
__foreEndListAuth__=''#前台列表权限foreEndListAuth[是/否]当foreEndListAuth=是刷的表新增用户字段userid前台list列表接口仅能查看自己的记录和add接口后台赋值userid的值
__foreEndList__=''#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
__isAdmin__=''#表属性isAdmin=”是”,刷出来的用户表也是管理员即page和list可以查看所有人的考试记录(同时应用于其他表)
addtime = models.DateTimeField(auto_now_add=False, verbose_name=u'创建时间')
biaoti=models.CharField ( max_length=255,null=False, unique=False, verbose_name='标题' )
jianjie=models.TextField ( null=True, unique=False, verbose_name='简介' )
fabushijian=models.DateField ( null=True, unique=False, verbose_name='发布时间' )
fengmian=models.CharField ( max_length=255, null=True, unique=False, verbose_name='封面' )
neirong=models.TextField ( null=True, unique=False, verbose_name='内容' )
clicktime=models.DateTimeField ( null=True, unique=False, verbose_name='最近点击时间' )
clicknum=models.IntegerField ( null=True, unique=False,default='0', verbose_name='点击次数' )
'''
biaoti=VARCHAR
jianjie=Text
fabushijian=Date
fengmian=VARCHAR
neirong=Text
clicktime=DateTime
clicknum=Integer
'''
class Meta:
db_table = 'tongzhigonggao'
verbose_name = verbose_name_plural = '通知公告'
class keshihua(BaseModel):
__doc__ = u'''keshihua'''
__tablename__ = 'keshihua'
__authTables__={}
__authPeople__=''#用户表表属性loginUserColumn对应的值就是用户名字段mima就是密码字段
__sfsh__=''#表sfsh(是否审核,”是”或”否”)字段和sfhf(审核回复)字段,后台列表(page)的操作中要多一个”审核”按钮点击”审核”弹出一个页面包含”是否审核”和”审核回复”点击确定调用update接口修改sfsh和sfhf两个字段。
__authSeparate__=''#后台列表权限
__thumbsUp__=''#表属性thumbsUp[是/否]新增thumbsupnum赞和crazilynum踩字段
__intelRecom__=''#智能推荐功能(表属性:[intelRecom是/否)],新增clicktime[前端不显示该字段]字段调用info/detail接口的时候更新按clicktime排序查询)
__browseClick__=''#表属性[browseClick:是/否]点击字段clicknum调用info/detail接口的时候后端自动+1、投票功能表属性[vote:是/否]投票字段votenum,调用vote接口后端votenum+1
__foreEndListAuth__=''#前台列表权限foreEndListAuth[是/否]当foreEndListAuth=是刷的表新增用户字段userid前台list列表接口仅能查看自己的记录和add接口后台赋值userid的值
__foreEndList__=''#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
__isAdmin__=''#表属性isAdmin=”是”,刷出来的用户表也是管理员即page和list可以查看所有人的考试记录(同时应用于其他表)
addtime = models.DateTimeField(auto_now_add=False, verbose_name=u'创建时间')
keshihua=models.CharField ( max_length=255, null=True, unique=False, verbose_name='可视化' )
'''
keshihua=VARCHAR
'''
class Meta:
db_table = 'keshihua'
verbose_name = verbose_name_plural = '可视化'
class storeup(BaseModel):
__doc__ = u'''storeup'''
__tablename__ = 'storeup'
__authTables__={}
__authSeparate__=''#后台列表权限
__foreEndListAuth__=''#前台列表权限foreEndListAuth[是/否]当foreEndListAuth=是刷的表新增用户字段userid前台list列表接口仅能查看自己的记录和add接口后台赋值userid的值
addtime = models.DateTimeField(auto_now_add=False, verbose_name=u'创建时间')
userid=models.BigIntegerField ( null=False, unique=False, verbose_name='用户id' )
refid=models.BigIntegerField ( null=True, unique=False, verbose_name='收藏id' )
tablename=models.CharField ( max_length=255, null=True, unique=False, verbose_name='表名' )
name=models.CharField ( max_length=255,null=False, unique=False, verbose_name='收藏名称' )
picture=models.CharField ( max_length=255,null=False, unique=False, verbose_name='收藏图片' )
type=models.CharField ( max_length=255, null=True, unique=False,default='1', verbose_name='类型(1:收藏,21:赞,22:踩)' )
inteltype=models.CharField ( max_length=255, null=True, unique=False, verbose_name='推荐类型' )
'''
userid=BigInteger
refid=BigInteger
tablename=VARCHAR
name=VARCHAR
picture=VARCHAR
type=VARCHAR
inteltype=VARCHAR
'''
class Meta:
db_table = 'storeup'
verbose_name = verbose_name_plural = '收藏表'

Binary file not shown.
Loading…
Cancel
Save