master
123456xjy 6 months ago
parent b9c8052100
commit 7dc6956bfd

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,16 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="2">
<item index="0" class="java.lang.String" itemvalue="django" />
<item index="1" class="java.lang.String" itemvalue="requests" />
</list>
</value>
</option>
</inspection_tool>
</profile>
</component>

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11 (pythonProject1)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (python电影院信息管理)" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/python电影院信息管理.iml" filepath="$PROJECT_DIR$/.idea/python电影院信息管理.iml" />
</modules>
</component>
</project>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.7 (python电影院信息管理)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Jinja2" />
<option name="TEMPLATE_FOLDERS">
<list>
<option value="$MODULE_DIR$/djangof11e3/templates" />
</list>
</option>
</component>
</module>

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="FacetManager">
<facet type="django" name="Django">
<configuration>
<option name="rootFolder" value="$MODULE_DIR$" />
<option name="settingsModule" value="dj2/settings.py" />
<option name="manageScript" value="$MODULE_DIR$/manage.py" />
<option name="environment" value="&lt;map/&gt;" />
<option name="doNotUseTestRunner" value="false" />
<option name="trackFilePattern" value="migrations" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.11 (pythonProject1)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Django" />
<option name="TEMPLATE_FOLDERS">
<list>
<option value="$MODULE_DIR$/templates" />
</list>
</option>
</component>
</module>

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (pythonProject1)" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/djangof11e3.iml" filepath="$PROJECT_DIR$/.idea/djangof11e3.iml" />
</modules>
</component>
</project>

@ -0,0 +1,9 @@
[sql]
;support two sql,mysql and mssql,choice one
type = mysql
host = 127.0.0.1
port = 3306
user = root
passwd = 1234
db = djangof11e3
charset = utf8

@ -0,0 +1,3 @@
import pymysql
pymysql.install_as_MySQLdb()

@ -0,0 +1,155 @@
"""
Django settings for dj2 project.
Generated by 'django-admin startproject' using Django 2.0.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.0/ref/settings/
"""
import os
from util.configread import config_read
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'w5yn#0gn2tt7pvu%hvwt0!lt=!$6+eqp4%m8)u3u#gknm@jm)k'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ["*"]
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
"main",
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
# 'django.middleware.csrf.CsrfViewMiddleware',#Forbidden (CSRF cookie not set.)
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'threadlocals.middleware.ThreadLocalMiddleware',
"xmiddleware.xparam.Xparam",
"xmiddleware.xauth.Xauth",
]
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
SESSION_COOKIE_NAME = "sessionid"
SESSION_COOKIE_PATH = "/"
SESSION_COOKIE_DOMAIN = None
SESSION_COOKIE_SECURE = False
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_AGE = 1209600
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
SESSION_SAVE_EVERY_REQUEST = False
ROOT_URLCONF = 'dj2.urls'
TEMPLATES_DIR = os.path.join(BASE_DIR, "templates")
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [TEMPLATES_DIR],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'dj2.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
# }
# }
dbtype, host, port, user, passwd, dbName, charset = config_read("config.ini")
dbName=dbName.replace(" ","").strip()
print(dbtype, host, port, user, passwd, dbName, charset)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'project',
'USER':'root',
'PASSWORD':'1234',
'HOST':'127.0.0.1',
'PORT':3306
}
}
# Password validation
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.0/topics/i18n/
LANGUAGE_CODE = 'zh-Hans'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = '/assets/'
STATICFILES_DIRS =[
os.path.join(BASE_DIR, "templates/front/assets"),
]
# media
MEDIA_URL = "/media/" # 自定义
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') # 自定义
if os.path.isdir(MEDIA_ROOT) == False:
os.mkdir(MEDIA_ROOT)

