玖 玖 6 months ago
parent f194a21143
commit a5df70331c

@ -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="inheritedJdk" />
<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,7 @@
<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="Stylelint" enabled="true" level="ERROR" enabled_by_default="true" />
</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.7 (django3qu6u)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (django3qu6u)" 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/django3qu6u.iml" filepath="$PROJECT_DIR$/.idea/django3qu6u.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 = 123456
db = django3qu6u
charset = utf8

@ -0,0 +1,473 @@
-- MySQL dump 10.13 Distrib 5.7.31, for Linux (x86_64)
--
-- Host: localhost Database: django3qu6u
-- ------------------------------------------------------
-- Server version 5.7.31
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Current Database: `django3qu6u`
--
/*!40000 DROP DATABASE IF EXISTS `django3qu6u`*/;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `django3qu6u` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
USE `django3qu6u`;
--
-- Table structure for table `config`
--
DROP TABLE IF EXISTS `config`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `config` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(100) NOT NULL COMMENT '配置参数名称',
`value` varchar(100) DEFAULT NULL COMMENT '配置参数值',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='配置文件';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `config`
--
LOCK TABLES `config` WRITE;
/*!40000 ALTER TABLE `config` DISABLE KEYS */;
INSERT INTO `config` VALUES (1,'picture1','upload/picture1.jpg'),(2,'picture2','upload/picture2.jpg'),(3,'picture3','upload/picture3.jpg');
/*!40000 ALTER TABLE `config` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `gerenjianli`
--
DROP TABLE IF EXISTS `gerenjianli`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `gerenjianli` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`zhanghao` varchar(200) DEFAULT NULL COMMENT '账号',
`xingming` varchar(200) DEFAULT NULL COMMENT '姓名',
`xingbie` varchar(200) DEFAULT NULL COMMENT '性别',
`shouji` varchar(200) DEFAULT NULL COMMENT '手机',
`zhaopian` varchar(200) DEFAULT NULL COMMENT '照片',
`zhuanye` varchar(200) NOT NULL COMMENT '专业',
`xueli` varchar(200) NOT NULL COMMENT '学历',
`xuexiao` varchar(200) NOT NULL COMMENT '学校',
`chushengriqi` date DEFAULT NULL COMMENT '出生日期',
`yingyushuiping` varchar(200) DEFAULT NULL COMMENT '英语水平',
`gongzuonianxian` varchar(200) DEFAULT NULL COMMENT '工作年限',
`juzhudizhi` varchar(200) DEFAULT NULL COMMENT '居住地址',
`gerenjineng` longtext COMMENT '个人技能',
`yixianggangwei` varchar(200) DEFAULT NULL COMMENT '意向岗位',
`yixiangfangxiang` varchar(200) DEFAULT NULL COMMENT '意向方向',
`yixiangchengshi` varchar(200) DEFAULT NULL COMMENT '意向城市',
`yixiangxinshui` varchar(200) DEFAULT NULL COMMENT '意向薪水',
`ziwomiaoshu` longtext COMMENT '自我描述',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8 COMMENT='个人简历';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `gerenjianli`
--
LOCK TABLES `gerenjianli` WRITE;
/*!40000 ALTER TABLE `gerenjianli` DISABLE KEYS */;
INSERT INTO `gerenjianli` VALUES (31,'2024-05-20 08:30:24','账号1','姓名1','性别1','手机1','upload/gerenjianli_zhaopian1.jpg','专业1','学历1','学校1','2024-05-20','英语水平1','工作年限1','居住地址1','个人技能1','意向岗位1','意向方向1','意向城市1','意向薪水1','自我描述1'),(32,'2024-05-20 08:30:24','账号2','姓名2','性别2','手机2','upload/gerenjianli_zhaopian2.jpg','专业2','学历2','学校2','2024-05-20','英语水平2','工作年限2','居住地址2','个人技能2','意向岗位2','意向方向2','意向城市2','意向薪水2','自我描述2'),(33,'2024-05-20 08:30:24','账号3','姓名3','性别3','手机3','upload/gerenjianli_zhaopian3.jpg','专业3','学历3','学校3','2024-05-20','英语水平3','工作年限3','居住地址3','个人技能3','意向岗位3','意向方向3','意向城市3','意向薪水3','自我描述3'),(34,'2024-05-20 08:30:24','账号4','姓名4','性别4','手机4','upload/gerenjianli_zhaopian4.jpg','专业4','学历4','学校4','2024-05-20','英语水平4','工作年限4','居住地址4','个人技能4','意向岗位4','意向方向4','意向城市4','意向薪水4','自我描述4'),(35,'2024-05-20 08:30:24','账号5','姓名5','性别5','手机5','upload/gerenjianli_zhaopian5.jpg','专业5','学历5','学校5','2024-05-20','英语水平5','工作年限5','居住地址5','个人技能5','意向岗位5','意向方向5','意向城市5','意向薪水5','自我描述5'),(36,'2024-05-20 08:30:24','账号6','姓名6','性别6','手机6','upload/gerenjianli_zhaopian6.jpg','专业6','学历6','学校6','2024-05-20','英语水平6','工作年限6','居住地址6','个人技能6','意向岗位6','意向方向6','意向城市6','意向薪水6','自我描述6');
/*!40000 ALTER TABLE `gerenjianli` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `gongsi`
--
DROP TABLE IF EXISTS `gongsi`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `gongsi` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gongsizhanghao` varchar(200) NOT NULL COMMENT '公司账号',
`mima` varchar(200) NOT NULL COMMENT '密码',
`gongsimingcheng` varchar(200) NOT NULL COMMENT '公司名称',
`gongsilingyu` varchar(200) DEFAULT NULL COMMENT '公司领域',
`gongsiguimo` varchar(200) DEFAULT NULL COMMENT '公司规模',
`gongsileixing` varchar(200) DEFAULT NULL COMMENT '公司类型',
`gongsitupian` varchar(200) DEFAULT NULL COMMENT '公司图片',
`gongsidizhi` varchar(200) DEFAULT NULL COMMENT '公司地址',
PRIMARY KEY (`id`),
UNIQUE KEY `gongsizhanghao` (`gongsizhanghao`)
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8 COMMENT='公司';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `gongsi`
--
LOCK TABLES `gongsi` WRITE;
/*!40000 ALTER TABLE `gongsi` DISABLE KEYS */;
INSERT INTO `gongsi` VALUES (21,'2024-05-20 08:30:24','22','22','公司名称1','公司领域1','公司规模1','公司类型1','upload/gongsi_gongsitupian1.jpg','公司地址1'),(22,'2024-05-20 08:30:24','公司账号2','123456','公司名称2','公司领域2','公司规模2','公司类型2','upload/gongsi_gongsitupian2.jpg','公司地址2'),(23,'2024-05-20 08:30:24','公司账号3','123456','公司名称3','公司领域3','公司规模3','公司类型3','upload/gongsi_gongsitupian3.jpg','公司地址3'),(24,'2024-05-20 08:30:24','公司账号4','123456','公司名称4','公司领域4','公司规模4','公司类型4','upload/gongsi_gongsitupian4.jpg','公司地址4'),(25,'2024-05-20 08:30:24','公司账号5','123456','公司名称5','公司领域5','公司规模5','公司类型5','upload/gongsi_gongsitupian5.jpg','公司地址5'),(26,'2024-05-20 08:30:24','公司账号6','123456','公司名称6','公司领域6','公司规模6','公司类型6','upload/gongsi_gongsitupian6.jpg','公司地址6');
/*!40000 ALTER TABLE `gongsi` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `gongsixinxi`
--
DROP TABLE IF EXISTS `gongsixinxi`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `gongsixinxi` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gongsizhanghao` varchar(200) DEFAULT NULL COMMENT '公司账号',
`gongsimingcheng` varchar(200) DEFAULT NULL COMMENT '公司名称',
`fengmian` varchar(200) DEFAULT NULL COMMENT '封面',
`gongsidizhi` varchar(200) DEFAULT NULL COMMENT '公司地址',
`gongsilingyu` varchar(200) DEFAULT NULL COMMENT '公司领域',
`gongsiguimo` varchar(200) DEFAULT NULL COMMENT '公司规模',
`gongsileixing` varchar(200) DEFAULT NULL COMMENT '公司类型',
`chuangliriqi` date DEFAULT NULL COMMENT '创立日期',
`fuzeren` varchar(200) DEFAULT NULL COMMENT '负责人',
`lianxifangshi` varchar(200) DEFAULT NULL COMMENT '联系方式',
`yuangongrenshu` varchar(200) DEFAULT NULL COMMENT '员工人数',
`gongsijieshao` longtext COMMENT '公司介绍',
`thumbsupnum` int(11) DEFAULT '0' COMMENT '',
`crazilynum` int(11) DEFAULT '0' COMMENT '',
`clicktime` datetime DEFAULT NULL COMMENT '最近点击时间',
`clicknum` int(11) DEFAULT '0' COMMENT '点击次数',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8 COMMENT='公司信息';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `gongsixinxi`
--
LOCK TABLES `gongsixinxi` WRITE;
/*!40000 ALTER TABLE `gongsixinxi` DISABLE KEYS */;
INSERT INTO `gongsixinxi` VALUES (41,'2024-05-20 08:30:24','公司账号1','公司名称1','upload/gongsixinxi_fengmian1.jpg','公司地址1','公司领域1','公司规模1','公司类型1','2024-05-20','负责人1','13823888881','员工人数1','公司介绍1',1,1,'2024-05-20 16:30:24',1),(42,'2024-05-20 08:30:24','公司账号2','公司名称2','upload/gongsixinxi_fengmian2.jpg','公司地址2','公司领域2','公司规模2','公司类型2','2024-05-20','负责人2','13823888882','员工人数2','公司介绍2',2,2,'2024-05-20 16:30:24',6),(43,'2024-05-20 08:30:24','公司账号3','公司名称3','upload/gongsixinxi_fengmian3.jpg','公司地址3','公司领域3','公司规模3','公司类型3','2024-05-20','负责人3','13823888883','员工人数3','公司介绍3',3,3,'2024-05-20 16:30:24',3),(44,'2024-05-20 08:30:24','公司账号4','公司名称4','upload/gongsixinxi_fengmian4.jpg','公司地址4','公司领域4','公司规模4','公司类型4','2024-05-20','负责人4','13823888884','员工人数4','公司介绍4',4,4,'2024-05-20 16:30:24',4),(45,'2024-05-20 08:30:24','公司账号5','公司名称5','upload/gongsixinxi_fengmian5.jpg','公司地址5','公司领域5','公司规模5','公司类型5','2024-05-20','负责人5','13823888885','员工人数5','公司介绍5',5,5,'2024-05-20 16:30:24',5),(46,'2024-05-20 08:30:24','公司账号6','公司名称6','upload/gongsixinxi_fengmian6.jpg','公司地址6','公司领域6','公司规模6','公司类型6','2024-05-20','负责人6','13823888886','员工人数6','公司介绍6',6,6,'2024-05-20 16:30:24',6);
/*!40000 ALTER TABLE `gongsixinxi` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `keshihua`
--
DROP TABLE IF EXISTS `keshihua`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `keshihua` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`keshihua` varchar(200) DEFAULT NULL COMMENT '可视化',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=107 DEFAULT CHARSET=utf8 COMMENT='可视化';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `keshihua`
--
LOCK TABLES `keshihua` WRITE;
/*!40000 ALTER TABLE `keshihua` DISABLE KEYS */;
INSERT INTO `keshihua` VALUES (101,'2024-05-20 08:30:24','可视化1'),(102,'2024-05-20 08:30:24','可视化2'),(103,'2024-05-20 08:30:24','可视化3'),(104,'2024-05-20 08:30:24','可视化4'),(105,'2024-05-20 08:30:24','可视化5'),(106,'2024-05-20 08:30:24','可视化6');
/*!40000 ALTER TABLE `keshihua` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `mianshijieguo`
--
DROP TABLE IF EXISTS `mianshijieguo`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mianshijieguo` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`biaoti` varchar(200) DEFAULT NULL COMMENT '标题',
`gangweimingcheng` varchar(200) DEFAULT NULL COMMENT '岗位名称',
`jieguo` longtext NOT NULL COMMENT '结果',
`shijian` datetime DEFAULT NULL COMMENT '时间',
`gongsizhanghao` varchar(200) DEFAULT NULL COMMENT '公司账号',
`gongsimingcheng` varchar(200) DEFAULT NULL COMMENT '公司名称',
`zhanghao` varchar(200) DEFAULT NULL COMMENT '账号',
`xingming` varchar(200) DEFAULT NULL COMMENT '姓名',
`crossuserid` bigint(20) DEFAULT NULL COMMENT '跨表用户id',
`crossrefid` bigint(20) DEFAULT NULL COMMENT '跨表主键id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=87 DEFAULT CHARSET=utf8 COMMENT='面试结果';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `mianshijieguo`
--
LOCK TABLES `mianshijieguo` WRITE;
/*!40000 ALTER TABLE `mianshijieguo` DISABLE KEYS */;
INSERT INTO `mianshijieguo` VALUES (81,'2024-05-20 08:30:24','标题1','岗位名称1','结果1','2024-05-20 16:30:24','公司账号1','公司名称1','账号1','姓名1',1,1),(82,'2024-05-20 08:30:24','标题2','岗位名称2','结果2','2024-05-20 16:30:24','公司账号2','公司名称2','账号2','姓名2',2,2),(83,'2024-05-20 08:30:24','标题3','岗位名称3','结果3','2024-05-20 16:30:24','公司账号3','公司名称3','账号3','姓名3',3,3),(84,'2024-05-20 08:30:24','标题4','岗位名称4','结果4','2024-05-20 16:30:24','公司账号4','公司名称4','账号4','姓名4',4,4),(85,'2024-05-20 08:30:24','标题5','岗位名称5','结果5','2024-05-20 16:30:24','公司账号5','公司名称5','账号5','姓名5',5,5),(86,'2024-05-20 08:30:24','标题6','岗位名称6','结果6','2024-05-20 16:30:24','公司账号6','公司名称6','账号6','姓名6',6,6);
/*!40000 ALTER TABLE `mianshijieguo` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `mianshiyaoqing`
--
DROP TABLE IF EXISTS `mianshiyaoqing`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mianshiyaoqing` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gangweimingcheng` varchar(200) DEFAULT NULL COMMENT '岗位名称',
`tongzhineirong` longtext NOT NULL COMMENT '通知内容',
`tongzhishijian` datetime DEFAULT NULL COMMENT '通知时间',
`gongsizhanghao` varchar(200) DEFAULT NULL COMMENT '公司账号',
`gongsimingcheng` varchar(200) DEFAULT NULL COMMENT '公司名称',
`zhanghao` varchar(200) DEFAULT NULL COMMENT '账号',
`xingming` varchar(200) DEFAULT NULL COMMENT '姓名',
`crossuserid` bigint(20) DEFAULT NULL COMMENT '跨表用户id',
`crossrefid` bigint(20) DEFAULT NULL COMMENT '跨表主键id',
`sfsh` varchar(200) DEFAULT '' COMMENT '是否审核',
`shhf` longtext COMMENT '审核回复',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=77 DEFAULT CHARSET=utf8 COMMENT='面试邀请';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `mianshiyaoqing`
--
LOCK TABLES `mianshiyaoqing` WRITE;
/*!40000 ALTER TABLE `mianshiyaoqing` DISABLE KEYS */;
INSERT INTO `mianshiyaoqing` VALUES (71,'2024-05-20 08:30:24','岗位名称1','通知内容1','2024-05-20 16:30:24','公司账号1','公司名称1','账号1','姓名1',1,1,'',''),(72,'2024-05-20 08:30:24','岗位名称2','通知内容2','2024-05-20 16:30:24','公司账号2','公司名称2','账号2','姓名2',2,2,'',''),(73,'2024-05-20 08:30:24','岗位名称3','通知内容3','2024-05-20 16:30:24','公司账号3','公司名称3','账号3','姓名3',3,3,'',''),(74,'2024-05-20 08:30:24','岗位名称4','通知内容4','2024-05-20 16:30:24','公司账号4','公司名称4','账号4','姓名4',4,4,'',''),(75,'2024-05-20 08:30:24','岗位名称5','通知内容5','2024-05-20 16:30:24','公司账号5','公司名称5','账号5','姓名5',5,5,'',''),(76,'2024-05-20 08:30:24','岗位名称6','通知内容6','2024-05-20 16:30:24','公司账号6','公司名称6','账号6','姓名6',6,6,'','');
/*!40000 ALTER TABLE `mianshiyaoqing` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `qiuzhizhe`
--
DROP TABLE IF EXISTS `qiuzhizhe`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `qiuzhizhe` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`zhanghao` varchar(200) NOT NULL COMMENT '账号',
`mima` varchar(200) NOT NULL COMMENT '密码',
`xingming` varchar(200) NOT NULL COMMENT '姓名',
`nianling` int(11) DEFAULT NULL COMMENT '年龄',
`xingbie` varchar(200) DEFAULT NULL COMMENT '性别',
`shouji` varchar(200) DEFAULT NULL COMMENT '手机',
`zhaopian` varchar(200) DEFAULT NULL COMMENT '照片',
PRIMARY KEY (`id`),
UNIQUE KEY `zhanghao` (`zhanghao`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 COMMENT='求职者';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `qiuzhizhe`
--
LOCK TABLES `qiuzhizhe` WRITE;
/*!40000 ALTER TABLE `qiuzhizhe` DISABLE KEYS */;
INSERT INTO `qiuzhizhe` VALUES (11,'2024-05-20 08:30:24','11','11','姓名1',1,'','13823888881','upload/qiuzhizhe_zhaopian1.jpg'),(12,'2024-05-20 08:30:24','账号2','123456','姓名2',2,'','13823888882','upload/qiuzhizhe_zhaopian2.jpg'),(13,'2024-05-20 08:30:24','账号3','123456','姓名3',3,'','13823888883','upload/qiuzhizhe_zhaopian3.jpg'),(14,'2024-05-20 08:30:24','账号4','123456','姓名4',4,'','13823888884','upload/qiuzhizhe_zhaopian4.jpg'),(15,'2024-05-20 08:30:24','账号5','123456','姓名5',5,'','13823888885','upload/qiuzhizhe_zhaopian5.jpg'),(16,'2024-05-20 08:30:24','账号6','123456','姓名6',6,'','13823888886','upload/qiuzhizhe_zhaopian6.jpg');
/*!40000 ALTER TABLE `qiuzhizhe` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `storeup`
--
DROP TABLE IF EXISTS `storeup`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `storeup` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`userid` bigint(20) NOT NULL COMMENT '用户id',
`refid` bigint(20) DEFAULT NULL COMMENT '收藏id',
`tablename` varchar(200) DEFAULT NULL COMMENT '表名',
`name` varchar(200) NOT NULL COMMENT '收藏名称',
`picture` varchar(200) NOT NULL COMMENT '收藏图片',
`type` varchar(200) DEFAULT '1' COMMENT '类型(1:收藏,21:赞,22:踩)',
`inteltype` varchar(200) DEFAULT NULL COMMENT '推荐类型',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1645000431353 DEFAULT CHARSET=utf8 COMMENT='收藏表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `storeup`
--
LOCK TABLES `storeup` WRITE;
/*!40000 ALTER TABLE `storeup` DISABLE KEYS */;
/*!40000 ALTER TABLE `storeup` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tongzhigonggao`
--
DROP TABLE IF EXISTS `tongzhigonggao`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tongzhigonggao` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`biaoti` varchar(200) NOT NULL COMMENT '标题',
`jianjie` longtext COMMENT '简介',
`fabushijian` date DEFAULT NULL COMMENT '发布时间',
`fengmian` varchar(200) DEFAULT NULL COMMENT '封面',
`neirong` longtext COMMENT '内容',
`clicktime` datetime DEFAULT NULL COMMENT '最近点击时间',
`clicknum` int(11) DEFAULT '0' COMMENT '点击次数',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=97 DEFAULT CHARSET=utf8 COMMENT='通知公告';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tongzhigonggao`
--
LOCK TABLES `tongzhigonggao` WRITE;
/*!40000 ALTER TABLE `tongzhigonggao` DISABLE KEYS */;
INSERT INTO `tongzhigonggao` VALUES (91,'2024-05-20 08:30:24','标题1','简介1','2024-05-20','upload/tongzhigonggao_fengmian1.jpg','内容1','2024-05-20 16:30:24',1),(92,'2024-05-20 08:30:24','标题2','简介2','2024-05-20','upload/tongzhigonggao_fengmian2.jpg','内容2','2024-05-20 16:30:24',2),(93,'2024-05-20 08:30:24','标题3','简介3','2024-05-20','upload/tongzhigonggao_fengmian3.jpg','内容3','2024-05-20 16:30:24',3),(94,'2024-05-20 08:30:24','标题4','简介4','2024-05-20','upload/tongzhigonggao_fengmian4.jpg','内容4','2024-05-20 16:30:24',4),(95,'2024-05-20 08:30:24','标题5','简介5','2024-05-20','upload/tongzhigonggao_fengmian5.jpg','内容5','2024-05-20 16:30:24',5),(96,'2024-05-20 08:30:24','标题6','简介6','2024-05-20','upload/tongzhigonggao_fengmian6.jpg','内容6','2024-05-20 16:30:24',6);
/*!40000 ALTER TABLE `tongzhigonggao` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `toudijianli`
--
DROP TABLE IF EXISTS `toudijianli`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `toudijianli` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`zhanghao` varchar(200) DEFAULT NULL COMMENT '账号',
`xingming` varchar(200) DEFAULT NULL COMMENT '姓名',
`zhaopian` varchar(200) DEFAULT NULL COMMENT '照片',
`jianliwenjian` varchar(200) DEFAULT NULL COMMENT '简历文件',
`gangweimingcheng` varchar(200) DEFAULT NULL COMMENT '岗位名称',
`toudishijian` datetime DEFAULT NULL COMMENT '投递时间',
`gongsizhanghao` varchar(200) DEFAULT NULL COMMENT '公司账号',
`gongsimingcheng` varchar(200) DEFAULT NULL COMMENT '公司名称',
`crossuserid` bigint(20) DEFAULT NULL COMMENT '跨表用户id',
`crossrefid` bigint(20) DEFAULT NULL COMMENT '跨表主键id',
`sfsh` varchar(200) DEFAULT '' COMMENT '是否审核',
`shhf` longtext COMMENT '审核回复',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=67 DEFAULT CHARSET=utf8 COMMENT='投递简历';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `toudijianli`
--
LOCK TABLES `toudijianli` WRITE;
/*!40000 ALTER TABLE `toudijianli` DISABLE KEYS */;
INSERT INTO `toudijianli` VALUES (61,'2024-05-20 08:30:24','账号1','姓名1','upload/toudijianli_zhaopian1.jpg','','岗位名称1','2024-05-20 16:30:24','公司账号1','公司名称1',1,1,'',''),(62,'2024-05-20 08:30:24','账号2','姓名2','upload/toudijianli_zhaopian2.jpg','','岗位名称2','2024-05-20 16:30:24','公司账号2','公司名称2',2,2,'',''),(63,'2024-05-20 08:30:24','账号3','姓名3','upload/toudijianli_zhaopian3.jpg','','岗位名称3','2024-05-20 16:30:24','公司账号3','公司名称3',3,3,'',''),(64,'2024-05-20 08:30:24','账号4','姓名4','upload/toudijianli_zhaopian4.jpg','','岗位名称4','2024-05-20 16:30:24','公司账号4','公司名称4',4,4,'',''),(65,'2024-05-20 08:30:24','账号5','姓名5','upload/toudijianli_zhaopian5.jpg','','岗位名称5','2024-05-20 16:30:24','公司账号5','公司名称5',5,5,'',''),(66,'2024-05-20 08:30:24','账号6','姓名6','upload/toudijianli_zhaopian6.jpg','','岗位名称6','2024-05-20 16:30:24','公司账号6','公司名称6',6,6,'','');
/*!40000 ALTER TABLE `toudijianli` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `users` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`username` varchar(100) NOT NULL COMMENT '用户名',
`password` varchar(100) NOT NULL COMMENT '密码',
`role` varchar(100) DEFAULT '管理员' COMMENT '角色',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '新增时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='用户表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `users`
--
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` VALUES (1,'abo','abo','管理员','2024-05-20 08:30:24');
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `zhaopinxinxi`
--
DROP TABLE IF EXISTS `zhaopinxinxi`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `zhaopinxinxi` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gangweibianhao` varchar(200) NOT NULL COMMENT '岗位编号',
`gangweimingcheng` varchar(200) NOT NULL COMMENT '岗位名称',
`shangbandizhi` varchar(200) NOT NULL COMMENT '上班地址',
`jingyanyaoqiu` longtext NOT NULL COMMENT '经验要求',
`xueliyaoqiu` varchar(200) NOT NULL COMMENT '学历要求',
`zhaopinrenshu` int(11) NOT NULL COMMENT '招聘人数',
`gangweifuli` longtext COMMENT '岗位福利',
`xinzidaiyu` varchar(200) DEFAULT NULL COMMENT '薪资待遇',
`gongzuonianxian` varchar(200) NOT NULL COMMENT '工作年限',
`tupian` varchar(200) DEFAULT NULL COMMENT '图片',
`fabushijian` date DEFAULT NULL COMMENT '发布时间',
`gongsizhanghao` varchar(200) DEFAULT NULL COMMENT '公司账号',
`gongsimingcheng` varchar(200) DEFAULT NULL COMMENT '公司名称',
`gongsilingyu` varchar(200) DEFAULT NULL COMMENT '公司领域',
`gongsiguimo` varchar(200) DEFAULT NULL COMMENT '公司规模',
`gongsileixing` varchar(200) DEFAULT NULL COMMENT '公司类型',
`zhiweixinxi` longtext COMMENT '职位信息',
`thumbsupnum` int(11) DEFAULT '0' COMMENT '',
`crazilynum` int(11) DEFAULT '0' COMMENT '',
`clicktime` datetime DEFAULT NULL COMMENT '最近点击时间',
`clicknum` int(11) DEFAULT '0' COMMENT '点击次数',
PRIMARY KEY (`id`),
UNIQUE KEY `gangweibianhao` (`gangweibianhao`)
) ENGINE=InnoDB AUTO_INCREMENT=1645000403948 DEFAULT CHARSET=utf8 COMMENT='招聘信息';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `zhaopinxinxi`
--
LOCK TABLES `zhaopinxinxi` WRITE;
/*!40000 ALTER TABLE `zhaopinxinxi` DISABLE KEYS */;
INSERT INTO `zhaopinxinxi` VALUES (51,'2024-05-20 08:30:24','岗位编号1','岗位名称1','上班地址1','经验要求1','学历要求1',1,'岗位福利1','薪资待遇1','工作年限1','upload/zhaopinxinxi_tupian1.jpg','2024-05-20','公司账号1','公司名称1','公司领域1','公司规模1','公司类型1','职位信息1',1,1,'2024-05-20 16:30:24',1),(52,'2024-05-20 08:30:24','岗位编号2','岗位名称2','上班地址2','经验要求2','学历要求2',2,'岗位福利2','薪资待遇2','工作年限2','upload/zhaopinxinxi_tupian2.jpg','2024-05-20','公司账号2','公司名称2','公司领域2','公司规模2','公司类型2','职位信息2',2,2,'2024-05-20 16:30:24',2),(53,'2024-05-20 08:30:24','岗位编号3','岗位名称3','上班地址3','经验要求3','学历要求3',3,'岗位福利3','薪资待遇3','工作年限3','upload/zhaopinxinxi_tupian3.jpg','2024-05-20','公司账号3','公司名称3','公司领域3','公司规模3','公司类型3','职位信息3',3,3,'2024-05-20 16:30:24',3),(54,'2024-05-20 08:30:24','岗位编号4','岗位名称4','上班地址4','经验要求4','学历要求4',4,'岗位福利4','薪资待遇4','工作年限4','upload/zhaopinxinxi_tupian4.jpg','2024-05-20','公司账号4','公司名称4','公司领域4','公司规模4','公司类型4','职位信息4',4,4,'2024-05-20 16:30:24',4),(55,'2024-05-20 08:30:24','岗位编号5','岗位名称5','上班地址5','经验要求5','学历要求5',5,'岗位福利5','薪资待遇5','工作年限5','upload/zhaopinxinxi_tupian5.jpg','2024-05-20','公司账号5','公司名称5','公司领域5','公司规模5','公司类型5','职位信息5',5,5,'2024-05-20 16:30:24',5),(56,'2024-05-20 08:30:24','岗位编号6','岗位名称6','上班地址6','经验要求6','学历要求6',6,'岗位福利6','薪资待遇6','工作年限6','upload/zhaopinxinxi_tupian6.jpg','2024-05-20','公司账号6','公司名称6','公司领域6','公司规模6','公司类型6','职位信息6',6,6,'2024-05-20 16:30:24',6),(1645000370071,'2024-05-20 08:32:50','01','水电费','11','第三方时代','睡得着',22,'','222','电商发送到','','2024-05-20','22','公司名称1','公司领域1','公司规模1','公司类型1','<p>水电费</p>',0,0,NULL,0),(1645000403947,'2024-05-20 08:33:23','02','水电费','水电费时代','水电费时代','时代发多少',33,'','','时代发送到','','2024-05-20','22','公司名称1','公司领域1','公司规模1','公司类型1','',0,0,NULL,0);
/*!40000 ALTER TABLE `zhaopinxinxi` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2024-05-20 9:27:16

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

@ -0,0 +1,184 @@
"""
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'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = False
EMAIL_USE_SSL = True
EMAIL_HOST = 'smtp.qq.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = 'yclw9@qq.com'
EMAIL_HOST_PASSWORD = 'mhbrkuayvkkgbijd'
# 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)
if dbtype == 'mysql':
DATABASES = {
'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'sql_mode': 'traditional',
'init_command': "SET sql_mode='traditional'", # STRICT_TRANS_TABLES
},
'NAME': dbName,
'USER': user,
'PASSWORD': passwd,
'HOST': host,
'PORT': port,
'charset': charset,
'TEST': {
'CHARSET': charset,
'COLLATION': 'utf8_general_ci',
},
'CONN_MAX_AGE':60
},
}
else:
print("请使用mysql5.5数据库")
os._exit(1)
# 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)
ALIPAY_APP_ID = ''
APP_PRIVATE_KEY_STRING = open('{}/util/alipay_key/app_private_2048.txt'.format(BASE_DIR)).read()
ALIPAY_PUBLIC_KEY_STRING = open('{}/util/alipay_key/alipay_public_2048.txt'.format(BASE_DIR)).read()
ALIPAY_SIGN_TYPE = 'RSA2'

@ -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/django3qu6u.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,725 @@
#coding:utf-8
__author__ = "ila"
import base64, copy, logging, os, time, xlrd
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import gerenjianli
from util.codes import *
from util.auth import Auth
from util.common import Common
import util.message as mes
from django.db import connection
import random
from django.core.mail import send_mail
from alipay import AliPayConfig, AliPay
from django.conf import settings
from django.shortcuts import redirect
def gerenjianli_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = gerenjianli.createbyreq(gerenjianli, gerenjianli, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def gerenjianli_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = gerenjianli.getbyparams(gerenjianli, gerenjianli, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= gerenjianli.__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, gerenjianli, req_dict)
def gerenjianli_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def gerenjianli_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
columns= gerenjianli.getallcolumn( gerenjianli, gerenjianli)
try:
__loginUserColumn__= gerenjianli.__loginUserColumn__
except:
__loginUserColumn__=None
username=req_dict.get(list(req_dict.keys())[0])
if __loginUserColumn__:
username_str=__loginUserColumn__
else:
username_str=username
if 'mima' in columns:
password_str='mima'
else:
password_str='password'
init_pwd = '123456'
eval('''gerenjianli.objects.filter({}='{}').update({}='{}')'''.format(username_str,username,password_str,init_pwd))
return JsonResponse(msg)
def gerenjianli_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'] = gerenjianli.getbyparams(gerenjianli, gerenjianli, req_dict)[0]
return JsonResponse(msg)
def gerenjianli_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=gerenjianli.getbyparams(gerenjianli, gerenjianli, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def gerenjianli_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= gerenjianli.getallcolumn( gerenjianli, gerenjianli)
#当前登录用户所在表
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__=gerenjianli.__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__=gerenjianli.__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 'gerenjianli'[:7]!='discuss'and "userid" in gerenjianli.getallcolumn(gerenjianli,gerenjianli):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=gerenjianli.__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'] =gerenjianli.page(gerenjianli, gerenjianli, req_dict)
return JsonResponse(msg)
def gerenjianli_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 gerenjianli.getallcolumn(gerenjianli,gerenjianli):
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'] = gerenjianli.page(gerenjianli,gerenjianli, req_dict)
return JsonResponse(msg)
def gerenjianli_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= gerenjianli.getallcolumn( gerenjianli, gerenjianli)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=gerenjianli.__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__=gerenjianli.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=gerenjianli.__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__=gerenjianli.__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 gerenjianli.__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'] = gerenjianli.page(gerenjianli, gerenjianli, req_dict)
return JsonResponse(msg)
def gerenjianli_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= gerenjianli.getallcolumn( gerenjianli, gerenjianli)
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= gerenjianli.createbyreq(gerenjianli,gerenjianli, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gerenjianli_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= gerenjianli.getallcolumn( gerenjianli, gerenjianli)
try:
__authSeparate__=gerenjianli.__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__=gerenjianli.__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= gerenjianli.createbyreq(gerenjianli,gerenjianli, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gerenjianli_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=gerenjianli.getbyid(gerenjianli,gerenjianli,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 = gerenjianli.updatebyparams(gerenjianli,gerenjianli, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gerenjianli_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = gerenjianli.getbyid(gerenjianli,gerenjianli, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= gerenjianli.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in gerenjianli.getallcolumn(gerenjianli,gerenjianli):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=gerenjianli.updatebyparams(gerenjianli,gerenjianli,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def gerenjianli_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =gerenjianli.getbyid(gerenjianli,gerenjianli, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= gerenjianli.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in gerenjianli.getallcolumn(gerenjianli,gerenjianli):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=gerenjianli.updatebyparams(gerenjianli,gerenjianli,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def gerenjianli_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 gerenjianli.getallcolumn(gerenjianli,gerenjianli) :
del req_dict["mima"]
if "password" not in gerenjianli.getallcolumn(gerenjianli,gerenjianli) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = gerenjianli.updatebyparams(gerenjianli, gerenjianli, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gerenjianli_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=gerenjianli.deletes(gerenjianli,
gerenjianli,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gerenjianli_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= gerenjianli.getbyid(gerenjianli, gerenjianli, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=gerenjianli.updatebyparams(gerenjianli,gerenjianli,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def gerenjianli_importExcel(request):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
excel_file = request.FILES.get("file", "")
file_type = excel_file.name.split('.')[1]
if file_type in ['xlsx', 'xls']:
data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())
table = data.sheets()[0]
rows = table.nrows
try:
for row in range(1, rows):
row_values = table.row_values(row)
req_dict = {}
gerenjianli.createbyreq(gerenjianli, gerenjianli, req_dict)
except:
pass
else:
msg.code = 500
msg.msg = "文件类型错误"
return JsonResponse(msg)
def gerenjianli_sendemail(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
code = random.sample(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 4)
to = []
to.append(req_dict['email'])
send_mail('用户注册', '您的注册验证码是【'+''.join(code)+'】,请不要把验证码泄漏给其他人,如非本人请勿操作。', 'yclw9@qq.com', to, fail_silently = False)
cursor = connection.cursor()
cursor.execute("insert into emailregistercode(email,role,code) values('"+req_dict['email']+"','用户','"+''.join(code)+"')")
msg = {
"msg": "发送成功",
"code": 0
}
return JsonResponse(msg)
def gerenjianli_autoSort2(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
cursor = connection.cursor()
leixing = set()
try:
cursor.execute("select goodtype from orders where userid = %d"%(request.session.get("params").get("id"))+" and tablename = 'gerenjianli' order by addtime desc")
rows = cursor.fetchall()
for row in rows:
for item in row:
leixing.add(item)
except:
leixing = set()
L = []
cursor.execute("select * from gerenjianli where $intelRecomColumn in ('%s"%("','").join(leixing)+"') union all select * from gerenjianli where $intelRecomColumn not in('%s"%("','").join(leixing)+"')")
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
return JsonResponse({"code": 0, "msg": '', "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":5,"list": L[0:6]}})
def gerenjianli_value(request, xColumnName, yColumnName, timeStatType):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and zhanghao ='{0}' ".format(decode_str['params']['zhanghao'])
sql = ''
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM gerenjianli {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d')".format(xColumnName, yColumnName, where, '%Y-%m-%d')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM gerenjianli {2} GROUP BY DATE_FORMAT({0}, '%Y-%m')".format(xColumnName, yColumnName, where, '%Y-%m')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM gerenjianli {2} GROUP BY DATE_FORMAT({0}, '%Y')".format(xColumnName, yColumnName, where, '%Y')
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def gerenjianli_o_value(request, xColumnName, yColumnName):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and zhanghao ='{0}' ".format(decode_str['params']['zhanghao'])
sql = "SELECT {0}, sum({1}) AS total FROM gerenjianli {2} GROUP BY {0}".format(xColumnName, yColumnName, where)
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def gerenjianli_alipay(request):
if request.method in ["POST", "GET"]:
alipay = AliPay(
appid=settings.ALIPAY_APP_ID,
app_notify_url=None,
app_private_key_string=settings.APP_PRIVATE_KEY_STRING,
alipay_public_key_string=settings.ALIPAY_PUBLIC_KEY_STRING,
sign_type=settings.ALIPAY_SIGN_TYPE,
debug=True,
config=AliPayConfig(timeout=15)
)
req_dict = request.session.get("req_dict")
order_string = alipay.api_alipay_trade_page_pay(
out_trade_no=req_dict['tradeno'],
total_amount=req_dict['totalamount'],
subject=req_dict['subject'],
return_url='http://localhost:8080/django3qu6u/gerenjianli/notify',
#notify_url=''
)
pay_url = 'https://openapi.alipaydev.com/gateway.do?' + order_string
pay_url = '<form name="punchout_form" method="post" action="{0}"><input type="hidden" name="biz_content" ><input type="submit" value="立即支付" style="display: none"></form>'.format(pay_url)
return JsonResponse({'code': 0, "data": pay_url})
def gerenjianli_notify(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
out_trade_no = req_dict['out_trade_no']
cursor = connection.cursor()
return redirect('http://localhost:8080/django3qu6u/admin/dist/index.html#/gerenjianli')

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

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

@ -0,0 +1,717 @@
#coding:utf-8
__author__ = "ila"
import base64, copy, logging, os, time, xlrd
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import keshihua
from util.codes import *
from util.auth import Auth
from util.common import Common
import util.message as mes
from django.db import connection
import random
from django.core.mail import send_mail
from alipay import AliPayConfig, AliPay
from django.conf import settings
from django.shortcuts import redirect
def keshihua_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = keshihua.createbyreq(keshihua, keshihua, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def keshihua_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = keshihua.getbyparams(keshihua, keshihua, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= keshihua.__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, keshihua, req_dict)
def keshihua_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def keshihua_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
columns= keshihua.getallcolumn( keshihua, keshihua)
try:
__loginUserColumn__= keshihua.__loginUserColumn__
except:
__loginUserColumn__=None
username=req_dict.get(list(req_dict.keys())[0])
if __loginUserColumn__:
username_str=__loginUserColumn__
else:
username_str=username
if 'mima' in columns:
password_str='mima'
else:
password_str='password'
init_pwd = '123456'
eval('''keshihua.objects.filter({}='{}').update({}='{}')'''.format(username_str,username,password_str,init_pwd))
return JsonResponse(msg)
def keshihua_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'] = keshihua.getbyparams(keshihua, keshihua, req_dict)[0]
return JsonResponse(msg)
def keshihua_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=keshihua.getbyparams(keshihua, keshihua, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def keshihua_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= keshihua.getallcolumn( keshihua, keshihua)
#当前登录用户所在表
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__=keshihua.__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__=keshihua.__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 'keshihua'[:7]!='discuss'and "userid" in keshihua.getallcolumn(keshihua,keshihua):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=keshihua.__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'] =keshihua.page(keshihua, keshihua, req_dict)
return JsonResponse(msg)
def keshihua_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 keshihua.getallcolumn(keshihua,keshihua):
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'] = keshihua.page(keshihua,keshihua, req_dict)
return JsonResponse(msg)
def keshihua_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= keshihua.getallcolumn( keshihua, keshihua)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=keshihua.__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__=keshihua.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=keshihua.__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__=keshihua.__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 keshihua.__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'] = keshihua.page(keshihua, keshihua, req_dict)
return JsonResponse(msg)
def keshihua_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= keshihua.getallcolumn( keshihua, keshihua)
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= keshihua.createbyreq(keshihua,keshihua, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def keshihua_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= keshihua.getallcolumn( keshihua, keshihua)
try:
__authSeparate__=keshihua.__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__=keshihua.__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= keshihua.createbyreq(keshihua,keshihua, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def keshihua_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=keshihua.getbyid(keshihua,keshihua,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 = keshihua.updatebyparams(keshihua,keshihua, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def keshihua_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = keshihua.getbyid(keshihua,keshihua, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= keshihua.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in keshihua.getallcolumn(keshihua,keshihua):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=keshihua.updatebyparams(keshihua,keshihua,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def keshihua_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =keshihua.getbyid(keshihua,keshihua, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= keshihua.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in keshihua.getallcolumn(keshihua,keshihua):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=keshihua.updatebyparams(keshihua,keshihua,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def keshihua_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 keshihua.getallcolumn(keshihua,keshihua) :
del req_dict["mima"]
if "password" not in keshihua.getallcolumn(keshihua,keshihua) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = keshihua.updatebyparams(keshihua, keshihua, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def keshihua_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=keshihua.deletes(keshihua,
keshihua,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def keshihua_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= keshihua.getbyid(keshihua, keshihua, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=keshihua.updatebyparams(keshihua,keshihua,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def keshihua_importExcel(request):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
excel_file = request.FILES.get("file", "")
file_type = excel_file.name.split('.')[1]
if file_type in ['xlsx', 'xls']:
data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())
table = data.sheets()[0]
rows = table.nrows
try:
for row in range(1, rows):
row_values = table.row_values(row)
req_dict = {}
keshihua.createbyreq(keshihua, keshihua, req_dict)
except:
pass
else:
msg.code = 500
msg.msg = "文件类型错误"
return JsonResponse(msg)
def keshihua_sendemail(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
code = random.sample(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 4)
to = []
to.append(req_dict['email'])
send_mail('用户注册', '您的注册验证码是【'+''.join(code)+'】,请不要把验证码泄漏给其他人,如非本人请勿操作。', 'yclw9@qq.com', to, fail_silently = False)
cursor = connection.cursor()
cursor.execute("insert into emailregistercode(email,role,code) values('"+req_dict['email']+"','用户','"+''.join(code)+"')")
msg = {
"msg": "发送成功",
"code": 0
}
return JsonResponse(msg)
def keshihua_autoSort2(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
cursor = connection.cursor()
leixing = set()
try:
cursor.execute("select goodtype from orders where userid = %d"%(request.session.get("params").get("id"))+" and tablename = 'keshihua' order by addtime desc")
rows = cursor.fetchall()
for row in rows:
for item in row:
leixing.add(item)
except:
leixing = set()
L = []
cursor.execute("select * from keshihua where $intelRecomColumn in ('%s"%("','").join(leixing)+"') union all select * from keshihua where $intelRecomColumn not in('%s"%("','").join(leixing)+"')")
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
return JsonResponse({"code": 0, "msg": '', "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":5,"list": L[0:6]}})
def keshihua_value(request, xColumnName, yColumnName, timeStatType):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
sql = ''
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM keshihua {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d')".format(xColumnName, yColumnName, where, '%Y-%m-%d')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM keshihua {2} GROUP BY DATE_FORMAT({0}, '%Y-%m')".format(xColumnName, yColumnName, where, '%Y-%m')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM keshihua {2} GROUP BY DATE_FORMAT({0}, '%Y')".format(xColumnName, yColumnName, where, '%Y')
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def keshihua_o_value(request, xColumnName, yColumnName):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
sql = "SELECT {0}, sum({1}) AS total FROM keshihua {2} GROUP BY {0}".format(xColumnName, yColumnName, where)
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def keshihua_alipay(request):
if request.method in ["POST", "GET"]:
alipay = AliPay(
appid=settings.ALIPAY_APP_ID,
app_notify_url=None,
app_private_key_string=settings.APP_PRIVATE_KEY_STRING,
alipay_public_key_string=settings.ALIPAY_PUBLIC_KEY_STRING,
sign_type=settings.ALIPAY_SIGN_TYPE,
debug=True,
config=AliPayConfig(timeout=15)
)
req_dict = request.session.get("req_dict")
order_string = alipay.api_alipay_trade_page_pay(
out_trade_no=req_dict['tradeno'],
total_amount=req_dict['totalamount'],
subject=req_dict['subject'],
return_url='http://localhost:8080/django3qu6u/keshihua/notify',
#notify_url=''
)
pay_url = 'https://openapi.alipaydev.com/gateway.do?' + order_string
pay_url = '<form name="punchout_form" method="post" action="{0}"><input type="hidden" name="biz_content" ><input type="submit" value="立即支付" style="display: none"></form>'.format(pay_url)
return JsonResponse({'code': 0, "data": pay_url})
def keshihua_notify(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
out_trade_no = req_dict['out_trade_no']
cursor = connection.cursor()
return redirect('http://localhost:8080/django3qu6u/admin/dist/index.html#/keshihua')

@ -0,0 +1,733 @@
#coding:utf-8
__author__ = "ila"
import base64, copy, logging, os, time, xlrd
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import mianshijieguo
from util.codes import *
from util.auth import Auth
from util.common import Common
import util.message as mes
from django.db import connection
import random
from django.core.mail import send_mail
from alipay import AliPayConfig, AliPay
from django.conf import settings
from django.shortcuts import redirect
def mianshijieguo_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = mianshijieguo.createbyreq(mianshijieguo, mianshijieguo, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def mianshijieguo_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = mianshijieguo.getbyparams(mianshijieguo, mianshijieguo, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= mianshijieguo.__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, mianshijieguo, req_dict)
def mianshijieguo_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def mianshijieguo_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
columns= mianshijieguo.getallcolumn( mianshijieguo, mianshijieguo)
try:
__loginUserColumn__= mianshijieguo.__loginUserColumn__
except:
__loginUserColumn__=None
username=req_dict.get(list(req_dict.keys())[0])
if __loginUserColumn__:
username_str=__loginUserColumn__
else:
username_str=username
if 'mima' in columns:
password_str='mima'
else:
password_str='password'
init_pwd = '123456'
eval('''mianshijieguo.objects.filter({}='{}').update({}='{}')'''.format(username_str,username,password_str,init_pwd))
return JsonResponse(msg)
def mianshijieguo_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'] = mianshijieguo.getbyparams(mianshijieguo, mianshijieguo, req_dict)[0]
return JsonResponse(msg)
def mianshijieguo_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=mianshijieguo.getbyparams(mianshijieguo, mianshijieguo, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def mianshijieguo_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= mianshijieguo.getallcolumn( mianshijieguo, mianshijieguo)
#当前登录用户所在表
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__=mianshijieguo.__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__=mianshijieguo.__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 'mianshijieguo'[:7]!='discuss'and "userid" in mianshijieguo.getallcolumn(mianshijieguo,mianshijieguo):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=mianshijieguo.__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'] =mianshijieguo.page(mianshijieguo, mianshijieguo, req_dict)
return JsonResponse(msg)
def mianshijieguo_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 mianshijieguo.getallcolumn(mianshijieguo,mianshijieguo):
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'] = mianshijieguo.page(mianshijieguo,mianshijieguo, req_dict)
return JsonResponse(msg)
def mianshijieguo_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= mianshijieguo.getallcolumn( mianshijieguo, mianshijieguo)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=mianshijieguo.__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__=mianshijieguo.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=mianshijieguo.__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__=mianshijieguo.__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 mianshijieguo.__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'] = mianshijieguo.page(mianshijieguo, mianshijieguo, req_dict)
return JsonResponse(msg)
def mianshijieguo_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= mianshijieguo.getallcolumn( mianshijieguo, mianshijieguo)
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= mianshijieguo.createbyreq(mianshijieguo,mianshijieguo, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def mianshijieguo_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= mianshijieguo.getallcolumn( mianshijieguo, mianshijieguo)
try:
__authSeparate__=mianshijieguo.__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__=mianshijieguo.__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= mianshijieguo.createbyreq(mianshijieguo,mianshijieguo, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def mianshijieguo_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=mianshijieguo.getbyid(mianshijieguo,mianshijieguo,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 = mianshijieguo.updatebyparams(mianshijieguo,mianshijieguo, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def mianshijieguo_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = mianshijieguo.getbyid(mianshijieguo,mianshijieguo, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= mianshijieguo.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in mianshijieguo.getallcolumn(mianshijieguo,mianshijieguo):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=mianshijieguo.updatebyparams(mianshijieguo,mianshijieguo,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def mianshijieguo_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =mianshijieguo.getbyid(mianshijieguo,mianshijieguo, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= mianshijieguo.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in mianshijieguo.getallcolumn(mianshijieguo,mianshijieguo):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=mianshijieguo.updatebyparams(mianshijieguo,mianshijieguo,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def mianshijieguo_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 mianshijieguo.getallcolumn(mianshijieguo,mianshijieguo) :
del req_dict["mima"]
if "password" not in mianshijieguo.getallcolumn(mianshijieguo,mianshijieguo) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = mianshijieguo.updatebyparams(mianshijieguo, mianshijieguo, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def mianshijieguo_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=mianshijieguo.deletes(mianshijieguo,
mianshijieguo,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def mianshijieguo_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= mianshijieguo.getbyid(mianshijieguo, mianshijieguo, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=mianshijieguo.updatebyparams(mianshijieguo,mianshijieguo,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def mianshijieguo_importExcel(request):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
excel_file = request.FILES.get("file", "")
file_type = excel_file.name.split('.')[1]
if file_type in ['xlsx', 'xls']:
data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())
table = data.sheets()[0]
rows = table.nrows
try:
for row in range(1, rows):
row_values = table.row_values(row)
req_dict = {}
mianshijieguo.createbyreq(mianshijieguo, mianshijieguo, req_dict)
except:
pass
else:
msg.code = 500
msg.msg = "文件类型错误"
return JsonResponse(msg)
def mianshijieguo_sendemail(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
code = random.sample(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 4)
to = []
to.append(req_dict['email'])
send_mail('用户注册', '您的注册验证码是【'+''.join(code)+'】,请不要把验证码泄漏给其他人,如非本人请勿操作。', 'yclw9@qq.com', to, fail_silently = False)
cursor = connection.cursor()
cursor.execute("insert into emailregistercode(email,role,code) values('"+req_dict['email']+"','用户','"+''.join(code)+"')")
msg = {
"msg": "发送成功",
"code": 0
}
return JsonResponse(msg)
def mianshijieguo_autoSort2(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
cursor = connection.cursor()
leixing = set()
try:
cursor.execute("select goodtype from orders where userid = %d"%(request.session.get("params").get("id"))+" and tablename = 'mianshijieguo' order by addtime desc")
rows = cursor.fetchall()
for row in rows:
for item in row:
leixing.add(item)
except:
leixing = set()
L = []
cursor.execute("select * from mianshijieguo where $intelRecomColumn in ('%s"%("','").join(leixing)+"') union all select * from mianshijieguo where $intelRecomColumn not in('%s"%("','").join(leixing)+"')")
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
return JsonResponse({"code": 0, "msg": '', "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":5,"list": L[0:6]}})
def mianshijieguo_value(request, xColumnName, yColumnName, timeStatType):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and gongsizhanghao ='{0}' ".format(decode_str['params']['gongsizhanghao'])
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and zhanghao ='{0}' ".format(decode_str['params']['zhanghao'])
sql = ''
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM mianshijieguo {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d')".format(xColumnName, yColumnName, where, '%Y-%m-%d')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM mianshijieguo {2} GROUP BY DATE_FORMAT({0}, '%Y-%m')".format(xColumnName, yColumnName, where, '%Y-%m')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM mianshijieguo {2} GROUP BY DATE_FORMAT({0}, '%Y')".format(xColumnName, yColumnName, where, '%Y')
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def mianshijieguo_o_value(request, xColumnName, yColumnName):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and gongsizhanghao ='{0}' ".format(decode_str['params']['gongsizhanghao'])
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and zhanghao ='{0}' ".format(decode_str['params']['zhanghao'])
sql = "SELECT {0}, sum({1}) AS total FROM mianshijieguo {2} GROUP BY {0}".format(xColumnName, yColumnName, where)
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def mianshijieguo_alipay(request):
if request.method in ["POST", "GET"]:
alipay = AliPay(
appid=settings.ALIPAY_APP_ID,
app_notify_url=None,
app_private_key_string=settings.APP_PRIVATE_KEY_STRING,
alipay_public_key_string=settings.ALIPAY_PUBLIC_KEY_STRING,
sign_type=settings.ALIPAY_SIGN_TYPE,
debug=True,
config=AliPayConfig(timeout=15)
)
req_dict = request.session.get("req_dict")
order_string = alipay.api_alipay_trade_page_pay(
out_trade_no=req_dict['tradeno'],
total_amount=req_dict['totalamount'],
subject=req_dict['subject'],
return_url='http://localhost:8080/django3qu6u/mianshijieguo/notify',
#notify_url=''
)
pay_url = 'https://openapi.alipaydev.com/gateway.do?' + order_string
pay_url = '<form name="punchout_form" method="post" action="{0}"><input type="hidden" name="biz_content" ><input type="submit" value="立即支付" style="display: none"></form>'.format(pay_url)
return JsonResponse({'code': 0, "data": pay_url})
def mianshijieguo_notify(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
out_trade_no = req_dict['out_trade_no']
cursor = connection.cursor()
return redirect('http://localhost:8080/django3qu6u/admin/dist/index.html#/mianshijieguo')

@ -0,0 +1,733 @@
#coding:utf-8
__author__ = "ila"
import base64, copy, logging, os, time, xlrd
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import mianshiyaoqing
from util.codes import *
from util.auth import Auth
from util.common import Common
import util.message as mes
from django.db import connection
import random
from django.core.mail import send_mail
from alipay import AliPayConfig, AliPay
from django.conf import settings
from django.shortcuts import redirect
def mianshiyaoqing_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = mianshiyaoqing.createbyreq(mianshiyaoqing, mianshiyaoqing, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def mianshiyaoqing_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = mianshiyaoqing.getbyparams(mianshiyaoqing, mianshiyaoqing, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= mianshiyaoqing.__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, mianshiyaoqing, req_dict)
def mianshiyaoqing_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def mianshiyaoqing_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
columns= mianshiyaoqing.getallcolumn( mianshiyaoqing, mianshiyaoqing)
try:
__loginUserColumn__= mianshiyaoqing.__loginUserColumn__
except:
__loginUserColumn__=None
username=req_dict.get(list(req_dict.keys())[0])
if __loginUserColumn__:
username_str=__loginUserColumn__
else:
username_str=username
if 'mima' in columns:
password_str='mima'
else:
password_str='password'
init_pwd = '123456'
eval('''mianshiyaoqing.objects.filter({}='{}').update({}='{}')'''.format(username_str,username,password_str,init_pwd))
return JsonResponse(msg)
def mianshiyaoqing_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'] = mianshiyaoqing.getbyparams(mianshiyaoqing, mianshiyaoqing, req_dict)[0]
return JsonResponse(msg)
def mianshiyaoqing_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=mianshiyaoqing.getbyparams(mianshiyaoqing, mianshiyaoqing, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def mianshiyaoqing_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= mianshiyaoqing.getallcolumn( mianshiyaoqing, mianshiyaoqing)
#当前登录用户所在表
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__=mianshiyaoqing.__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__=mianshiyaoqing.__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 'mianshiyaoqing'[:7]!='discuss'and "userid" in mianshiyaoqing.getallcolumn(mianshiyaoqing,mianshiyaoqing):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=mianshiyaoqing.__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'] =mianshiyaoqing.page(mianshiyaoqing, mianshiyaoqing, req_dict)
return JsonResponse(msg)
def mianshiyaoqing_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 mianshiyaoqing.getallcolumn(mianshiyaoqing,mianshiyaoqing):
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'] = mianshiyaoqing.page(mianshiyaoqing,mianshiyaoqing, req_dict)
return JsonResponse(msg)
def mianshiyaoqing_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= mianshiyaoqing.getallcolumn( mianshiyaoqing, mianshiyaoqing)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=mianshiyaoqing.__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__=mianshiyaoqing.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=mianshiyaoqing.__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__=mianshiyaoqing.__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 mianshiyaoqing.__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'] = mianshiyaoqing.page(mianshiyaoqing, mianshiyaoqing, req_dict)
return JsonResponse(msg)
def mianshiyaoqing_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= mianshiyaoqing.getallcolumn( mianshiyaoqing, mianshiyaoqing)
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= mianshiyaoqing.createbyreq(mianshiyaoqing,mianshiyaoqing, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def mianshiyaoqing_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= mianshiyaoqing.getallcolumn( mianshiyaoqing, mianshiyaoqing)
try:
__authSeparate__=mianshiyaoqing.__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__=mianshiyaoqing.__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= mianshiyaoqing.createbyreq(mianshiyaoqing,mianshiyaoqing, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def mianshiyaoqing_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=mianshiyaoqing.getbyid(mianshiyaoqing,mianshiyaoqing,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 = mianshiyaoqing.updatebyparams(mianshiyaoqing,mianshiyaoqing, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def mianshiyaoqing_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = mianshiyaoqing.getbyid(mianshiyaoqing,mianshiyaoqing, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= mianshiyaoqing.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in mianshiyaoqing.getallcolumn(mianshiyaoqing,mianshiyaoqing):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=mianshiyaoqing.updatebyparams(mianshiyaoqing,mianshiyaoqing,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def mianshiyaoqing_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =mianshiyaoqing.getbyid(mianshiyaoqing,mianshiyaoqing, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= mianshiyaoqing.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in mianshiyaoqing.getallcolumn(mianshiyaoqing,mianshiyaoqing):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=mianshiyaoqing.updatebyparams(mianshiyaoqing,mianshiyaoqing,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def mianshiyaoqing_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 mianshiyaoqing.getallcolumn(mianshiyaoqing,mianshiyaoqing) :
del req_dict["mima"]
if "password" not in mianshiyaoqing.getallcolumn(mianshiyaoqing,mianshiyaoqing) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = mianshiyaoqing.updatebyparams(mianshiyaoqing, mianshiyaoqing, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def mianshiyaoqing_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=mianshiyaoqing.deletes(mianshiyaoqing,
mianshiyaoqing,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def mianshiyaoqing_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= mianshiyaoqing.getbyid(mianshiyaoqing, mianshiyaoqing, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=mianshiyaoqing.updatebyparams(mianshiyaoqing,mianshiyaoqing,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def mianshiyaoqing_importExcel(request):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
excel_file = request.FILES.get("file", "")
file_type = excel_file.name.split('.')[1]
if file_type in ['xlsx', 'xls']:
data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())
table = data.sheets()[0]
rows = table.nrows
try:
for row in range(1, rows):
row_values = table.row_values(row)
req_dict = {}
mianshiyaoqing.createbyreq(mianshiyaoqing, mianshiyaoqing, req_dict)
except:
pass
else:
msg.code = 500
msg.msg = "文件类型错误"
return JsonResponse(msg)
def mianshiyaoqing_sendemail(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
code = random.sample(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 4)
to = []
to.append(req_dict['email'])
send_mail('用户注册', '您的注册验证码是【'+''.join(code)+'】,请不要把验证码泄漏给其他人,如非本人请勿操作。', 'yclw9@qq.com', to, fail_silently = False)
cursor = connection.cursor()
cursor.execute("insert into emailregistercode(email,role,code) values('"+req_dict['email']+"','用户','"+''.join(code)+"')")
msg = {
"msg": "发送成功",
"code": 0
}
return JsonResponse(msg)
def mianshiyaoqing_autoSort2(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
cursor = connection.cursor()
leixing = set()
try:
cursor.execute("select goodtype from orders where userid = %d"%(request.session.get("params").get("id"))+" and tablename = 'mianshiyaoqing' order by addtime desc")
rows = cursor.fetchall()
for row in rows:
for item in row:
leixing.add(item)
except:
leixing = set()
L = []
cursor.execute("select * from mianshiyaoqing where $intelRecomColumn in ('%s"%("','").join(leixing)+"') union all select * from mianshiyaoqing where $intelRecomColumn not in('%s"%("','").join(leixing)+"')")
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
return JsonResponse({"code": 0, "msg": '', "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":5,"list": L[0:6]}})
def mianshiyaoqing_value(request, xColumnName, yColumnName, timeStatType):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and gongsizhanghao ='{0}' ".format(decode_str['params']['gongsizhanghao'])
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and zhanghao ='{0}' ".format(decode_str['params']['zhanghao'])
sql = ''
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM mianshiyaoqing {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d')".format(xColumnName, yColumnName, where, '%Y-%m-%d')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM mianshiyaoqing {2} GROUP BY DATE_FORMAT({0}, '%Y-%m')".format(xColumnName, yColumnName, where, '%Y-%m')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM mianshiyaoqing {2} GROUP BY DATE_FORMAT({0}, '%Y')".format(xColumnName, yColumnName, where, '%Y')
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def mianshiyaoqing_o_value(request, xColumnName, yColumnName):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and gongsizhanghao ='{0}' ".format(decode_str['params']['gongsizhanghao'])
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and zhanghao ='{0}' ".format(decode_str['params']['zhanghao'])
sql = "SELECT {0}, sum({1}) AS total FROM mianshiyaoqing {2} GROUP BY {0}".format(xColumnName, yColumnName, where)
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def mianshiyaoqing_alipay(request):
if request.method in ["POST", "GET"]:
alipay = AliPay(
appid=settings.ALIPAY_APP_ID,
app_notify_url=None,
app_private_key_string=settings.APP_PRIVATE_KEY_STRING,
alipay_public_key_string=settings.ALIPAY_PUBLIC_KEY_STRING,
sign_type=settings.ALIPAY_SIGN_TYPE,
debug=True,
config=AliPayConfig(timeout=15)
)
req_dict = request.session.get("req_dict")
order_string = alipay.api_alipay_trade_page_pay(
out_trade_no=req_dict['tradeno'],
total_amount=req_dict['totalamount'],
subject=req_dict['subject'],
return_url='http://localhost:8080/django3qu6u/mianshiyaoqing/notify',
#notify_url=''
)
pay_url = 'https://openapi.alipaydev.com/gateway.do?' + order_string
pay_url = '<form name="punchout_form" method="post" action="{0}"><input type="hidden" name="biz_content" ><input type="submit" value="立即支付" style="display: none"></form>'.format(pay_url)
return JsonResponse({'code': 0, "data": pay_url})
def mianshiyaoqing_notify(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
out_trade_no = req_dict['out_trade_no']
cursor = connection.cursor()
return redirect('http://localhost:8080/django3qu6u/admin/dist/index.html#/mianshiyaoqing')

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

@ -0,0 +1,717 @@
#coding:utf-8
__author__ = "ila"
import base64, copy, logging, os, time, xlrd
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import storeup
from util.codes import *
from util.auth import Auth
from util.common import Common
import util.message as mes
from django.db import connection
import random
from django.core.mail import send_mail
from alipay import AliPayConfig, AliPay
from django.conf import settings
from django.shortcuts import redirect
def 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")
columns= storeup.getallcolumn( storeup, storeup)
try:
__loginUserColumn__= storeup.__loginUserColumn__
except:
__loginUserColumn__=None
username=req_dict.get(list(req_dict.keys())[0])
if __loginUserColumn__:
username_str=__loginUserColumn__
else:
username_str=username
if 'mima' in columns:
password_str='mima'
else:
password_str='password'
init_pwd = '123456'
eval('''storeup.objects.filter({}='{}').update({}='{}')'''.format(username_str,username,password_str,init_pwd))
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 'storeup'[:7]!='discuss'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)
def storeup_importExcel(request):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
excel_file = request.FILES.get("file", "")
file_type = excel_file.name.split('.')[1]
if file_type in ['xlsx', 'xls']:
data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())
table = data.sheets()[0]
rows = table.nrows
try:
for row in range(1, rows):
row_values = table.row_values(row)
req_dict = {}
storeup.createbyreq(storeup, storeup, req_dict)
except:
pass
else:
msg.code = 500
msg.msg = "文件类型错误"
return JsonResponse(msg)
def storeup_sendemail(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
code = random.sample(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 4)
to = []
to.append(req_dict['email'])
send_mail('用户注册', '您的注册验证码是【'+''.join(code)+'】,请不要把验证码泄漏给其他人,如非本人请勿操作。', 'yclw9@qq.com', to, fail_silently = False)
cursor = connection.cursor()
cursor.execute("insert into emailregistercode(email,role,code) values('"+req_dict['email']+"','用户','"+''.join(code)+"')")
msg = {
"msg": "发送成功",
"code": 0
}
return JsonResponse(msg)
def storeup_autoSort2(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
cursor = connection.cursor()
leixing = set()
try:
cursor.execute("select goodtype from orders where userid = %d"%(request.session.get("params").get("id"))+" and tablename = 'storeup' order by addtime desc")
rows = cursor.fetchall()
for row in rows:
for item in row:
leixing.add(item)
except:
leixing = set()
L = []
cursor.execute("select * from storeup where $intelRecomColumn in ('%s"%("','").join(leixing)+"') union all select * from storeup where $intelRecomColumn not in('%s"%("','").join(leixing)+"')")
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
return JsonResponse({"code": 0, "msg": '', "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":5,"list": L[0:6]}})
def storeup_value(request, xColumnName, yColumnName, timeStatType):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
sql = ''
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM storeup {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d')".format(xColumnName, yColumnName, where, '%Y-%m-%d')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM storeup {2} GROUP BY DATE_FORMAT({0}, '%Y-%m')".format(xColumnName, yColumnName, where, '%Y-%m')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM storeup {2} GROUP BY DATE_FORMAT({0}, '%Y')".format(xColumnName, yColumnName, where, '%Y')
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def storeup_o_value(request, xColumnName, yColumnName):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
sql = "SELECT {0}, sum({1}) AS total FROM storeup {2} GROUP BY {0}".format(xColumnName, yColumnName, where)
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def storeup_alipay(request):
if request.method in ["POST", "GET"]:
alipay = AliPay(
appid=settings.ALIPAY_APP_ID,
app_notify_url=None,
app_private_key_string=settings.APP_PRIVATE_KEY_STRING,
alipay_public_key_string=settings.ALIPAY_PUBLIC_KEY_STRING,
sign_type=settings.ALIPAY_SIGN_TYPE,
debug=True,
config=AliPayConfig(timeout=15)
)
req_dict = request.session.get("req_dict")
order_string = alipay.api_alipay_trade_page_pay(
out_trade_no=req_dict['tradeno'],
total_amount=req_dict['totalamount'],
subject=req_dict['subject'],
return_url='http://localhost:8080/django3qu6u/storeup/notify',
#notify_url=''
)
pay_url = 'https://openapi.alipaydev.com/gateway.do?' + order_string
pay_url = '<form name="punchout_form" method="post" action="{0}"><input type="hidden" name="biz_content" ><input type="submit" value="立即支付" style="display: none"></form>'.format(pay_url)
return JsonResponse({'code': 0, "data": pay_url})
def storeup_notify(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
out_trade_no = req_dict['out_trade_no']
cursor = connection.cursor()
return redirect('http://localhost:8080/django3qu6u/admin/dist/index.html#/storeup')

@ -0,0 +1,717 @@
#coding:utf-8
__author__ = "ila"
import base64, copy, logging, os, time, xlrd
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import tongzhigonggao
from util.codes import *
from util.auth import Auth
from util.common import Common
import util.message as mes
from django.db import connection
import random
from django.core.mail import send_mail
from alipay import AliPayConfig, AliPay
from django.conf import settings
from django.shortcuts import redirect
def tongzhigonggao_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = tongzhigonggao.createbyreq(tongzhigonggao, tongzhigonggao, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def tongzhigonggao_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = tongzhigonggao.getbyparams(tongzhigonggao, tongzhigonggao, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= tongzhigonggao.__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, tongzhigonggao, req_dict)
def tongzhigonggao_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def tongzhigonggao_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
columns= tongzhigonggao.getallcolumn( tongzhigonggao, tongzhigonggao)
try:
__loginUserColumn__= tongzhigonggao.__loginUserColumn__
except:
__loginUserColumn__=None
username=req_dict.get(list(req_dict.keys())[0])
if __loginUserColumn__:
username_str=__loginUserColumn__
else:
username_str=username
if 'mima' in columns:
password_str='mima'
else:
password_str='password'
init_pwd = '123456'
eval('''tongzhigonggao.objects.filter({}='{}').update({}='{}')'''.format(username_str,username,password_str,init_pwd))
return JsonResponse(msg)
def tongzhigonggao_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'] = tongzhigonggao.getbyparams(tongzhigonggao, tongzhigonggao, req_dict)[0]
return JsonResponse(msg)
def tongzhigonggao_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=tongzhigonggao.getbyparams(tongzhigonggao, tongzhigonggao, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def tongzhigonggao_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= tongzhigonggao.getallcolumn( tongzhigonggao, tongzhigonggao)
#当前登录用户所在表
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__=tongzhigonggao.__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__=tongzhigonggao.__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 'tongzhigonggao'[:7]!='discuss'and "userid" in tongzhigonggao.getallcolumn(tongzhigonggao,tongzhigonggao):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=tongzhigonggao.__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'] =tongzhigonggao.page(tongzhigonggao, tongzhigonggao, req_dict)
return JsonResponse(msg)
def tongzhigonggao_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 tongzhigonggao.getallcolumn(tongzhigonggao,tongzhigonggao):
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'] = tongzhigonggao.page(tongzhigonggao,tongzhigonggao, req_dict)
return JsonResponse(msg)
def tongzhigonggao_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= tongzhigonggao.getallcolumn( tongzhigonggao, tongzhigonggao)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=tongzhigonggao.__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__=tongzhigonggao.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=tongzhigonggao.__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__=tongzhigonggao.__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 tongzhigonggao.__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'] = tongzhigonggao.page(tongzhigonggao, tongzhigonggao, req_dict)
return JsonResponse(msg)
def tongzhigonggao_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= tongzhigonggao.getallcolumn( tongzhigonggao, tongzhigonggao)
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= tongzhigonggao.createbyreq(tongzhigonggao,tongzhigonggao, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def tongzhigonggao_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= tongzhigonggao.getallcolumn( tongzhigonggao, tongzhigonggao)
try:
__authSeparate__=tongzhigonggao.__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__=tongzhigonggao.__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= tongzhigonggao.createbyreq(tongzhigonggao,tongzhigonggao, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def tongzhigonggao_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=tongzhigonggao.getbyid(tongzhigonggao,tongzhigonggao,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 = tongzhigonggao.updatebyparams(tongzhigonggao,tongzhigonggao, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def tongzhigonggao_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = tongzhigonggao.getbyid(tongzhigonggao,tongzhigonggao, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= tongzhigonggao.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in tongzhigonggao.getallcolumn(tongzhigonggao,tongzhigonggao):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=tongzhigonggao.updatebyparams(tongzhigonggao,tongzhigonggao,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def tongzhigonggao_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =tongzhigonggao.getbyid(tongzhigonggao,tongzhigonggao, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= tongzhigonggao.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in tongzhigonggao.getallcolumn(tongzhigonggao,tongzhigonggao):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=tongzhigonggao.updatebyparams(tongzhigonggao,tongzhigonggao,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def tongzhigonggao_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 tongzhigonggao.getallcolumn(tongzhigonggao,tongzhigonggao) :
del req_dict["mima"]
if "password" not in tongzhigonggao.getallcolumn(tongzhigonggao,tongzhigonggao) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = tongzhigonggao.updatebyparams(tongzhigonggao, tongzhigonggao, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def tongzhigonggao_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=tongzhigonggao.deletes(tongzhigonggao,
tongzhigonggao,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def tongzhigonggao_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= tongzhigonggao.getbyid(tongzhigonggao, tongzhigonggao, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=tongzhigonggao.updatebyparams(tongzhigonggao,tongzhigonggao,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def tongzhigonggao_importExcel(request):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
excel_file = request.FILES.get("file", "")
file_type = excel_file.name.split('.')[1]
if file_type in ['xlsx', 'xls']:
data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())
table = data.sheets()[0]
rows = table.nrows
try:
for row in range(1, rows):
row_values = table.row_values(row)
req_dict = {}
tongzhigonggao.createbyreq(tongzhigonggao, tongzhigonggao, req_dict)
except:
pass
else:
msg.code = 500
msg.msg = "文件类型错误"
return JsonResponse(msg)
def tongzhigonggao_sendemail(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
code = random.sample(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 4)
to = []
to.append(req_dict['email'])
send_mail('用户注册', '您的注册验证码是【'+''.join(code)+'】,请不要把验证码泄漏给其他人,如非本人请勿操作。', 'yclw9@qq.com', to, fail_silently = False)
cursor = connection.cursor()
cursor.execute("insert into emailregistercode(email,role,code) values('"+req_dict['email']+"','用户','"+''.join(code)+"')")
msg = {
"msg": "发送成功",
"code": 0
}
return JsonResponse(msg)
def tongzhigonggao_autoSort2(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
cursor = connection.cursor()
leixing = set()
try:
cursor.execute("select goodtype from orders where userid = %d"%(request.session.get("params").get("id"))+" and tablename = 'tongzhigonggao' order by addtime desc")
rows = cursor.fetchall()
for row in rows:
for item in row:
leixing.add(item)
except:
leixing = set()
L = []
cursor.execute("select * from tongzhigonggao where $intelRecomColumn in ('%s"%("','").join(leixing)+"') union all select * from tongzhigonggao where $intelRecomColumn not in('%s"%("','").join(leixing)+"')")
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
return JsonResponse({"code": 0, "msg": '', "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":5,"list": L[0:6]}})
def tongzhigonggao_value(request, xColumnName, yColumnName, timeStatType):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
sql = ''
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM tongzhigonggao {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d')".format(xColumnName, yColumnName, where, '%Y-%m-%d')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM tongzhigonggao {2} GROUP BY DATE_FORMAT({0}, '%Y-%m')".format(xColumnName, yColumnName, where, '%Y-%m')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM tongzhigonggao {2} GROUP BY DATE_FORMAT({0}, '%Y')".format(xColumnName, yColumnName, where, '%Y')
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def tongzhigonggao_o_value(request, xColumnName, yColumnName):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
sql = "SELECT {0}, sum({1}) AS total FROM tongzhigonggao {2} GROUP BY {0}".format(xColumnName, yColumnName, where)
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def tongzhigonggao_alipay(request):
if request.method in ["POST", "GET"]:
alipay = AliPay(
appid=settings.ALIPAY_APP_ID,
app_notify_url=None,
app_private_key_string=settings.APP_PRIVATE_KEY_STRING,
alipay_public_key_string=settings.ALIPAY_PUBLIC_KEY_STRING,
sign_type=settings.ALIPAY_SIGN_TYPE,
debug=True,
config=AliPayConfig(timeout=15)
)
req_dict = request.session.get("req_dict")
order_string = alipay.api_alipay_trade_page_pay(
out_trade_no=req_dict['tradeno'],
total_amount=req_dict['totalamount'],
subject=req_dict['subject'],
return_url='http://localhost:8080/django3qu6u/tongzhigonggao/notify',
#notify_url=''
)
pay_url = 'https://openapi.alipaydev.com/gateway.do?' + order_string
pay_url = '<form name="punchout_form" method="post" action="{0}"><input type="hidden" name="biz_content" ><input type="submit" value="立即支付" style="display: none"></form>'.format(pay_url)
return JsonResponse({'code': 0, "data": pay_url})
def tongzhigonggao_notify(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
out_trade_no = req_dict['out_trade_no']
cursor = connection.cursor()
return redirect('http://localhost:8080/django3qu6u/admin/dist/index.html#/tongzhigonggao')

@ -0,0 +1,733 @@
#coding:utf-8
__author__ = "ila"
import base64, copy, logging, os, time, xlrd
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import toudijianli
from util.codes import *
from util.auth import Auth
from util.common import Common
import util.message as mes
from django.db import connection
import random
from django.core.mail import send_mail
from alipay import AliPayConfig, AliPay
from django.conf import settings
from django.shortcuts import redirect
def toudijianli_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = toudijianli.createbyreq(toudijianli, toudijianli, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def toudijianli_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = toudijianli.getbyparams(toudijianli, toudijianli, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= toudijianli.__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, toudijianli, req_dict)
def toudijianli_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def toudijianli_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
columns= toudijianli.getallcolumn( toudijianli, toudijianli)
try:
__loginUserColumn__= toudijianli.__loginUserColumn__
except:
__loginUserColumn__=None
username=req_dict.get(list(req_dict.keys())[0])
if __loginUserColumn__:
username_str=__loginUserColumn__
else:
username_str=username
if 'mima' in columns:
password_str='mima'
else:
password_str='password'
init_pwd = '123456'
eval('''toudijianli.objects.filter({}='{}').update({}='{}')'''.format(username_str,username,password_str,init_pwd))
return JsonResponse(msg)
def toudijianli_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'] = toudijianli.getbyparams(toudijianli, toudijianli, req_dict)[0]
return JsonResponse(msg)
def toudijianli_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=toudijianli.getbyparams(toudijianli, toudijianli, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def toudijianli_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= toudijianli.getallcolumn( toudijianli, toudijianli)
#当前登录用户所在表
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__=toudijianli.__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__=toudijianli.__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 'toudijianli'[:7]!='discuss'and "userid" in toudijianli.getallcolumn(toudijianli,toudijianli):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=toudijianli.__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'] =toudijianli.page(toudijianli, toudijianli, req_dict)
return JsonResponse(msg)
def toudijianli_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 toudijianli.getallcolumn(toudijianli,toudijianli):
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'] = toudijianli.page(toudijianli,toudijianli, req_dict)
return JsonResponse(msg)
def toudijianli_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= toudijianli.getallcolumn( toudijianli, toudijianli)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=toudijianli.__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__=toudijianli.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=toudijianli.__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__=toudijianli.__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 toudijianli.__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'] = toudijianli.page(toudijianli, toudijianli, req_dict)
return JsonResponse(msg)
def toudijianli_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= toudijianli.getallcolumn( toudijianli, toudijianli)
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= toudijianli.createbyreq(toudijianli,toudijianli, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def toudijianli_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= toudijianli.getallcolumn( toudijianli, toudijianli)
try:
__authSeparate__=toudijianli.__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__=toudijianli.__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= toudijianli.createbyreq(toudijianli,toudijianli, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def toudijianli_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=toudijianli.getbyid(toudijianli,toudijianli,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 = toudijianli.updatebyparams(toudijianli,toudijianli, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def toudijianli_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = toudijianli.getbyid(toudijianli,toudijianli, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= toudijianli.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in toudijianli.getallcolumn(toudijianli,toudijianli):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=toudijianli.updatebyparams(toudijianli,toudijianli,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def toudijianli_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =toudijianli.getbyid(toudijianli,toudijianli, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= toudijianli.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in toudijianli.getallcolumn(toudijianli,toudijianli):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=toudijianli.updatebyparams(toudijianli,toudijianli,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def toudijianli_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 toudijianli.getallcolumn(toudijianli,toudijianli) :
del req_dict["mima"]
if "password" not in toudijianli.getallcolumn(toudijianli,toudijianli) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = toudijianli.updatebyparams(toudijianli, toudijianli, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def toudijianli_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=toudijianli.deletes(toudijianli,
toudijianli,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def toudijianli_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= toudijianli.getbyid(toudijianli, toudijianli, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=toudijianli.updatebyparams(toudijianli,toudijianli,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def toudijianli_importExcel(request):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
excel_file = request.FILES.get("file", "")
file_type = excel_file.name.split('.')[1]
if file_type in ['xlsx', 'xls']:
data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())
table = data.sheets()[0]
rows = table.nrows
try:
for row in range(1, rows):
row_values = table.row_values(row)
req_dict = {}
toudijianli.createbyreq(toudijianli, toudijianli, req_dict)
except:
pass
else:
msg.code = 500
msg.msg = "文件类型错误"
return JsonResponse(msg)
def toudijianli_sendemail(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
code = random.sample(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 4)
to = []
to.append(req_dict['email'])
send_mail('用户注册', '您的注册验证码是【'+''.join(code)+'】,请不要把验证码泄漏给其他人,如非本人请勿操作。', 'yclw9@qq.com', to, fail_silently = False)
cursor = connection.cursor()
cursor.execute("insert into emailregistercode(email,role,code) values('"+req_dict['email']+"','用户','"+''.join(code)+"')")
msg = {
"msg": "发送成功",
"code": 0
}
return JsonResponse(msg)
def toudijianli_autoSort2(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
cursor = connection.cursor()
leixing = set()
try:
cursor.execute("select goodtype from orders where userid = %d"%(request.session.get("params").get("id"))+" and tablename = 'toudijianli' order by addtime desc")
rows = cursor.fetchall()
for row in rows:
for item in row:
leixing.add(item)
except:
leixing = set()
L = []
cursor.execute("select * from toudijianli where $intelRecomColumn in ('%s"%("','").join(leixing)+"') union all select * from toudijianli where $intelRecomColumn not in('%s"%("','").join(leixing)+"')")
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
return JsonResponse({"code": 0, "msg": '', "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":5,"list": L[0:6]}})
def toudijianli_value(request, xColumnName, yColumnName, timeStatType):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and zhanghao ='{0}' ".format(decode_str['params']['zhanghao'])
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and gongsizhanghao ='{0}' ".format(decode_str['params']['gongsizhanghao'])
sql = ''
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM toudijianli {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d')".format(xColumnName, yColumnName, where, '%Y-%m-%d')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM toudijianli {2} GROUP BY DATE_FORMAT({0}, '%Y-%m')".format(xColumnName, yColumnName, where, '%Y-%m')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM toudijianli {2} GROUP BY DATE_FORMAT({0}, '%Y')".format(xColumnName, yColumnName, where, '%Y')
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def toudijianli_o_value(request, xColumnName, yColumnName):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and zhanghao ='{0}' ".format(decode_str['params']['zhanghao'])
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and gongsizhanghao ='{0}' ".format(decode_str['params']['gongsizhanghao'])
sql = "SELECT {0}, sum({1}) AS total FROM toudijianli {2} GROUP BY {0}".format(xColumnName, yColumnName, where)
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def toudijianli_alipay(request):
if request.method in ["POST", "GET"]:
alipay = AliPay(
appid=settings.ALIPAY_APP_ID,
app_notify_url=None,
app_private_key_string=settings.APP_PRIVATE_KEY_STRING,
alipay_public_key_string=settings.ALIPAY_PUBLIC_KEY_STRING,
sign_type=settings.ALIPAY_SIGN_TYPE,
debug=True,
config=AliPayConfig(timeout=15)
)
req_dict = request.session.get("req_dict")
order_string = alipay.api_alipay_trade_page_pay(
out_trade_no=req_dict['tradeno'],
total_amount=req_dict['totalamount'],
subject=req_dict['subject'],
return_url='http://localhost:8080/django3qu6u/toudijianli/notify',
#notify_url=''
)
pay_url = 'https://openapi.alipaydev.com/gateway.do?' + order_string
pay_url = '<form name="punchout_form" method="post" action="{0}"><input type="hidden" name="biz_content" ><input type="submit" value="立即支付" style="display: none"></form>'.format(pay_url)
return JsonResponse({'code': 0, "data": pay_url})
def toudijianli_notify(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
out_trade_no = req_dict['out_trade_no']
cursor = connection.cursor()
return redirect('http://localhost:8080/django3qu6u/admin/dist/index.html#/toudijianli')

@ -0,0 +1,725 @@
#coding:utf-8
__author__ = "ila"
import base64, copy, logging, os, time, xlrd
from django.http import JsonResponse
from django.apps import apps
from django.db.models.aggregates import Count,Sum
from .models import zhaopinxinxi
from util.codes import *
from util.auth import Auth
from util.common import Common
import util.message as mes
from django.db import connection
import random
from django.core.mail import send_mail
from alipay import AliPayConfig, AliPay
from django.conf import settings
from django.shortcuts import redirect
def zhaopinxinxi_register(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
error = zhaopinxinxi.createbyreq(zhaopinxinxi, zhaopinxinxi, req_dict)
if error != None:
msg['code'] = crud_error_code
msg['msg'] = "用户已存在,请勿重复注册!"
return JsonResponse(msg)
def zhaopinxinxi_login(request):
if request.method in ["POST", "GET"]:
msg = {'code': normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
datas = zhaopinxinxi.getbyparams(zhaopinxinxi, zhaopinxinxi, req_dict)
if not datas:
msg['code'] = password_error_code
msg['msg'] = mes.password_error_code
return JsonResponse(msg)
try:
__sfsh__= zhaopinxinxi.__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, zhaopinxinxi, req_dict)
def zhaopinxinxi_logout(request):
if request.method in ["POST", "GET"]:
msg = {
"msg": "登出成功",
"code": 0
}
return JsonResponse(msg)
def zhaopinxinxi_resetPass(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code}
req_dict = request.session.get("req_dict")
columns= zhaopinxinxi.getallcolumn( zhaopinxinxi, zhaopinxinxi)
try:
__loginUserColumn__= zhaopinxinxi.__loginUserColumn__
except:
__loginUserColumn__=None
username=req_dict.get(list(req_dict.keys())[0])
if __loginUserColumn__:
username_str=__loginUserColumn__
else:
username_str=username
if 'mima' in columns:
password_str='mima'
else:
password_str='password'
init_pwd = '123456'
eval('''zhaopinxinxi.objects.filter({}='{}').update({}='{}')'''.format(username_str,username,password_str,init_pwd))
return JsonResponse(msg)
def zhaopinxinxi_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'] = zhaopinxinxi.getbyparams(zhaopinxinxi, zhaopinxinxi, req_dict)[0]
return JsonResponse(msg)
def zhaopinxinxi_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=zhaopinxinxi.getbyparams(zhaopinxinxi, zhaopinxinxi, req_dict)
if len(data)>0:
msg['data'] = data[0]
else:
msg['data'] = {}
return JsonResponse(msg)
def zhaopinxinxi_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= zhaopinxinxi.getallcolumn( zhaopinxinxi, zhaopinxinxi)
#当前登录用户所在表
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__=zhaopinxinxi.__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__=zhaopinxinxi.__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 'zhaopinxinxi'[:7]!='discuss'and "userid" in zhaopinxinxi.getallcolumn(zhaopinxinxi,zhaopinxinxi):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致]则对应的表有个隐藏属性authTable为”是”那么该用户查看该表信息时只能查看自己的
try:
__authTables__=zhaopinxinxi.__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'] =zhaopinxinxi.page(zhaopinxinxi, zhaopinxinxi, req_dict)
return JsonResponse(msg)
def zhaopinxinxi_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 zhaopinxinxi.getallcolumn(zhaopinxinxi,zhaopinxinxi):
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'] = zhaopinxinxi.page(zhaopinxinxi,zhaopinxinxi, req_dict)
return JsonResponse(msg)
def zhaopinxinxi_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= zhaopinxinxi.getallcolumn( zhaopinxinxi, zhaopinxinxi)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=zhaopinxinxi.__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__=zhaopinxinxi.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=zhaopinxinxi.__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__=zhaopinxinxi.__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 zhaopinxinxi.__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'] = zhaopinxinxi.page(zhaopinxinxi, zhaopinxinxi, req_dict)
return JsonResponse(msg)
def zhaopinxinxi_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= zhaopinxinxi.getallcolumn( zhaopinxinxi, zhaopinxinxi)
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= zhaopinxinxi.createbyreq(zhaopinxinxi,zhaopinxinxi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def zhaopinxinxi_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= zhaopinxinxi.getallcolumn( zhaopinxinxi, zhaopinxinxi)
try:
__authSeparate__=zhaopinxinxi.__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__=zhaopinxinxi.__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= zhaopinxinxi.createbyreq(zhaopinxinxi,zhaopinxinxi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def zhaopinxinxi_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=zhaopinxinxi.getbyid(zhaopinxinxi,zhaopinxinxi,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 = zhaopinxinxi.updatebyparams(zhaopinxinxi,zhaopinxinxi, update_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def zhaopinxinxi_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = zhaopinxinxi.getbyid(zhaopinxinxi,zhaopinxinxi, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= zhaopinxinxi.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in zhaopinxinxi.getallcolumn(zhaopinxinxi,zhaopinxinxi):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=zhaopinxinxi.updatebyparams(zhaopinxinxi,zhaopinxinxi,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def zhaopinxinxi_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =zhaopinxinxi.getbyid(zhaopinxinxi,zhaopinxinxi, int(id_))
if len(data)>0:
msg['data']=data[0]
#浏览点击次数
try:
__browseClick__= zhaopinxinxi.__browseClick__
except:
__browseClick__=None
if __browseClick__=="" and "clicknum" in zhaopinxinxi.getallcolumn(zhaopinxinxi,zhaopinxinxi):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=zhaopinxinxi.updatebyparams(zhaopinxinxi,zhaopinxinxi,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def zhaopinxinxi_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 zhaopinxinxi.getallcolumn(zhaopinxinxi,zhaopinxinxi) :
del req_dict["mima"]
if "password" not in zhaopinxinxi.getallcolumn(zhaopinxinxi,zhaopinxinxi) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = zhaopinxinxi.updatebyparams(zhaopinxinxi, zhaopinxinxi, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def zhaopinxinxi_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=zhaopinxinxi.deletes(zhaopinxinxi,
zhaopinxinxi,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def zhaopinxinxi_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= zhaopinxinxi.getbyid(zhaopinxinxi, zhaopinxinxi, int(id_))
for i in data:
votenum=i.get('votenum')
if votenum!=None:
params={"id":int(id_),"votenum":votenum+1}
error=zhaopinxinxi.updatebyparams(zhaopinxinxi,zhaopinxinxi,params)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def zhaopinxinxi_importExcel(request):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
excel_file = request.FILES.get("file", "")
file_type = excel_file.name.split('.')[1]
if file_type in ['xlsx', 'xls']:
data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())
table = data.sheets()[0]
rows = table.nrows
try:
for row in range(1, rows):
row_values = table.row_values(row)
req_dict = {}
zhaopinxinxi.createbyreq(zhaopinxinxi, zhaopinxinxi, req_dict)
except:
pass
else:
msg.code = 500
msg.msg = "文件类型错误"
return JsonResponse(msg)
def zhaopinxinxi_sendemail(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
code = random.sample(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 4)
to = []
to.append(req_dict['email'])
send_mail('用户注册', '您的注册验证码是【'+''.join(code)+'】,请不要把验证码泄漏给其他人,如非本人请勿操作。', 'yclw9@qq.com', to, fail_silently = False)
cursor = connection.cursor()
cursor.execute("insert into emailregistercode(email,role,code) values('"+req_dict['email']+"','用户','"+''.join(code)+"')")
msg = {
"msg": "发送成功",
"code": 0
}
return JsonResponse(msg)
def zhaopinxinxi_autoSort2(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
cursor = connection.cursor()
leixing = set()
try:
cursor.execute("select goodtype from orders where userid = %d"%(request.session.get("params").get("id"))+" and tablename = 'zhaopinxinxi' order by addtime desc")
rows = cursor.fetchall()
for row in rows:
for item in row:
leixing.add(item)
except:
leixing = set()
L = []
cursor.execute("select * from zhaopinxinxi where $intelRecomColumn in ('%s"%("','").join(leixing)+"') union all select * from zhaopinxinxi where $intelRecomColumn not in('%s"%("','").join(leixing)+"')")
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
return JsonResponse({"code": 0, "msg": '', "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":5,"list": L[0:6]}})
def zhaopinxinxi_value(request, xColumnName, yColumnName, timeStatType):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and gongsizhanghao ='{0}' ".format(decode_str['params']['gongsizhanghao'])
sql = ''
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM zhaopinxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d')".format(xColumnName, yColumnName, where, '%Y-%m-%d')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM zhaopinxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m')".format(xColumnName, yColumnName, where, '%Y-%m')
if timeStatType == '':
sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM zhaopinxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y')".format(xColumnName, yColumnName, where, '%Y')
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def zhaopinxinxi_o_value(request, xColumnName, yColumnName):
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": "成功", "data": {}}
where = ' where 1 = 1 '
token = request.META.get('HTTP_TOKEN')
decode_str = eval(base64.b64decode(token).decode("utf8"))
if decode_str['tablename'] != 'users':
where = where + " and gongsizhanghao ='{0}' ".format(decode_str['params']['gongsizhanghao'])
sql = "SELECT {0}, sum({1}) AS total FROM zhaopinxinxi {2} GROUP BY {0}".format(xColumnName, yColumnName, where)
L = []
cursor = connection.cursor()
cursor.execute(sql)
desc = cursor.description
data_dict = [dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()]
for online_dict in data_dict:
for key in online_dict:
if 'datetime.datetime' in str(type(online_dict[key])):
online_dict[key] = online_dict[key].strftime(
"%Y-%m-%d %H:%M:%S")
else:
pass
L.append(online_dict)
msg['data'] = L
return JsonResponse(msg)
def zhaopinxinxi_alipay(request):
if request.method in ["POST", "GET"]:
alipay = AliPay(
appid=settings.ALIPAY_APP_ID,
app_notify_url=None,
app_private_key_string=settings.APP_PRIVATE_KEY_STRING,
alipay_public_key_string=settings.ALIPAY_PUBLIC_KEY_STRING,
sign_type=settings.ALIPAY_SIGN_TYPE,
debug=True,
config=AliPayConfig(timeout=15)
)
req_dict = request.session.get("req_dict")
order_string = alipay.api_alipay_trade_page_pay(
out_trade_no=req_dict['tradeno'],
total_amount=req_dict['totalamount'],
subject=req_dict['subject'],
return_url='http://localhost:8080/django3qu6u/zhaopinxinxi/notify',
#notify_url=''
)
pay_url = 'https://openapi.alipaydev.com/gateway.do?' + order_string
pay_url = '<form name="punchout_form" method="post" action="{0}"><input type="hidden" name="biz_content" ><input type="submit" value="立即支付" style="display: none"></form>'.format(pay_url)
return JsonResponse({'code': 0, "data": pay_url})
def zhaopinxinxi_notify(request):
if request.method in ["POST", "GET"]:
req_dict = request.session.get("req_dict")
out_trade_no = req_dict['out_trade_no']
cursor = connection.cursor()
return redirect('http://localhost:8080/django3qu6u/admin/dist/index.html#/zhaopinxinxi')

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

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

@ -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,162 @@
# 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()))),
path(r'{}/importExcel'.format(tableName.lower()),
eval("{}_v.{}_importExcel".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/sendemail'.format(tableName.lower()),
eval("{}_v.{}_sendemail".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/autoSort2'.format(tableName.lower()),
eval("{}_v.{}_autoSort2".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/value/<xColumnName>/<yColumnName>/<timeStatType>'.format(tableName.lower()),
eval("{}_v.{}_value".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/value/<xColumnName>/<yColumnName>'.format(tableName.lower()),
eval("{}_v.{}_o_value".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/alipay'.format(tableName.lower()),
eval("{}_v.{}_alipay".format(tableName.capitalize(), tableName.lower()))),
path(r'{}/notify'.format(tableName.lower()),
eval("{}_v.{}_notify".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,7 @@
django==2.0
django-threadlocals
pymysql
click
requests
xlrd
python-alipay-sdk

@ -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.fee01443.css" rel="preload" as="style"><link href="./css/chunk-vendors.6d894868.css" rel="preload" as="style"><link href="./js/app.3993825f.js" rel="preload" as="script"><link href="./js/chunk-vendors.7e405093.js" rel="preload" as="script"><link href="./css/chunk-vendors.6d894868.css" rel="stylesheet"><link href="./css/app.fee01443.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.7e405093.js"></script><script src="./js/app.3993825f.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

File diff suppressed because it is too large Load Diff

@ -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,13 @@
#canvas {
position: fixed;
top: 0;
left: 0;
width: 100%;
margin: 0;
overflow: hidden;
background: hsla(0, 5%, 5%, 1);
background-repeat: no-repeat;
background-attachment: fixed;
background-image: linear-gradient(to right top, hsla(0, 5%, 15%, 0.5), hsla(0, 5%, 5%, 1));
background-image: -moz-linear-gradient(to right top, hsla(0, 5%, 15%, 0.5), hsla(0, 5%, 5%, 1));
}

@ -0,0 +1,6 @@
#canvas {
background: rgba(0,0,0,1);
position: absolute;
left: 0;
top: 0;
}

@ -0,0 +1,5 @@
#canvas {
position: fixed;
left: 0;
top: 0;
}

@ -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

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

Loading…
Cancel
Save