@ -0,0 +1,101 @@
"""dj2 URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
import os
from django.contrib import admin
from django.urls import path,include,re_path
from django.conf.urls import url
from django.views.static import serve
from django.views.generic import TemplateView
from . import views
from dj2.settings import dbName as schemaName
urlpatterns = [
path('xadmin/', admin.site.urls),
path(r'index/',views.index),
re_path(r'admin/lib/(?P<p1>.*)/(?P<p2>.*)$', views.admin_lib2),
re_path(r'admin/lib/(?P<p1>.*)/(?P<p2>.*)/(?P<p3>.*)$', views.admin_lib3),
re_path(r'admin/lib/(?P<p1>.*)/(?P<p2>.*)/(?P<p3>.*)/(?P<p4>.*)$', views.admin_lib4),
re_path(r'admin/page/(?P<p1>.*)$', views.admin_page),
re_path(r'admin/page/(?P<p1>.*)/(?P<p2>.*)$', views.admin_page2),
re_path(r'admin/pages/(?P<p1>.*)$', views.admin_pages),
re_path(r'admin/pages/(?P<p1>.*)/(?P<p2>.*)$', views.admin_pages2),
re_path(r'front/(?P<p1>.*)$', views.schema_front1),
re_path(r'front/(?P<p1>.*)/(?P<p2>.*)$', views.schema_front2),
re_path(r'front/(?P<p1>.*)/(?P<p2>.*)/(?P<p3>.*)$', views.schema_front3),
re_path(r'front/(?P<p1>.*)/(?P<p2>.*)/(?P<p3>.*)/(?P<p4>.*)$', views.schema_front4),
re_path(r'{}/front/(?P<p1>.*)$'.format(schemaName), views.schema_front1),
re_path(r'{}/front/(?P<p1>.*)/(?P<p2>.*)$'.format(schemaName), views.schema_front2),
re_path(r'{}/front/(?P<p1>.*)/(?P<p2>.*)/(?P<p3>.*)$'.format(schemaName), views.schema_front3),
re_path(r'{}/front/(?P<p1>.*)/(?P<p2>.*)/(?P<p3>.*)/(?P<p4>.*)$'.format(schemaName), views.schema_front4),
# re_path(r'assets/(?P<p1>.*)$', views.assets1),
# re_path(r'assets/(?P<p1>.*)/(?P<p2>.*)$', views.assets2),
# re_path(r'assets/(?P<p1>.*)/(?P<p2>.*)/(?P<p3>.*)$', views.assets3),
# re_path(r'assets/(?P<p1>.*)/(?P<p2>.*)/(?P<p3>.*)/(?P<p4>.*)$', views.assets4),
#re_path(r'admin/(?P<p1>.*)$', views.admin_file1),
re_path(r'admin/(?P<p1>.*)/(?P<p2>.*)$', views.admin_file2),
re_path(r'admin/(?P<p1>.*)/(?P<p2>.*)/(?P<p3>.*)$', views.admin_file3),
re_path(r'admin/(?P<p1>.*)/(?P<p2>.*)/(?P<p3>.*)/(?P<p4>.*)$', views.admin_file4),
re_path(r'layui/(?P<p1>.*)$', views.layui1),
re_path(r'layui/(?P<p1>.*)/(?P<p2>.*)$', views.layui2),
re_path(r'layui/(?P<p1>.*)/(?P<p2>.*)/(?P<p3>.*)$', views.layui3),
re_path(r'layui/(?P<p1>.*)/(?P<p2>.*)/(?P<p3>.*)/(?P<p4>.*)$', views.layui4),
re_path(r'pages/(?P<p1>.*)$', views.front_pages),
re_path(r'pages/(?P<p1>.*)/(?P<p2>.*)$', views.front_pages2),
# re_path(r'pages/(?P<p1>.*)$', views.front_file1),
# re_path(r'(?P<p1>css|jss|img|image|iamges|font|fonts)/(?P<p2>.*)$', views.front_file2),
re_path(r'modules/(?P<p1>.*)$', views.front_modules),
re_path(r'css/(?P<p1>.*)$', views.css1),
re_path(r'js/(?P<p1>.*)$', views.js1),
re_path(r'img/(?P<p1>.*)$', views.img1),
path(r'test/<str:p1>/',views.test),
path(r'null',views.null),
path('{}/'.format(schemaName),include('main.urls')),#导入schemaName
]
#判断admin使用vue还是jquery
if os.path.isdir(os.path.join(os.getcwd(),"templates/front/admin/dist/")):
urlpatterns.extend([
path(r'{}/admin/dist/index.html'.format(schemaName),
TemplateView.as_view(template_name='front/admin/dist/index.html')),
path(r'{}/admin/'.format(schemaName), TemplateView.as_view(template_name='front/admin/dist/index.html')),
# 以下是后台admin的url匹配规则
path(r'admin/dist/index.html'.format(schemaName),
TemplateView.as_view(template_name='front/admin/dist/index.html')),
path(r'admin/', TemplateView.as_view(template_name='front/admin/dist/index.html')),
])
else:
urlpatterns.extend([
path(r'{}/admin/index.html'.format(schemaName),
TemplateView.as_view(template_name='front/admin/index.html')),
path(r'{}/admin/'.format(schemaName), TemplateView.as_view(template_name='front/admin/index.html')),
# 以下是后台admin的url匹配规则
path(r'admin/index.html'.format(schemaName),
TemplateView.as_view(template_name='front/admin/index.html')),
path(r'admin/', TemplateView.as_view(template_name='front/admin/index.html')),
])
if os.path.isfile(os.path.join(os.getcwd(),"templates/front/index.html")):
urlpatterns.extend([
path(r'index.html', TemplateView.as_view(template_name='front/index.html')),
path(r'{}/index.html'.format(schemaName), TemplateView.as_view(template_name='front/index.html')),
path(r'{}/front/index.html'.format(schemaName), TemplateView.as_view(template_name='front/index.html')),
path(r'', TemplateView.as_view(template_name='front/index.html')),
])

@ -0,0 +1,963 @@
# coding:utf-8
__author__ = "ila"
import os,sys
from django.http import JsonResponse, HttpResponse
from django.apps import apps
def index(request):
if request.method in ["GET", "POST"]:
msg = {"code": 200, "msg": "success", "data": []}
print("=================>index")
# allModels = apps.get_app_config('main').get_models()
# for m in allModels:
# print(m.__tablename__)
# print(dir(m))
# # for col in m._meta.fields:
# # print("col name============>",col.name)
# # print("col type============>",col.get_internal_type())
# print(allModels)
return JsonResponse(msg)
def test(request, p1):
if request.method in ["GET", "POST"]:
msg = {"code": 200, "msg": "success", "data": []}
print("=================>index ", p1)
return JsonResponse(msg)
def null(request,):
if request.method in ["GET", "POST"]:
msg = {"code": 200, "msg": "success", "data": []}
return JsonResponse(msg)
def check_suffix(filelName,path1):
try:
image_data = open(path1, "rb").read()
except:
image_data = "no file"
if '.js' in filelName:
return HttpResponse(image_data, content_type="application/javascript")
elif '.jpg' in filelName or '.jpeg' in filelName or '.png' in filelName or '.gif' in filelName:
return HttpResponse(image_data, content_type="image/png")
elif '.css' in filelName:
return HttpResponse(image_data, content_type="text/css")
elif '.ttf' in filelName or '.woff' in filelName:
return HttpResponse(image_data, content_type="application/octet-stream")
elif '.mp4' in filelName:
return HttpResponse(image_data, content_type="video/mp4")
elif '.mp3' in filelName:
return HttpResponse(image_data, content_type="audio/mp3")
elif '.csv' in filelName:
return HttpResponse(image_data, content_type="application/CSV")
elif '.doc' in filelName:
return HttpResponse(image_data, content_type="application/msword")
elif '.docx' in filelName:
return HttpResponse(image_data, content_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document")
elif '.xls' in filelName:
return HttpResponse(image_data, content_type="application/vnd.ms-excel")
elif '.xlsx' in filelName:
return HttpResponse(image_data, content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
elif '.ppt' in filelName:
return HttpResponse(image_data, content_type="application/vnd.ms-powerpoint")
elif '.pptx' in filelName:
return HttpResponse(image_data, content_type="application/vnd.openxmlformats-officedocument.presentationml.presentation")
else:
return HttpResponse(image_data, content_type="text/html")
def admin_lib2(request, p1, p2):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/admin/lib/", p1, p2)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p2:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p2 or '.jpeg' in p2 or '.png' in p2 or '.gif' in p2:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p2:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p2 or '.woff' in p2:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p2:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p2:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def admin_lib3(request, p1, p2, p3):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/admin/lib/", p1, p2, p3)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p3:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p3 or '.jpeg' in p3 or '.png' in p3 or '.gif' in p3:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p3:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p3 or '.woff' in p3:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p3:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p3:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def admin_lib4(request, p1, p2, p3, p4):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/admin/lib/", p1, p2, p3, p4)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p4:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p4 or '.jpeg' in p4 or '.png' in p4 or '.gif' in p4:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p4:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p4 or '.woff' in p4:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p4:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p4:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def admin_page(request, p1):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/admin/page/", p1)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p1:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p1 or '.jpeg' in p1 or '.png' in p1 or '.gif' in p1:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p1:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p1 or '.woff' in p1:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p1:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p1:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def admin_page2(request, p1, p2):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/admin/page/", p1, p2)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p2:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p2 or '.jpeg' in p2 or '.png' in p2 or '.gif' in p2:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p2:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p2 or '.woff' in p2:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p2:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p2:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def admin_pages(request, p1):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/admin/pages/", p1)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p1:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p1 or '.jpeg' in p1 or '.png' in p1 or '.gif' in p1:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p1:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p1 or '.woff' in p1:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p1:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p1:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def admin_pages2(request, p1, p2):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/admin/pages/", p1, p2)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p2:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p2 or '.jpeg' in p2 or '.png' in p2 or '.gif' in p2:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p2:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p2 or '.woff' in p2:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p2:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p2:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def admin_file1(request, p1):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/admin/", p1)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p1:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p1 or '.jpeg' in p1 or '.png' in p1 or '.gif' in p1:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p1:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p1 or '.woff' in p1:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p1:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p1:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def admin_file2(request, p1, p2):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/admin/", p1, p2)
if not os.path.isfile(path1):
path1 = os.path.join(os.getcwd(), "templates/front/admin/dist/", p1, p2)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p2:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p2 or '.jpeg' in p2 or '.png' in p2 or '.gif' in p2:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p2:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p2 or '.woff' in p2:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p2:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p2:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def admin_file3(request, p1, p2, p3):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/admin/", p1, p2, p3)
if not os.path.isfile(path1):
path1 = os.path.join(os.getcwd(), "templates/front/admin/dist/", p1, p2,p3)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p3:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p3 or '.jpeg' in p3 or '.png' in p3 or '.gif' in p3:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p3:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p3 or '.woff' in p3:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p3:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p3:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def admin_file4(request, p1, p2, p3, p4):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/admin/", p1, p2, p3, p4)
if not os.path.isfile(path1):
path1 = os.path.join(os.getcwd(), "templates/front/admin/dist/", p1, p2,p3,p4)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p4:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p4 or '.jpeg' in p4 or '.png' in p4 or '.gif' in p4:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p4:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p4 or '.woff' in p4:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p4:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p4:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def front_pages(request, p1):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/pages/", p1)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p1:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p1 or '.jpeg' in p1 or '.png' in p1 or '.gif' in p1:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p1:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p1 or '.woff' in p1:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p1:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p1:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def front_pages2(request, p1, p2):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/pages/", p1, p2)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p2:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p2 or '.jpeg' in p2 or '.png' in p2 or '.gif' in p2:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p2:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p2 or '.woff' in p2:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p2:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p2:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def layui1(request, p1):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/layui/", p1)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p1:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p1 or '.jpeg' in p1 or '.png' in p1 or '.gif' in p1:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p1:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p1 or '.woff' in p1:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p1:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p1:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def layui2(request, p1, p2):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/layui/", p1, p2)
print("layui2 path1========================>",path1)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p2:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p2 or '.jpeg' in p2 or '.png' in p2 or '.gif' in p2:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p2:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p2 or '.woff' in p2:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p2:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p2:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def layui3(request, p1, p2, p3):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/layui/", p1, p2, p3)
print("layui3 path1========================>",path1)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
#
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p3:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p3 or '.jpeg' in p3 or '.png' in p3 or '.gif' in p3:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p3:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p3 or '.woff' in p3:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p3:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p3:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def layui4(request, p1, p2, p3, p4):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/layui/", p1, p2, p3, p4)
print("layui4 path1========================>",path1)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p4:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p4 or '.jpeg' in p4 or '.png' in p4 or '.gif' in p4:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p4:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p4 or '.woff' in p4:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p4:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p4:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def pages1(request, p1):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/pages/", p1)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p1:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p1 or '.jpeg' in p1 or '.png' in p1 or '.gif' in p1:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p1:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p1 or '.woff' in p1:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p1:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p1:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def pages2(request, p1, p2):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/pages/", p1, p2)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p2:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p2 or '.jpeg' in p2 or '.png' in p2 or '.gif' in p2:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p2:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p2 or '.woff' in p2:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p2:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p2:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def front_file1(request, p1):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/", p1)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p1:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p1 or '.jpeg' in p1 or '.png' in p1 or '.gif' in p1:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p1:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p1 or '.woff' in p1:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p1:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p1:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def front_file2(request, p1, p2):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/", p1, p2)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p2:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p2 or '.jpeg' in p2 or '.png' in p2 or '.gif' in p2:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p2:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p2 or '.woff' in p2:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p2:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p2:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def schema_front1(request, p1):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/", p1)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p1:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p1 or '.jpeg' in p1 or '.png' in p1 or '.gif' in p1:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p1:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p1 or '.woff' in p1:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p1:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p1:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def schema_front2(request, p1, p2):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/", p1, p2)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p2:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p2 or '.jpeg' in p2 or '.png' in p2 or '.gif' in p2:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p2:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p2 or '.woff' in p2:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p2:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p2:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def schema_front3(request, p1, p2, p3):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/", p1, p2, p3)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p3:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p3 or '.jpeg' in p3 or '.png' in p3 or '.gif' in p3:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p3:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p3 or '.woff' in p3:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p3:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p3:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def schema_front4(request, p1, p2, p3, p4):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/", p1, p2, p3, p4)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p4:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p4 or '.jpeg' in p4 or '.png' in p4 or '.gif' in p4:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p4:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p4 or '.woff' in p4:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p4:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p4:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def assets1(request, p1):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/assets/", p1)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p1:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p1 or '.jpeg' in p1 or '.png' in p1 or '.gif' in p1:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p1:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p1 or '.woff' in p1:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p1:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p1:
# return HttpResponse(image_data, content_type="audio/mp3")
# elif '.map' in p1:
# return JsonResponse({})
# else:
# return HttpResponse(image_data, content_type="text/html")
def assets2(request, p1, p2):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/assets/", p1, p2)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p2:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p2 or '.jpeg' in p2 or '.png' in p2 or '.gif' in p2:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p2:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p2 or '.woff' in p2:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p2:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p2:
# return HttpResponse(image_data, content_type="audio/mp3")
# elif '.map' in p2:
# return JsonResponse({})
# else:
# return HttpResponse(image_data, content_type="text/html")
def assets3(request, p1, p2, p3):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/assets/", p1, p2, p3)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p3:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p3 or '.jpeg' in p3 or '.png' in p3 or '.gif' in p3:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p3:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p3 or '.woff' in p3:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p3:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p3:
# return HttpResponse(image_data, content_type="audio/mp3")
# elif '.map' in p3:
# return JsonResponse({})
# else:
# return HttpResponse(image_data, content_type="text/html")
def assets4(request, p1, p2, p3, p4):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/assets/", p1, p2, p3, p4)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p4:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p4 or '.jpeg' in p4 or '.png' in p4 or '.gif' in p4:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p4:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p4 or '.woff' in p4:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p4:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p4:
# return HttpResponse(image_data, content_type="audio/mp3")
# elif '.map' in p4:
# return JsonResponse({})
# else:
# return HttpResponse(image_data, content_type="text/html")
def css1(request, p1):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/css/", p1)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p1:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p1 or '.jpeg' in p1 or '.png' in p1 or '.gif' in p1:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p1:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p1 or '.woff' in p1:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p1:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p1:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def js1(request, p1):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/js/", p1)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p1:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p1 or '.jpeg' in p1 or '.png' in p1 or '.gif' in p1:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p1:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p1 or '.woff' in p1:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p1:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p1:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def img1(request, p1):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/img/", p1)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)
# try:
# image_data = open(path1, "rb").read()
# except:
# image_data="no file"
# if '.js' in p1:
# return HttpResponse(image_data, content_type="application/javascript")
# elif '.jpg' in p1 or '.jpeg' in p1 or '.png' in p1 or '.gif' in p1:
# return HttpResponse(image_data, content_type="image/png")
# elif '.css' in p1:
# return HttpResponse(image_data, content_type="text/css")
# elif '.ttf' in p1 or '.woff' in p1:
# return HttpResponse(image_data, content_type="application/octet-stream")
# elif '.mp4' in p1:
# return HttpResponse(image_data, content_type="video/mp4")
# elif '.mp3' in p1:
# return HttpResponse(image_data, content_type="audio/mp3")
# else:
# return HttpResponse(image_data, content_type="text/html")
def front_modules(request, p1):
if request.method in ["GET", "POST"]:
fullPath = request.get_full_path()
print("{}=============>".format(sys._getframe().f_code.co_name), fullPath)
path1 = os.path.join(os.getcwd(), "templates/front/modules/", p1)
return check_suffix(eval(eval(sys._getframe().f_code.co_name).__code__.co_varnames[-3]),path1)

@ -0,0 +1,16 @@
"""
WSGI config for dj2 project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dj2.settings")
application = get_wsgi_application()

@ -0,0 +1,53 @@
# coding:utf-8
# author:ila
import click,py_compile,os
from configparser import ConfigParser
from util.configread import config_read
from util.sqlinit import Create
@click.group()
def sub():
pass
@click.command()
def initdb(ini="config.ini"):
dbtype, host, port, user, passwd, dbName, charset = config_read(ini)
if dbtype == 'mysql':
cm = Create(dbtype, host, port, user, passwd, dbName, charset)
cm.create_db("CREATE DATABASE IF NOT EXISTS `{}` /*!40100 DEFAULT CHARACTER SET utf8 */ ;".format(dbName))
cm.conn_close()
elif dbtype == 'mssql':
cm = Create(dbtype, host, port, user, passwd, dbName, charset)
cm.create_db("CREATE DATABASE IF NOT EXISTS `{}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;".format(dbName))
cm.conn_close()
else:
print('请修改当前面目录下的config.ini文件')
@click.command()
def initsql(ini="config.ini"):
dbtype, host, port, user, passwd, dbName, charset = config_read(ini)
if dbtype == 'mysql':
cm = Create(dbtype, host, port, user, passwd, dbName, charset)
cm.create_db("CREATE DATABASE IF NOT EXISTS `{}` /*!40100 DEFAULT CHARACTER SET utf8 */ ;".format(dbName))
with open("./db/mysql.sql", encoding="utf8") as f:
createsql = f.read()
createsql = "DROP TABLE" + createsql.split('DROP TABLE', 1)[-1]
cm.create_tables(createsql.split(';')[:-1])
cm.conn_close()
elif dbtype == 'mssql':
cm = Create(dbtype, host, port, user, passwd, dbName, charset)
cm.create_db("CREATE DATABASE IF NOT EXISTS `{}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;".format(dbName))
with open("./db/mssql.sql", encoding="utf8") as f:
createsql = f.read()
createsql = "DROP TABLE" + createsql.split('DROP TABLE', 1)[-1]
cm.create_tables(createsql.split(';')[:-1])
cm.conn_close()
else:
print('请修改当前面目录下的config.ini文件')
sub.add_command(initdb,"initdb")
sub.add_command(initsql,"initsql")
if __name__ == "__main__":
sub()

@ -0,0 +1,522 @@
#coding:utf-8
__author__ = "ila"
import copy
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import dianyingfenlei
from util.codes import *
from util.auth import Auth
import util.message as mes
def dianyingfenlei_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = dianyingfenlei.createbyreq(dianyingfenlei, dianyingfenlei, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def dianyingfenlei_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = dianyingfenlei.getbyparams(dianyingfenlei, dianyingfenlei, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= dianyingfenlei.__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, dianyingfenlei, req_dict)
def dianyingfenlei_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def dianyingfenlei_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = dianyingfenlei.updatebyparams(dianyingfenlei,dianyingfenlei, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def dianyingfenlei_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'] = dianyingfenlei.getbyparams(dianyingfenlei, dianyingfenlei, req_dict)[0]
return JsonResponse(msg)
def dianyingfenlei_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=dianyingfenlei.getbyparams(dianyingfenlei, dianyingfenlei, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def dianyingfenlei_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= dianyingfenlei.getallcolumn( dianyingfenlei, dianyingfenlei)
#当前登录用户所在表
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__=dianyingfenlei.__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__=dianyingfenlei.__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 "userid" in dianyingfenlei.getallcolumn(dianyingfenlei,dianyingfenlei):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=dianyingfenlei.__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'] =dianyingfenlei.page(dianyingfenlei, dianyingfenlei, req_dict)
return JsonResponse(msg)
def dianyingfenlei_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 dianyingfenlei.getallcolumn(dianyingfenlei,dianyingfenlei):
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'] = dianyingfenlei.page(dianyingfenlei,dianyingfenlei, req_dict)
return JsonResponse(msg)
def dianyingfenlei_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= dianyingfenlei.getallcolumn( dianyingfenlei, dianyingfenlei)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=dianyingfenlei.__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__=dianyingfenlei.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=dianyingfenlei.__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__=dianyingfenlei.__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 dianyingfenlei.__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'] = dianyingfenlei.page(dianyingfenlei, dianyingfenlei, req_dict)
return JsonResponse(msg)
def dianyingfenlei_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= dianyingfenlei.getallcolumn( dianyingfenlei, dianyingfenlei)
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= dianyingfenlei.createbyreq(dianyingfenlei,dianyingfenlei, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def dianyingfenlei_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= dianyingfenlei.getallcolumn( dianyingfenlei, dianyingfenlei)
try:
__authSeparate__=dianyingfenlei.__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__=dianyingfenlei.__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= dianyingfenlei.createbyreq(dianyingfenlei,dianyingfenlei, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def dianyingfenlei_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=dianyingfenlei.getbyid(dianyingfenlei,dianyingfenlei,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 = dianyingfenlei.updatebyparams(dianyingfenlei,dianyingfenlei, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def dianyingfenlei_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = dianyingfenlei.getbyid(dianyingfenlei,dianyingfenlei, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= dianyingfenlei.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in dianyingfenlei.getallcolumn(dianyingfenlei,dianyingfenlei):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=dianyingfenlei.updatebyparams(dianyingfenlei,dianyingfenlei,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def dianyingfenlei_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =dianyingfenlei.getbyid(dianyingfenlei,dianyingfenlei, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= dianyingfenlei.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in dianyingfenlei.getallcolumn(dianyingfenlei,dianyingfenlei):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=dianyingfenlei.updatebyparams(dianyingfenlei,dianyingfenlei,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def dianyingfenlei_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 dianyingfenlei.getallcolumn(dianyingfenlei,dianyingfenlei) :
del req_dict["mima"]
if "password" not in dianyingfenlei.getallcolumn(dianyingfenlei,dianyingfenlei) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = dianyingfenlei.updatebyparams(dianyingfenlei, dianyingfenlei, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def dianyingfenlei_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=dianyingfenlei.deletes(dianyingfenlei,
dianyingfenlei,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def dianyingfenlei_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= dianyingfenlei.getbyid(dianyingfenlei, dianyingfenlei, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=dianyingfenlei.updatebyparams(dianyingfenlei,dianyingfenlei,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)

@ -0,0 +1,522 @@
#coding:utf-8
__author__ = "ila"
import copy
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import dianyingxinxi
from util.codes import *
from util.auth import Auth
import util.message as mes
def dianyingxinxi_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = dianyingxinxi.createbyreq(dianyingxinxi, dianyingxinxi, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def dianyingxinxi_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = dianyingxinxi.getbyparams(dianyingxinxi, dianyingxinxi, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= dianyingxinxi.__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, dianyingxinxi, req_dict)
def dianyingxinxi_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def dianyingxinxi_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = dianyingxinxi.updatebyparams(dianyingxinxi,dianyingxinxi, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def dianyingxinxi_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'] = dianyingxinxi.getbyparams(dianyingxinxi, dianyingxinxi, req_dict)[0]
return JsonResponse(msg)
def dianyingxinxi_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=dianyingxinxi.getbyparams(dianyingxinxi, dianyingxinxi, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def dianyingxinxi_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= dianyingxinxi.getallcolumn( dianyingxinxi, dianyingxinxi)
#当前登录用户所在表
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__=dianyingxinxi.__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__=dianyingxinxi.__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 "userid" in dianyingxinxi.getallcolumn(dianyingxinxi,dianyingxinxi):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=dianyingxinxi.__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'] =dianyingxinxi.page(dianyingxinxi, dianyingxinxi, req_dict)
return JsonResponse(msg)
def dianyingxinxi_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 dianyingxinxi.getallcolumn(dianyingxinxi,dianyingxinxi):
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'] = dianyingxinxi.page(dianyingxinxi,dianyingxinxi, req_dict)
return JsonResponse(msg)
def dianyingxinxi_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= dianyingxinxi.getallcolumn( dianyingxinxi, dianyingxinxi)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=dianyingxinxi.__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__=dianyingxinxi.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=dianyingxinxi.__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__=dianyingxinxi.__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 dianyingxinxi.__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'] = dianyingxinxi.page(dianyingxinxi, dianyingxinxi, req_dict)
return JsonResponse(msg)
def dianyingxinxi_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= dianyingxinxi.getallcolumn( dianyingxinxi, dianyingxinxi)
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= dianyingxinxi.createbyreq(dianyingxinxi,dianyingxinxi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def dianyingxinxi_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= dianyingxinxi.getallcolumn( dianyingxinxi, dianyingxinxi)
try:
__authSeparate__=dianyingxinxi.__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__=dianyingxinxi.__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= dianyingxinxi.createbyreq(dianyingxinxi,dianyingxinxi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def dianyingxinxi_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=dianyingxinxi.getbyid(dianyingxinxi,dianyingxinxi,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 = dianyingxinxi.updatebyparams(dianyingxinxi,dianyingxinxi, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def dianyingxinxi_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = dianyingxinxi.getbyid(dianyingxinxi,dianyingxinxi, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= dianyingxinxi.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in dianyingxinxi.getallcolumn(dianyingxinxi,dianyingxinxi):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=dianyingxinxi.updatebyparams(dianyingxinxi,dianyingxinxi,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def dianyingxinxi_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =dianyingxinxi.getbyid(dianyingxinxi,dianyingxinxi, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= dianyingxinxi.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in dianyingxinxi.getallcolumn(dianyingxinxi,dianyingxinxi):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=dianyingxinxi.updatebyparams(dianyingxinxi,dianyingxinxi,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def dianyingxinxi_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 dianyingxinxi.getallcolumn(dianyingxinxi,dianyingxinxi) :
del req_dict["mima"]
if "password" not in dianyingxinxi.getallcolumn(dianyingxinxi,dianyingxinxi) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = dianyingxinxi.updatebyparams(dianyingxinxi, dianyingxinxi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def dianyingxinxi_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=dianyingxinxi.deletes(dianyingxinxi,
dianyingxinxi,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def dianyingxinxi_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= dianyingxinxi.getbyid(dianyingxinxi, dianyingxinxi, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=dianyingxinxi.updatebyparams(dianyingxinxi,dianyingxinxi,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)

@ -0,0 +1,522 @@
#coding:utf-8
__author__ = "ila"
import copy
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import discussdianyingxinxi
from util.codes import *
from util.auth import Auth
import util.message as mes
def discussdianyingxinxi_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = discussdianyingxinxi.createbyreq(discussdianyingxinxi, discussdianyingxinxi, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def discussdianyingxinxi_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = discussdianyingxinxi.getbyparams(discussdianyingxinxi, discussdianyingxinxi, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= discussdianyingxinxi.__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, discussdianyingxinxi, req_dict)
def discussdianyingxinxi_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def discussdianyingxinxi_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = discussdianyingxinxi.updatebyparams(discussdianyingxinxi,discussdianyingxinxi, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def discussdianyingxinxi_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'] = discussdianyingxinxi.getbyparams(discussdianyingxinxi, discussdianyingxinxi, req_dict)[0]
return JsonResponse(msg)
def discussdianyingxinxi_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=discussdianyingxinxi.getbyparams(discussdianyingxinxi, discussdianyingxinxi, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def discussdianyingxinxi_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= discussdianyingxinxi.getallcolumn( discussdianyingxinxi, discussdianyingxinxi)
#当前登录用户所在表
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__=discussdianyingxinxi.__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__=discussdianyingxinxi.__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 "userid" in discussdianyingxinxi.getallcolumn(discussdianyingxinxi,discussdianyingxinxi):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=discussdianyingxinxi.__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'] =discussdianyingxinxi.page(discussdianyingxinxi, discussdianyingxinxi, req_dict)
return JsonResponse(msg)
def discussdianyingxinxi_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 discussdianyingxinxi.getallcolumn(discussdianyingxinxi,discussdianyingxinxi):
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'] = discussdianyingxinxi.page(discussdianyingxinxi,discussdianyingxinxi, req_dict)
return JsonResponse(msg)
def discussdianyingxinxi_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= discussdianyingxinxi.getallcolumn( discussdianyingxinxi, discussdianyingxinxi)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=discussdianyingxinxi.__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__=discussdianyingxinxi.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=discussdianyingxinxi.__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__=discussdianyingxinxi.__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 discussdianyingxinxi.__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'] = discussdianyingxinxi.page(discussdianyingxinxi, discussdianyingxinxi, req_dict)
return JsonResponse(msg)
def discussdianyingxinxi_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= discussdianyingxinxi.getallcolumn( discussdianyingxinxi, discussdianyingxinxi)
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= discussdianyingxinxi.createbyreq(discussdianyingxinxi,discussdianyingxinxi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def discussdianyingxinxi_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= discussdianyingxinxi.getallcolumn( discussdianyingxinxi, discussdianyingxinxi)
try:
__authSeparate__=discussdianyingxinxi.__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__=discussdianyingxinxi.__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= discussdianyingxinxi.createbyreq(discussdianyingxinxi,discussdianyingxinxi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def discussdianyingxinxi_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=discussdianyingxinxi.getbyid(discussdianyingxinxi,discussdianyingxinxi,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 = discussdianyingxinxi.updatebyparams(discussdianyingxinxi,discussdianyingxinxi, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def discussdianyingxinxi_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = discussdianyingxinxi.getbyid(discussdianyingxinxi,discussdianyingxinxi, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= discussdianyingxinxi.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in discussdianyingxinxi.getallcolumn(discussdianyingxinxi,discussdianyingxinxi):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=discussdianyingxinxi.updatebyparams(discussdianyingxinxi,discussdianyingxinxi,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def discussdianyingxinxi_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =discussdianyingxinxi.getbyid(discussdianyingxinxi,discussdianyingxinxi, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= discussdianyingxinxi.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in discussdianyingxinxi.getallcolumn(discussdianyingxinxi,discussdianyingxinxi):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=discussdianyingxinxi.updatebyparams(discussdianyingxinxi,discussdianyingxinxi,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def discussdianyingxinxi_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 discussdianyingxinxi.getallcolumn(discussdianyingxinxi,discussdianyingxinxi) :
del req_dict["mima"]
if "password" not in discussdianyingxinxi.getallcolumn(discussdianyingxinxi,discussdianyingxinxi) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = discussdianyingxinxi.updatebyparams(discussdianyingxinxi, discussdianyingxinxi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def discussdianyingxinxi_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=discussdianyingxinxi.deletes(discussdianyingxinxi,
discussdianyingxinxi,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def discussdianyingxinxi_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= discussdianyingxinxi.getbyid(discussdianyingxinxi, discussdianyingxinxi, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=discussdianyingxinxi.updatebyparams(discussdianyingxinxi,discussdianyingxinxi,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)

@ -0,0 +1,522 @@
#coding:utf-8
__author__ = "ila"
import copy
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import messages
from util.codes import *
from util.auth import Auth
import util.message as mes
def messages_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = messages.createbyreq(messages, messages, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def messages_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = messages.getbyparams(messages, messages, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= messages.__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, messages, req_dict)
def messages_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def messages_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = messages.updatebyparams(messages,messages, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def messages_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'] = messages.getbyparams(messages, messages, req_dict)[0]
return JsonResponse(msg)
def messages_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=messages.getbyparams(messages, messages, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def messages_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= messages.getallcolumn( messages, messages)
#当前登录用户所在表
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__=messages.__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__=messages.__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 "userid" in messages.getallcolumn(messages,messages):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=messages.__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'] =messages.page(messages, messages, req_dict)
return JsonResponse(msg)
def messages_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 messages.getallcolumn(messages,messages):
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'] = messages.page(messages,messages, req_dict)
return JsonResponse(msg)
def messages_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= messages.getallcolumn( messages, messages)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=messages.__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__=messages.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=messages.__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__=messages.__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 messages.__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'] = messages.page(messages, messages, req_dict)
return JsonResponse(msg)
def messages_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= messages.getallcolumn( messages, messages)
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= messages.createbyreq(messages,messages, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def messages_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= messages.getallcolumn( messages, messages)
try:
__authSeparate__=messages.__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__=messages.__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= messages.createbyreq(messages,messages, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def messages_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=messages.getbyid(messages,messages,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 = messages.updatebyparams(messages,messages, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def messages_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = messages.getbyid(messages,messages, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= messages.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in messages.getallcolumn(messages,messages):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=messages.updatebyparams(messages,messages,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def messages_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =messages.getbyid(messages,messages, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= messages.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in messages.getallcolumn(messages,messages):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=messages.updatebyparams(messages,messages,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def messages_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 messages.getallcolumn(messages,messages) :
del req_dict["mima"]
if "password" not in messages.getallcolumn(messages,messages) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = messages.updatebyparams(messages, messages, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def messages_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=messages.deletes(messages,
messages,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def messages_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= messages.getbyid(messages, messages, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=messages.updatebyparams(messages,messages,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)

@ -0,0 +1,522 @@
#coding:utf-8
__author__ = "ila"
import copy
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import news
from util.codes import *
from util.auth import Auth
import util.message as mes
def news_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = news.createbyreq(news, news, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def news_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = news.getbyparams(news, news, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= news.__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, news, req_dict)
def news_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def news_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = news.updatebyparams(news,news, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def news_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'] = news.getbyparams(news, news, req_dict)[0]
return JsonResponse(msg)
def news_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=news.getbyparams(news, news, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def news_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= news.getallcolumn( news, news)
#当前登录用户所在表
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__=news.__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__=news.__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 "userid" in news.getallcolumn(news,news):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=news.__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'] =news.page(news, news, req_dict)
return JsonResponse(msg)
def news_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 news.getallcolumn(news,news):
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'] = news.page(news,news, req_dict)
return JsonResponse(msg)
def news_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= news.getallcolumn( news, news)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=news.__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__=news.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=news.__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__=news.__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 news.__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'] = news.page(news, news, req_dict)
return JsonResponse(msg)
def news_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= news.getallcolumn( news, news)
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= news.createbyreq(news,news, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def news_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= news.getallcolumn( news, news)
try:
__authSeparate__=news.__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__=news.__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= news.createbyreq(news,news, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def news_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=news.getbyid(news,news,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 = news.updatebyparams(news,news, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def news_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = news.getbyid(news,news, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= news.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in news.getallcolumn(news,news):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=news.updatebyparams(news,news,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def news_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =news.getbyid(news,news, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= news.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in news.getallcolumn(news,news):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=news.updatebyparams(news,news,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def news_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 news.getallcolumn(news,news) :
del req_dict["mima"]
if "password" not in news.getallcolumn(news,news) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = news.updatebyparams(news, news, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def news_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=news.deletes(news,
news,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def news_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= news.getbyid(news, news, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=news.updatebyparams(news,news,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)

@ -0,0 +1,522 @@
#coding:utf-8
__author__ = "ila"
import copy
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import orders
from util.codes import *
from util.auth import Auth
import util.message as mes
def orders_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = orders.createbyreq(orders, orders, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def orders_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = orders.getbyparams(orders, orders, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= orders.__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, orders, req_dict)
def orders_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def orders_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = orders.updatebyparams(orders,orders, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def orders_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'] = orders.getbyparams(orders, orders, req_dict)[0]
return JsonResponse(msg)
def orders_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=orders.getbyparams(orders, orders, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def orders_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= orders.getallcolumn( orders, orders)
#当前登录用户所在表
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__=orders.__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__=orders.__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 "userid" in orders.getallcolumn(orders,orders):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=orders.__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'] =orders.page(orders, orders, req_dict)
return JsonResponse(msg)
def orders_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 orders.getallcolumn(orders,orders):
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'] = orders.page(orders,orders, req_dict)
return JsonResponse(msg)
def orders_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= orders.getallcolumn( orders, orders)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=orders.__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__=orders.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=orders.__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__=orders.__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 orders.__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'] = orders.page(orders, orders, req_dict)
return JsonResponse(msg)
def orders_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= orders.getallcolumn( orders, orders)
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= orders.createbyreq(orders,orders, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def orders_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= orders.getallcolumn( orders, orders)
try:
__authSeparate__=orders.__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__=orders.__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= orders.createbyreq(orders,orders, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def orders_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=orders.getbyid(orders,orders,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 = orders.updatebyparams(orders,orders, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def orders_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = orders.getbyid(orders,orders, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= orders.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in orders.getallcolumn(orders,orders):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=orders.updatebyparams(orders,orders,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def orders_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =orders.getbyid(orders,orders, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= orders.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in orders.getallcolumn(orders,orders):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=orders.updatebyparams(orders,orders,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def orders_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 orders.getallcolumn(orders,orders) :
del req_dict["mima"]
if "password" not in orders.getallcolumn(orders,orders) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = orders.updatebyparams(orders, orders, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def orders_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=orders.deletes(orders,
orders,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def orders_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= orders.getbyid(orders, orders, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=orders.updatebyparams(orders,orders,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)

@ -0,0 +1,522 @@
#coding:utf-8
__author__ = "ila"
import copy
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import storeup
from util.codes import *
from util.auth import Auth
import util.message as mes
def storeup_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = storeup.createbyreq(storeup, storeup, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def storeup_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = storeup.getbyparams(storeup, storeup, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= storeup.__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, storeup, req_dict)
def storeup_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def storeup_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = storeup.updatebyparams(storeup,storeup, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def storeup_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'] = storeup.getbyparams(storeup, storeup, req_dict)[0]
return JsonResponse(msg)
def storeup_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=storeup.getbyparams(storeup, storeup, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def storeup_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= storeup.getallcolumn( storeup, storeup)
#当前登录用户所在表
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__=storeup.__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__=storeup.__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 "userid" in storeup.getallcolumn(storeup,storeup):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=storeup.__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'] =storeup.page(storeup, storeup, req_dict)
return JsonResponse(msg)
def storeup_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 storeup.getallcolumn(storeup,storeup):
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'] = storeup.page(storeup,storeup, req_dict)
return JsonResponse(msg)
def storeup_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= storeup.getallcolumn( storeup, storeup)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=storeup.__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__=storeup.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=storeup.__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__=storeup.__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 storeup.__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'] = storeup.page(storeup, storeup, req_dict)
return JsonResponse(msg)
def storeup_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= storeup.getallcolumn( storeup, storeup)
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= storeup.createbyreq(storeup,storeup, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def storeup_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= storeup.getallcolumn( storeup, storeup)
try:
__authSeparate__=storeup.__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__=storeup.__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= storeup.createbyreq(storeup,storeup, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def storeup_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=storeup.getbyid(storeup,storeup,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 = storeup.updatebyparams(storeup,storeup, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def storeup_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = storeup.getbyid(storeup,storeup, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= storeup.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in storeup.getallcolumn(storeup,storeup):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=storeup.updatebyparams(storeup,storeup,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def storeup_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =storeup.getbyid(storeup,storeup, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= storeup.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in storeup.getallcolumn(storeup,storeup):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=storeup.updatebyparams(storeup,storeup,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def storeup_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 storeup.getallcolumn(storeup,storeup) :
del req_dict["mima"]
if "password" not in storeup.getallcolumn(storeup,storeup) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = storeup.updatebyparams(storeup, storeup, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def storeup_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=storeup.deletes(storeup,
storeup,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def storeup_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= storeup.getbyid(storeup, storeup, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=storeup.updatebyparams(storeup,storeup,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)

@ -0,0 +1,522 @@
#coding:utf-8
__author__ = "ila"
import copy
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import yonghu
from util.codes import *
from util.auth import Auth
import util.message as mes
def yonghu_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = yonghu.createbyreq(yonghu, yonghu, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def yonghu_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = yonghu.getbyparams(yonghu, yonghu, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= yonghu.__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, yonghu, req_dict)
def yonghu_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def yonghu_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = yonghu.updatebyparams(yonghu,yonghu, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def yonghu_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'] = yonghu.getbyparams(yonghu, yonghu, req_dict)[0]
return JsonResponse(msg)
def yonghu_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=yonghu.getbyparams(yonghu, yonghu, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def yonghu_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= yonghu.getallcolumn( yonghu, yonghu)
#当前登录用户所在表
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__=yonghu.__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__=yonghu.__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 "userid" in yonghu.getallcolumn(yonghu,yonghu):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=yonghu.__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'] =yonghu.page(yonghu, yonghu, req_dict)
return JsonResponse(msg)
def yonghu_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 yonghu.getallcolumn(yonghu,yonghu):
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'] = yonghu.page(yonghu,yonghu, req_dict)
return JsonResponse(msg)
def yonghu_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= yonghu.getallcolumn( yonghu, yonghu)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=yonghu.__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__=yonghu.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=yonghu.__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__=yonghu.__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 yonghu.__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'] = yonghu.page(yonghu, yonghu, req_dict)
return JsonResponse(msg)
def yonghu_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= yonghu.getallcolumn( yonghu, yonghu)
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= yonghu.createbyreq(yonghu,yonghu, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def yonghu_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= yonghu.getallcolumn( yonghu, yonghu)
try:
__authSeparate__=yonghu.__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__=yonghu.__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= yonghu.createbyreq(yonghu,yonghu, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def yonghu_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=yonghu.getbyid(yonghu,yonghu,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 = yonghu.updatebyparams(yonghu,yonghu, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def yonghu_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = yonghu.getbyid(yonghu,yonghu, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= yonghu.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in yonghu.getallcolumn(yonghu,yonghu):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=yonghu.updatebyparams(yonghu,yonghu,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def yonghu_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =yonghu.getbyid(yonghu,yonghu, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= yonghu.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in yonghu.getallcolumn(yonghu,yonghu):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=yonghu.updatebyparams(yonghu,yonghu,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def yonghu_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 yonghu.getallcolumn(yonghu,yonghu) :
del req_dict["mima"]
if "password" not in yonghu.getallcolumn(yonghu,yonghu) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = yonghu.updatebyparams(yonghu, yonghu, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def yonghu_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=yonghu.deletes(yonghu,
yonghu,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def yonghu_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= yonghu.getbyid(yonghu, yonghu, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=yonghu.updatebyparams(yonghu,yonghu,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)

@ -0,0 +1 @@
default_app_config = 'main.apps.MainConfig'

@ -0,0 +1,31 @@
from django.contrib import admin
from django.apps import apps, AppConfig
# Register your models here.
from dj2.settings import dbName as schemaName
from main.users_model import users
from main.config_model import config
try:
from main.models import *
except:
pass
# change title
admin.site.site_title = schemaName # 设置页面标题
admin.site.site_header = schemaName # 设置网站页头
admin.site.index_title = schemaName # 设置首页标语
allModels = apps.get_app_config('main').get_models()
for ind, model in enumerate(allModels):
class modelsite(admin.ModelAdmin):
list_display = []
for col in model._meta.fields:
list_display.append(col.name)
search_fields = list_display
admin.site.register(model, modelsite)

@ -0,0 +1,6 @@
from django.apps import AppConfig
class MainConfig(AppConfig):
name = 'main'
verbose_name = verbose_name_plural = r'刷表模块'

@ -0,0 +1,21 @@
# coding:utf-8
__author__ = "ila"
from django.db import models
from .model import BaseModel
class config(BaseModel):
# id=models.BigIntegerField(verbose_name="自增id")
name = models.CharField(max_length=100, verbose_name=u'键名')
value = models.CharField(max_length=100, verbose_name=u'键值')
__tablename__ = 'config'
class Meta:
db_table = 'config'
verbose_name = verbose_name_plural = u'配置表'
# def __str__(self):
# return self.name

@ -0,0 +1,131 @@
# coding:utf-8
__author__ = "ila"
import logging
from django.http import JsonResponse
from .config_model import config
from util.codes import *
from util import message as mes
def config_page(request):
'''
获取参数信息
:return:
'''
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')
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = config.page(config, config, req_dict)
return JsonResponse(msg)
def config_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")
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = config.page(config, config, req_dict)
return JsonResponse(msg)
def config_info(request, id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = config.getbyid(config, config, int(id_))
if len(data) > 0:
msg['data'] = data[0]
return JsonResponse(msg)
def config_detail(request, id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = config.getbyid(config, config, int(id_))
if len(data) > 0:
msg['data'] = data[0]
return JsonResponse(msg)
def config_save(request):
'''
创建参数信息
:return:
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get('req_dict')
param1 = config.getbyparams(config, config, req_dict)
if param1:
msg['code'] = id_exist_code
msg['msg'] = mes.id_exist_code
return JsonResponse(msg)
error = config.createbyreq(config, config, req_dict)
logging.warning("save_config.res=========>{}".format(error))
if error != None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def config_add(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
error = config.createbyreq(config, config, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def config_update(request):
'''
更新参数信息
:return:
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get('req_dict')
config.updatebyparams(config, config, req_dict)
return JsonResponse(msg)
def config_delete(request):
'''
删除参数信息
:return:
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get('req_dict')
config.deletes(config,
config,
req_dict.get("ids")
)
return JsonResponse(msg)

@ -0,0 +1,647 @@
# 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:
'''
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 = None, None
print(params)
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]
# __authSeparate__此属性为真params添加userid只查询个人数据
# try:
# __authSeparate__ = model.__authSeparate__
# except:
# __authSeparate__ = None
# #所有属性为"是"时才有效
# if __authSeparate__=='是':
# request = get_current_request()
# params["userid"] = request.session.get("params").get("id")
if sort != None or __sort__ != None:
if sort == None:
sort = __sort__
if order=='desc':
# 传参判断,需要逆序
datas = model.objects.filter(
**params
).order_by("-{}".format(sort)).all()
else:
# 传参无逆序要求
datas = model.objects.filter(
**params
).order_by("{}".format(sort)).all()
else:
datas = model.objects.filter(
**params
).all()
p = Paginator(datas, int(limit))
try:
p2 = p.page(int(page))
datas = p2.object_list
except:
datas=[]
pages = p.num_pages
try:
data = self.to_list(datas, datas)
except Exception as e:
print(Exception, ":", e)
data = []
newData = []
if fuzzy_key is None:
newData = data
total = p.count
else:
total = 0
for i in data:
for k, v in i.items():
if k == fuzzy_key and fuzzy_val in v:
newData.append(i)
total+=1
# __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
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,276 @@
#coding:utf-8
__author__ = "ila"
from django.db import models
from .model import BaseModel
from datetime import datetime
class yonghu(BaseModel):
__doc__ = u'''yonghu'''
__tablename__ = 'yonghu'
__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=True, unique=False, verbose_name='姓名' )
nianling=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='照片' )
sfsh=models.CharField ( max_length=255, null=True, unique=False,default='', verbose_name='是否审核' )
shhf=models.TextField ( null=True, unique=False, verbose_name='审核回复' )
money=models.FloatField ( null=True, unique=False,default='0', verbose_name='余额' )
'''
zhanghao=VARCHAR
mima=VARCHAR
xingming=VARCHAR
nianling=VARCHAR
xingbie=VARCHAR
shouji=VARCHAR
zhaopian=VARCHAR
sfsh=VARCHAR
shhf=Text
money=Float
'''
class Meta:
db_table = 'yonghu'
verbose_name = verbose_name_plural = '用户'
class dianyingxinxi(BaseModel):
__doc__ = u'''dianyingxinxi'''
__tablename__ = 'dianyingxinxi'
__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'创建时间')
dianyingmingcheng=models.CharField ( max_length=255,null=False, unique=False, verbose_name='电影名称' )
dianyingfenlei=models.CharField ( max_length=255, null=True, unique=False, verbose_name='电影分类' )
dianyinghaibao=models.CharField ( max_length=255, null=True, unique=False, verbose_name='电影海报' )
daoyan=models.CharField ( max_length=255, null=True, unique=False, verbose_name='导演' )
yanyuan=models.CharField ( max_length=255, null=True, unique=False, verbose_name='演员' )
shangyingriqi=models.DateField ( null=True, unique=False, verbose_name='上映日期' )
fangyingchangci=models.CharField ( max_length=255, null=True, unique=False, verbose_name='放映场次' )
fangyingshijian=models.CharField ( max_length=255, null=True, unique=False, verbose_name='放映时间' )
fangyingting=models.CharField ( max_length=255, null=True, unique=False, verbose_name='放映厅' )
yingyuanmingcheng=models.CharField ( max_length=255, null=True, unique=False, verbose_name='影院名称' )
yingyuandizhi=models.CharField ( max_length=255, null=True, unique=False, verbose_name='影院地址' )
dianyingjieshao=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='点击次数' )
price=models.FloatField ( null=False, unique=False, verbose_name='价格' )
number=models.IntegerField ( null=False, unique=False, verbose_name='座位总数' )
selected=models.TextField ( null=True, unique=False, verbose_name='已选座位[用,号隔开]' )
'''
dianyingmingcheng=VARCHAR
dianyingfenlei=VARCHAR
dianyinghaibao=VARCHAR
daoyan=VARCHAR
yanyuan=VARCHAR
shangyingriqi=Date
fangyingchangci=VARCHAR
fangyingshijian=VARCHAR
fangyingting=VARCHAR
yingyuanmingcheng=VARCHAR
yingyuandizhi=VARCHAR
dianyingjieshao=Text
thumbsupnum=Integer
crazilynum=Integer
clicktime=DateTime
clicknum=Integer
price=Float
number=Integer
selected=Text
'''
class Meta:
db_table = 'dianyingxinxi'
verbose_name = verbose_name_plural = '电影信息'
class dianyingfenlei(BaseModel):
__doc__ = u'''dianyingfenlei'''
__tablename__ = 'dianyingfenlei'
__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'创建时间')
dianyingfenlei=models.CharField ( max_length=255, null=True, unique=False, verbose_name='电影分类' )
'''
dianyingfenlei=VARCHAR
'''
class Meta:
db_table = 'dianyingfenlei'
verbose_name = verbose_name_plural = '电影分类'
class orders(BaseModel):
__doc__ = u'''orders'''
__tablename__ = 'orders'
__authTables__={}
__authSeparate__=''#后台列表权限
addtime = models.DateTimeField(auto_now_add=False, verbose_name=u'创建时间')
orderid=models.CharField ( max_length=255,null=False,unique=True, verbose_name='订单编号' )
tablename=models.CharField ( max_length=255, null=True, unique=False,default='dianyingxinxi', verbose_name='商品表名' )
userid=models.BigIntegerField ( null=False, unique=False, verbose_name='用户id' )
goodid=models.BigIntegerField ( null=False, unique=False, verbose_name='商品id' )
goodname=models.CharField ( max_length=255, null=True, unique=False, verbose_name='商品名称' )
picture=models.CharField ( max_length=255, null=True, unique=False, verbose_name='商品图片' )
buynumber=models.IntegerField ( null=False, unique=False, verbose_name='购买数量' )
price=models.FloatField ( null=False, unique=False,default='0', verbose_name='价格/积分' )
discountprice=models.FloatField ( null=True, unique=False,default='0', verbose_name='折扣价格' )
total=models.FloatField ( null=False, unique=False,default='0', verbose_name='总价格/总积分' )
discounttotal=models.FloatField ( null=True, unique=False,default='0', verbose_name='折扣总价格' )
type=models.IntegerField ( null=True, unique=False,default='1', verbose_name='支付类型' )
status=models.CharField ( max_length=255, null=True, unique=False, verbose_name='状态' )
address=models.CharField ( max_length=255, null=True, unique=False, verbose_name='地址' )
tel=models.CharField ( max_length=255, null=True, unique=False, verbose_name='电话' )
consignee=models.CharField ( max_length=255, null=True, unique=False, verbose_name='收货人' )
'''
orderid=VARCHAR
tablename=VARCHAR
userid=BigInteger
goodid=BigInteger
goodname=VARCHAR
picture=VARCHAR
buynumber=Integer
price=Float
discountprice=Float
total=Float
discounttotal=Float
type=Integer
status=VARCHAR
address=VARCHAR
tel=VARCHAR
consignee=VARCHAR
'''
class Meta:
db_table = 'orders'
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='收藏图片' )
'''
userid=BigInteger
refid=BigInteger
tablename=VARCHAR
name=VARCHAR
picture=VARCHAR
'''
class Meta:
db_table = 'storeup'
verbose_name = verbose_name_plural = '收藏表'
class news(BaseModel):
__doc__ = u'''news'''
__tablename__ = 'news'
__authTables__={}
addtime = models.DateTimeField(auto_now_add=False, verbose_name=u'创建时间')
title=models.CharField ( max_length=255,null=False, unique=False, verbose_name='标题' )
introduction=models.TextField ( null=True, unique=False, verbose_name='简介' )
picture=models.CharField ( max_length=255,null=False, unique=False, verbose_name='图片' )
content=models.TextField ( null=False, unique=False, verbose_name='内容' )
'''
title=VARCHAR
introduction=Text
picture=VARCHAR
content=Text
'''
class Meta:
db_table = 'news'
verbose_name = verbose_name_plural = '影视资讯'
class messages(BaseModel):
__doc__ = u'''messages'''
__tablename__ = 'messages'
__authTables__={}
__hasMessage__=''#表属性hasMessage为是新增留言板表messages,字段content内容userid用户id
__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' )
username=models.CharField ( max_length=255, null=True, unique=False, verbose_name='用户名' )
content=models.TextField ( null=False, unique=False, verbose_name='留言内容' )
reply=models.TextField ( null=True, unique=False, verbose_name='回复内容' )
'''
userid=BigInteger
username=VARCHAR
content=Text
reply=Text
'''
class Meta:
db_table = 'messages'
verbose_name = verbose_name_plural = '留言板'
class discussdianyingxinxi(BaseModel):
__doc__ = u'''discussdianyingxinxi'''
__tablename__ = 'discussdianyingxinxi'
__authTables__={}
addtime = models.DateTimeField(auto_now_add=False, verbose_name=u'创建时间')
refid=models.BigIntegerField ( null=False, unique=False, verbose_name='关联表id' )
userid=models.BigIntegerField ( null=False, unique=False, verbose_name='用户id' )
nickname=models.CharField ( max_length=255, null=True, unique=False, verbose_name='用户名' )
content=models.TextField ( null=False, unique=False, verbose_name='评论内容' )
reply=models.TextField ( null=True, unique=False, verbose_name='回复内容' )
'''
refid=BigInteger
userid=BigInteger
nickname=VARCHAR
content=Text
reply=Text
'''
class Meta:
db_table = 'discussdianyingxinxi'
verbose_name = verbose_name_plural = '电影信息评论表'

@ -0,0 +1,499 @@
# coding:utf-8
__author__ = "ila"
import logging, os, time
from django.http import JsonResponse
from django.apps import apps
from wsgiref.util import FileWrapper
from django.http import HttpResponse,HttpResponseRedirect
from django.shortcuts import redirect
from .config_model import config
from util.codes import *
from util import message as mes
from util.baidubce_api import BaiDuBce
from util.locate import geocoding
from dj2.settings import dbName as schemaName
def schemaName_cal(request, tableName, columnName):
'''
计算规则接口
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, 'data': []}
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__ == tableName:
data = m.getcomputedbycolumn(
m,
m,
columnName
)
print(data)
if data:
try:
sum='%.05f' % float(data.get("sum"))
except:
sum=0.00
try:
max='%.05f' % float(data.get("max"))
except:
max=0.00
try:
min='%.05f' % float(data.get("min"))
except:
min=0.00
try:
avg='%.05f' % float(data.get("avg"))
except:
avg=0.00
msg['data'] = {
"sum": sum,
"max": max,
"min": min,
"avg": avg,
}
break
return JsonResponse(msg)
def schemaName_file_upload(request):
'''
上传
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
file = request.FILES.get("file")
if file:
filename = file.name
filesuffix = filename.split(".")[-1]
file_name = "{}.{}".format(int(float(time.time()) * 1000), filesuffix)
filePath = os.path.join(os.getcwd(), "templates/front", file_name)
print("filePath===========>", filePath)
with open(filePath, 'wb+') as destination:
for chunk in file.chunks():
destination.write(chunk)
msg["file"] = file_name
# 判断是否需要保存为人脸识别基础照片
req_dict = request.session.get("req_dict")
type1 = req_dict.get("type", 0)
print("type1=======>",type1)
type1 = int(type1)
if type1 == 1:
params = {"name":"faceFile","value": file_name}
config.createbyreq(config, config, params)
return JsonResponse(msg)
def schemaName_file_download(request):
'''
下载
'''
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
filename = req_dict.get("fileName")
filePath = os.path.join(os.getcwd(), "templates/front", filename)
print("filePath===========>", filePath)
file = open(filePath, 'rb')
response = HttpResponse(file)
response['Content-Type'] = 'text/plain'
response['Content-Disposition'] = 'attachment; filename=%s' % os.path.basename(filePath)
response['Content-Length'] = os.path.getsize(filePath)
return response
def schemaName_follow_level(request, tableName, columnName, level, parent):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, 'data': []}
# 组合查询参数
params = {
"level": level,
"parent": parent
}
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__ == tableName:
data = m.getbyparams(
m,
m,
params
)
# 只需要此列的数据
for i in data:
msg['data'].append(i.get(columnName))
break
return JsonResponse(msg)
def schemaName_follow(request, tableName, columnName):
'''
根据option字段值获取某表的单行记录接口
组合columnName和columnValue成dict传入查询方法
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, 'data': []}
# 组合查询参数
params = request.session.get('req_dict')
columnValue = params.get("columnValue")
params = {columnName: columnValue}
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__ == tableName:
data = m.getbyparams(
m,
m,
params
)
if len(data)>0:
msg['data'] = data[0]
break
return JsonResponse(msg)
def schemaName_location(request):
'''
定位
:return:
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "address": ''}
req_dict = request.session.get('req_dict')
datas = config.getbyparams(config, config, {"name": "baidu_ditu_ak"})
if len(datas) > 0:
baidu_ditu_ak = datas[0].get("baidu_ditu_ak")
else:
baidu_ditu_ak = 'QvMZVORsL7sGzPyTf5ZhawntyjiWYCif'
lat = req_dict.get("lat", 24.2943350100)
lon = req_dict.get("lng", 116.1287866600)
msg['address'] = geocoding(baidu_ditu_ak, lat, lon)
return JsonResponse(msg)
def schemaName_matchface(request):
'''
baidubce百度人脸识别
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code}
req_dict = request.session.get("req_dict")
face1 = req_dict.get("face1")
file_path1 = os.path.join(os.getcwd(),"templates/front",face1)
face2 = req_dict.get("face1")
file_path2 = os.path.join(os.getcwd(), "templates/front", face2)
data = config.getbyparams(config, config, {"name": "APIKey"})
client_id = data[0].get("APIKey")
data = config.getbyparams(config, config, {"name": "SecretKey"})
client_secret = data[0].get("SecretKey")
bdb = BaiDuBce()
score = bdb.bd_check2pic(client_id, client_secret, file_path1, file_path2)
msg['score'] = score
return JsonResponse(msg)
def schemaName_option(request, tableName, columnName):
'''
获取某表的某个字段列表接口
:param request:
:param tableName:
:param columnName:
:return:
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, 'data': []}
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__ == tableName:
data = m.getbyColumn(
m,
m,
columnName
)
msg['data'] = data
break
return JsonResponse(msg)
def schemaName_remind_tablename_columnname_type(request, tableName, columnName, type)->int:
'''
前台提醒接口通用接口不需要登陆
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, 'data': []}
# 组合查询参数
params = request.session.get("req_dict")
remindstart = int(params.get('remindstart')) if params.get('remindstart') != None else None
remindend = int(params.get('remindend')) if params.get('remindend') != None else None
if int(type) == 1: # 数字
if remindstart == None and remindend != None:
params['remindstart'] = 0
elif remindstart != None and remindend == None:
params['remindend'] = 999999
elif remindstart == None and remindend == None:
params['remindstart'] = 0
params['remindend'] = 999999
elif int(type) == 2: # 日期
current_time = int(time.time())
if remindstart == None and remindend != None:
starttime = current_time - 60 * 60 * 24 * 365 * 2
params['remindstart'] = time.strftime("%Y-%m-%d", time.localtime(starttime))
endtime = current_time + 60 * 60 * 24 * remindend
params['remindend'] = time.strftime("%Y-%m-%d", time.localtime(endtime))
elif remindstart != None and remindend == None:
starttime = current_time - 60 * 60 * 24 * remindstart
params['remindstart'] = time.strftime("%Y-%m-%d", time.localtime(starttime))
endtime = current_time + 60 * 60 * 24 * 365 * 2
params['remindend'] = time.strftime("%Y-%m-%d", time.localtime(endtime))
elif remindstart == None and remindend == None:
starttime = current_time - 60 * 60 * 24 * 365 * 2
params['remindstart'] = time.strftime("%Y-%m-%d", time.localtime(starttime))
endtime = current_time + 60 * 60 * 24 * 365 * 2
params['remindend'] = time.strftime("%Y-%m-%d", time.localtime(endtime))
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__ == tableName:
data = m.getbetweenparams(
m,
m,
columnName,
params
)
msg['count'] = len(data)
break
return JsonResponse(msg)
def schemaName_tablename_remind_columnname_type(request, tableName, columnName, type):
'''
后台提醒接口判断authSeparate和authTable的权限
'''
if request.method in ["POST", "GET"]:
print("schemaName_tablename_remind_columnname_type==============>")
msg = {"code": normal_code, 'data': []}
req_dict = request.session.get("req_dict")
remindstart = int(req_dict.get('remindstart')) if req_dict.get('remindstart')!=None else None
remindend = int(req_dict.get('remindend')) if req_dict.get('remindend')!=None else None
print("req_dict===================>",req_dict)
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__ == tableName:
tableModel=m
break
# 获取全部列名
columns = tableModel.getallcolumn(tableModel, tableModel)
# 当前登录用户所在表
tablename = request.session.get("tablename")
# 当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__ =tableModel.__authTables__
except:
__authTables__ = {}
if __authTables__ != {}:
for authColumn, authTable in __authTables__.items():
if authTable == tablename:
params = request.session.get("params")
req_dict[authColumn] = params.get(authColumn)
break
'''__authSeparate__此属性为真params添加userid后台只查询个人数据'''
try:
__authSeparate__ =tableModel.__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
# 组合查询参数
if int(type) == 1: # 数字
if remindstart == None and remindend != None:
req_dict['remindstart'] = 0
elif remindstart != None and remindend == None:
req_dict['remindend'] = 999999
elif remindstart == None and remindend == None:
req_dict['remindstart'] = 0
req_dict['remindend'] = 999999
elif int(type) == 2: # 日期
current_time = int(time.time())
if remindstart == None and remindend != None:
starttime = current_time - 60 * 60 * 24 * 365 * 2
req_dict['remindstart'] = time.strftime("%Y-%m-%d", time.localtime(starttime))
endtime = current_time + 60 * 60 * 24 * remindend
req_dict['remindend'] = time.strftime("%Y-%m-%d", time.localtime(endtime))
elif remindstart != None and remindend == None:
starttime = current_time - 60 * 60 * 24 * remindstart
req_dict['remindstart'] = time.strftime("%Y-%m-%d", time.localtime(starttime))
endtime = current_time + 60 * 60 * 24 * 365 * 2
req_dict['remindend'] = time.strftime("%Y-%m-%d", time.localtime(endtime))
elif remindstart == None and remindend == None:
starttime = current_time - 60 * 60 * 24 * 365 * 2
req_dict['remindstart'] = time.strftime("%Y-%m-%d", time.localtime(starttime))
endtime = current_time + 60 * 60 * 24 * 365 * 2
req_dict['remindend'] = time.strftime("%Y-%m-%d", time.localtime(endtime))
else:
starttime = current_time - 60 * 60 * 24 * remindstart
req_dict['remindstart'] = time.strftime("%Y-%m-%d", time.localtime(starttime))
endtime = current_time + 60 * 60 * 24 * remindend
req_dict['remindend'] = time.strftime("%Y-%m-%d", time.localtime(endtime))
print("req_dict==============>",req_dict)
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__ == tableName:
data = m.getbetweenparams(
m,
m,
columnName,
req_dict
)
msg['count'] = len(data)
break
return JsonResponse(msg)
def schemaName_sh(request, tableName):
'''
根据主键id修改table表的sfsh状态接口
'''
if request.method in ["POST", "GET"]:
print('tableName=========>', tableName)
msg = {"code": normal_code, "msg": "成功", "data": {}}
req_dict = request.session.get("req_dict")
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__ == tableName:
# 查询结果
data1 = m.getbyid(
m,
m,
req_dict.get('id')
)
if data1[0].get("sfsh") == '':
req_dict['sfsh'] = ''
else:
req_dict['sfsh'] = ''
# 更新
res = m.updatebyparams(
m,
m,
req_dict
)
# logging.warning("schemaName_sh.res=====>{}".format(res))
if res!=None:
msg["code"]=crud_error_code
msg["code"]=mes.crud_error_code
break
return JsonResponse(msg)
def schemaName_upload(request, fileName):
'''
'''
if request.method in ["POST", "GET"]:
return HttpResponseRedirect ("/{}/front/{}".format(schemaName,fileName))
def schemaName_group_quyu(request, tableName, columnName):
'''
{
"code": 0,
"data": [
{
"total": 2,
"shangpinleibie": "水果"
},
{
"total": 1,
"shangpinleibie": "蔬菜"
}
]
}
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__ == tableName:
msg['data'] = m.groupbycolumnname(
m,
m,
columnName
)
break
return JsonResponse(msg)
def schemaName_value_quyu(request, tableName, xColumnName, yColumnName):
'''
按值统计接口,
{
"code": 0,
"data": [
{
"total": 10.0,
"shangpinleibie": "aa"
},
{
"total": 20.0,
"shangpinleibie": "bb"
},
{
"total": 15.0,
"shangpinleibie": "cc"
}
]
}
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__ == tableName:
msg['data'] = m.getvaluebyxycolumnname(
m,
m,
xColumnName,
yColumnName
)
break
return JsonResponse(msg)

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

@ -0,0 +1,148 @@
# coding:utf-8
__author__ = "ila"
import os
from django.urls import path
from main import users_v, config_v, schema_v
# from dj2.settings import dbName as schemaName
# url规则列表
urlpatterns = [
path(r'users/register', users_v.users_register),
path(r'users/login', users_v.users_login),
path(r'users/logout', users_v.users_logout),
path(r'users/session', users_v.users_session),
path(r'users/page', users_v.users_page),
path(r'users/save', users_v.users_save),
path(r'users/info/<id_>', users_v.users_info),
path(r'users/update', users_v.users_update),
path(r'users/delete', users_v.users_delete),
path(r'config/page', config_v.config_page),
path(r'config/list', config_v.config_list),
path(r'config/save', config_v.config_save),
path(r'config/add', config_v.config_add),
path(r'config/info/<id_>', config_v.config_info),
path(r'config/detail/<id_>', config_v.config_detail),
path(r'config/update', config_v.config_update),
path(r'config/delete', config_v.config_delete),
]
# main app的路径
mainDir = os.path.join(os.getcwd(), "main")
# 过滤文件的列表
excludeList = [
"schema_v.py",
"users_v.py",
"config_v.py",
]
# 循环当前目录下的py文件
view_tuple = set()
for i in os.listdir(mainDir):
if i not in excludeList and i[-5:] == "_v.py":
viewName = i[:-3] # 去掉.py后缀字符串
view_tuple.add("from main import {}".format(viewName))
# 组合成import字符串
import_str = '\n'.join(view_tuple)
# print(import_str)
exec(import_str)
for i in os.listdir(mainDir):
if i not in excludeList and i[-5:] == "_v.py":
tableName = i[:-5]
tableName = tableName.replace(" ", "").strip()
print("tableName============>", tableName, len(tableName))
urlpatterns.extend(
[
path(r'{}/register'.format(tableName.lower()),
eval("{}_v.{}_register".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/login'.format(tableName.lower()),
eval("{}_v.{}_login".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/logout'.format(tableName.lower()),
eval("{}_v.{}_logout".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/resetPass'.format(tableName.lower()),
eval("{}_v.{}_resetPass".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/session'.format(tableName.lower()),
eval("{}_v.{}_session".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/default'.format(tableName.lower()),
eval("{}_v.{}_default".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/page'.format(tableName.lower()),
eval("{}_v.{}_page".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/autoSort'.format(tableName.lower()),
eval("{}_v.{}_autoSort".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/save'.format(tableName.lower()),
eval("{}_v.{}_save".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/add'.format(tableName.lower()),
eval("{}_v.{}_add".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/thumbsup/<id_>'.format(tableName.lower()),
eval("{}_v.{}_thumbsup".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/info/<id_>'.format(tableName.lower()),
eval("{}_v.{}_info".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/detail/<id_>'.format(tableName.lower()),
eval("{}_v.{}_detail".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/update'.format(tableName.lower()),
eval("{}_v.{}_update".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/delete'.format(tableName.lower()),
eval("{}_v.{}_delete".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/vote/<id_>'.format(tableName.lower()),
eval("{}_v.{}_vote".format(tableName.capitalize(), tableName.lower()))),
]
)
# examrecord特定接口
if tableName.lower() == "examrecord":
urlpatterns.extend(
[
path(r'{}/groupby'.format(tableName.lower()),
eval("{}_v.{}_groupby".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/deleteRecords'.format(tableName.lower()),
eval("{}_v.{}_deleterecords".format(tableName.capitalize(), tableName.lower()))),
]
)
# forum特定接口
if tableName.lower() == "forum":
urlpatterns.extend(
[
path(r'{}/flist'.format(tableName.lower()),
eval("{}_v.{}_flist".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/list/<id_>'.format(tableName.lower()),
eval("{}_v.{}_list_id".format(tableName.capitalize(), tableName.lower()))),
]
)
else:
urlpatterns.extend(
[
path(r'{}/list'.format(tableName.lower()),
eval("{}_v.{}_list".format(tableName.capitalize(), tableName.lower()))),
]
)
urlpatterns.extend(
[
path(r'cal/<str:tableName>/<str:columnName>', schema_v.schemaName_cal),
path(r'file/download', schema_v.schemaName_file_download),
path(r'file/upload', schema_v.schemaName_file_upload),
path(r'follow/<tableName>/<columnName>/<level>/<parent>', schema_v.schemaName_follow_level),
path(r'follow/<tableName>/<columnName>', schema_v.schemaName_follow),
path(r'location', schema_v.schemaName_location),
path(r'matchFace', schema_v.schemaName_matchface),
path(r'option/<tableName>/<columnName>', schema_v.schemaName_option),
path(r'remind/<tableName>/<columnName>/<type>', schema_v.schemaName_remind_tablename_columnname_type),
# 前台提醒接口(通用接口,不需要登陆)
path(r'<tableName>/remind/<columnName>/<type>', schema_v.schemaName_tablename_remind_columnname_type),
# 后台提醒接口 (每个表的单独接口,需登录)
path(r'sh/<tableName>', schema_v.schemaName_sh),
path(r'upload/<fileName>', schema_v.schemaName_upload),
path(r'group/<tableName>/<columnName>', schema_v.schemaName_group_quyu),
path(r'value/<tableName>/<xColumnName>/<yColumnName>', schema_v.schemaName_value_quyu),
]
)
# print(urlpatterns)

@ -0,0 +1,22 @@
# coding:utf-8
__author__ = "ila"
from django.db import models
from .model import BaseModel
class users(BaseModel):
# id=models.BigIntegerField(verbose_name="自增id")
username = models.CharField(max_length=100, verbose_name=u'账号')
password = models.CharField(max_length=100, verbose_name=u'密码')
role = models.CharField(max_length=100, verbose_name=u'角色')
addtime = models.DateTimeField(auto_now_add=False, verbose_name=u'创建时间')
__tablename__ = 'users'
class Meta:
db_table = 'users'
verbose_name = verbose_name_plural = u'管理员表'
# def __str__(self):
# return self.username

@ -0,0 +1,161 @@
# coding:utf-8
__author__ = "ila"
from django.http import JsonResponse
from .users_model import users
from util.codes import *
from util.auth import Auth
import util.message as mes
def users_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
if req_dict.get('role')!=None:
del req_dict['role']
datas = users.getbyparams(users, users, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
req_dict['id'] = datas[0].get('id')
return Auth.authenticate(Auth, users, req_dict)
def users_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = users.createbyreq(users, users, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def users_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'] = users.getbyparams(users, users, req_dict)[0]
return JsonResponse(msg)
def users_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "退出成功",
"code": 0
}
return JsonResponse(msg)
def users_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")
tablename = request.session.get("tablename")
try:
__hasMessage__ = users.__hasMessage__
except:
__hasMessage__ = None
if __hasMessage__ and __hasMessage__ != "":
if tablename != "users":
req_dict["userid"] = request.session.get("params").get("id")
if tablename == "users":
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = users.page(users, users, req_dict)
else:
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = [],1,0,0,10
return JsonResponse(msg)
def users_info(request, id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = users.getbyid(users, users, int(id_))
if len(data) > 0:
msg['data'] = data[0]
# 浏览点击次数
try:
__browseClick__ = users.__browseClick__
except:
__browseClick__ = None
if __browseClick__ and "clicknum" in users.getallcolumn(users, users):
click_dict = {"id": int(id_), "clicknum": str(int(data[0].get("clicknum", 0)) + 1)}
ret = users.updatebyparams(users, users, click_dict)
if ret != None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def users_save(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
error = users.createbyreq(users, users, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def users_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 users.getallcolumn(users,users):
del req_dict["mima"]
if "password" not in users.getallcolumn(users,users):
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = users.updatebyparams(users, users, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def users_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 = users.deletes(users,
users,
req_dict.get("ids")
)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

@ -0,0 +1,15 @@
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dj2.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)

@ -0,0 +1,5 @@
django==2.0
django-threadlocals
pymysql
click
requests

@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

@ -0,0 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="./favicon.ico"><title>后台管理系统</title><link href="./css/app.ad7aa8d1.css" rel="preload" as="style"><link href="./css/chunk-vendors.a72b0961.css" rel="preload" as="style"><link href="./js/app.a3379f68.js" rel="preload" as="script"><link href="./js/chunk-vendors.27201129.js" rel="preload" as="script"><link href="./css/chunk-vendors.a72b0961.css" rel="stylesheet"><link href="./css/app.ad7aa8d1.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but mas-creator-admin doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="./js/chunk-vendors.27201129.js"></script><script src="./js/app.a3379f68.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1,62 @@
{
"name": "mas-creator-admin",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^0.19.2",
"core-js": "^3.4.4",
"echarts": "^4.6.0",
"element-ui": "^2.13.0",
"js-md5": "^0.7.3",
"print-js": "^1.5.0",
"vue": "^2.6.10",
"vue-quill-editor": "^3.0.6",
"vue-amap": "^0.5.10",
"vue-json-excel": "^0.3.0",
"vue-router": "^3.1.5"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.1.0",
"@vue/cli-plugin-eslint": "^4.1.0",
"@vue/cli-service": "^4.1.0",
"babel-eslint": "^10.0.3",
"babel-plugin-component": "^1.1.1",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"node-sass": "^4.13.1",
"sass-loader": "^8.0.2",
"svg-sprite-loader": "4.1.3",
"svgo": "1.2.2",
"vue-template-compiler": "^2.6.10"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {
"no-console": "off",
"no-unused-vars": 0,
"no-useless-escape": "off"
},
"parserOptions": {
"parser": "babel-eslint"
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8",
"Android >= 4.0"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>后台管理系统</title>
</head>
<body>
<noscript>
<strong>We're sorry but mas-creator-admin doesn't work properly without JavaScript enabled. Please enable it to
continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

@ -0,0 +1,30 @@
<template>
<div id="app" class="">
<router-view></router-view>
</div>
</template>
<script>
export default {
name: "app",
};
</script>
<style lang="scss">
*{
padding: 0;
margin:0;
}
html,body{
width: 100%;
height: 100%;
}
#app{
height:100%;
}
body {
padding: 0;
margin: 0;
}
</style>

@ -0,0 +1,9 @@
/* 改变主题色变量 */
$--color-primary: #00c292 !default;
$--color-success: #67c23a !default;
$--color-warning: #e6a23c !default;
$--color-danger: #f56c6c !default;
$--color-info: #909399 !default;
/* 改变 icon 字体路径变量,必需 */
$--font-path: '~element-ui/lib/theme-chalk/fonts';
@import "~element-ui/packages/theme-chalk/src/index";

@ -0,0 +1,47 @@
.form-content {
background: #ffffff;
padding: 10px 10px 0 10px;
}
.table-content {
background: #ffffff;
padding: 0 10px;
}
.pagination-content {
margin-top: 10px;
padding-bottom: 10px;
text-align: right;
}
.detail-form-content{
background: #ffffff;
padding: 10px;
.el-input{
min-width: 200px;
max-width: 600px;
}
}
.bg {
position: absolute;
top: 0;
left: 0;
height: 100%;
}
.login-form {
position: absolute;
top: 0;
right: 0;
width: 350px;
height: 100%;
background: #ffffff;
padding: 0 60px;
font-size: 18px;
font-weight: bold;
}
.h1 {
margin-top: 80px;
font-size: 20px;
font-weight: bold;
}
.btn-login {
margin-top: 50px;
width: 100%;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 843 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save