@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
@ -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="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
|
||||
<component name="PyCharmProfessionalAdvertiser">
|
||||
<option name="shown" value="true" />
|
||||
</component>
|
||||
</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/pythonProject.iml" filepath="$PROJECT_DIR$/.idea/pythonProject.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,21 @@
|
||||
# # This is a sample Python script.
|
||||
#
|
||||
# # Press Shift+F10 to execute it or replace it with your code.
|
||||
# # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
|
||||
#
|
||||
#
|
||||
# def print_hi(name):
|
||||
# # Use a breakpoint in the code line below to debug your script.
|
||||
# print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
|
||||
#
|
||||
#
|
||||
# # Press the green button in the gutter to run the script.
|
||||
# if __name__ == '__main__':
|
||||
# print_hi('PyCharm')
|
||||
#
|
||||
# # See PyCharm help at https://www.jetbrains.com/help/pycharm/
|
||||
import os
|
||||
|
||||
# 假设你已经在 Django 项目的根目录下
|
||||
project_path = os.getcwd()
|
||||
print("Django project is located at:", project_path)
|
@ -0,0 +1,14 @@
|
||||
/server/myapp/migrations
|
||||
/server/myapp/views/__pycache__/
|
||||
/server/.idea
|
||||
/web/.idea
|
||||
/web/dist
|
||||
/web/node_modules
|
||||
/server/.idea/
|
||||
/.idea/
|
||||
__pycache__
|
||||
.idea
|
||||
server/.idea
|
||||
.DS_Store
|
||||
server/.DS_Store
|
||||
web/.DS_Store
|
@ -0,0 +1,782 @@
|
||||
/*
|
||||
Navicat Premium Data Transfer
|
||||
|
||||
Source Server : localhost连接
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 50737
|
||||
Source Host : localhost:3306
|
||||
Source Schema : python_team
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 50737
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 04/02/2024 17:29:54
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for auth_group
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `auth_group`;
|
||||
CREATE TABLE `auth_group` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `name`(`name`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of auth_group
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for auth_group_permissions
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `auth_group_permissions`;
|
||||
CREATE TABLE `auth_group_permissions` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`group_id` int(11) NOT NULL,
|
||||
`permission_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `auth_group_permissions_group_id_permission_id_0cd325b0_uniq`(`group_id`, `permission_id`) USING BTREE,
|
||||
INDEX `auth_group_permissio_permission_id_84c5c92e_fk_auth_perm`(`permission_id`) USING BTREE,
|
||||
CONSTRAINT `auth_group_permissio_permission_id_84c5c92e_fk_auth_perm` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `auth_group_permissions_group_id_b120cbf9_fk_auth_group_id` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of auth_group_permissions
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for auth_permission
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `auth_permission`;
|
||||
CREATE TABLE `auth_permission` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`content_type_id` int(11) NOT NULL,
|
||||
`codename` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `auth_permission_content_type_id_codename_01ab375a_uniq`(`content_type_id`, `codename`) USING BTREE,
|
||||
CONSTRAINT `auth_permission_content_type_id_2f476e4b_fk_django_co` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 85 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of auth_permission
|
||||
-- ----------------------------
|
||||
INSERT INTO `auth_permission` VALUES (1, 'Can add log entry', 1, 'add_logentry');
|
||||
INSERT INTO `auth_permission` VALUES (2, 'Can change log entry', 1, 'change_logentry');
|
||||
INSERT INTO `auth_permission` VALUES (3, 'Can delete log entry', 1, 'delete_logentry');
|
||||
INSERT INTO `auth_permission` VALUES (4, 'Can view log entry', 1, 'view_logentry');
|
||||
INSERT INTO `auth_permission` VALUES (5, 'Can add permission', 2, 'add_permission');
|
||||
INSERT INTO `auth_permission` VALUES (6, 'Can change permission', 2, 'change_permission');
|
||||
INSERT INTO `auth_permission` VALUES (7, 'Can delete permission', 2, 'delete_permission');
|
||||
INSERT INTO `auth_permission` VALUES (8, 'Can view permission', 2, 'view_permission');
|
||||
INSERT INTO `auth_permission` VALUES (9, 'Can add group', 3, 'add_group');
|
||||
INSERT INTO `auth_permission` VALUES (10, 'Can change group', 3, 'change_group');
|
||||
INSERT INTO `auth_permission` VALUES (11, 'Can delete group', 3, 'delete_group');
|
||||
INSERT INTO `auth_permission` VALUES (12, 'Can view group', 3, 'view_group');
|
||||
INSERT INTO `auth_permission` VALUES (13, 'Can add user', 4, 'add_user');
|
||||
INSERT INTO `auth_permission` VALUES (14, 'Can change user', 4, 'change_user');
|
||||
INSERT INTO `auth_permission` VALUES (15, 'Can delete user', 4, 'delete_user');
|
||||
INSERT INTO `auth_permission` VALUES (16, 'Can view user', 4, 'view_user');
|
||||
INSERT INTO `auth_permission` VALUES (17, 'Can add content type', 5, 'add_contenttype');
|
||||
INSERT INTO `auth_permission` VALUES (18, 'Can change content type', 5, 'change_contenttype');
|
||||
INSERT INTO `auth_permission` VALUES (19, 'Can delete content type', 5, 'delete_contenttype');
|
||||
INSERT INTO `auth_permission` VALUES (20, 'Can view content type', 5, 'view_contenttype');
|
||||
INSERT INTO `auth_permission` VALUES (21, 'Can add session', 6, 'add_session');
|
||||
INSERT INTO `auth_permission` VALUES (22, 'Can change session', 6, 'change_session');
|
||||
INSERT INTO `auth_permission` VALUES (23, 'Can delete session', 6, 'delete_session');
|
||||
INSERT INTO `auth_permission` VALUES (24, 'Can view session', 6, 'view_session');
|
||||
INSERT INTO `auth_permission` VALUES (25, 'Can add ad', 7, 'add_ad');
|
||||
INSERT INTO `auth_permission` VALUES (26, 'Can change ad', 7, 'change_ad');
|
||||
INSERT INTO `auth_permission` VALUES (27, 'Can delete ad', 7, 'delete_ad');
|
||||
INSERT INTO `auth_permission` VALUES (28, 'Can view ad', 7, 'view_ad');
|
||||
INSERT INTO `auth_permission` VALUES (29, 'Can add classification', 8, 'add_classification');
|
||||
INSERT INTO `auth_permission` VALUES (30, 'Can change classification', 8, 'change_classification');
|
||||
INSERT INTO `auth_permission` VALUES (31, 'Can delete classification', 8, 'delete_classification');
|
||||
INSERT INTO `auth_permission` VALUES (32, 'Can view classification', 8, 'view_classification');
|
||||
INSERT INTO `auth_permission` VALUES (33, 'Can add error log', 9, 'add_errorlog');
|
||||
INSERT INTO `auth_permission` VALUES (34, 'Can change error log', 9, 'change_errorlog');
|
||||
INSERT INTO `auth_permission` VALUES (35, 'Can delete error log', 9, 'delete_errorlog');
|
||||
INSERT INTO `auth_permission` VALUES (36, 'Can view error log', 9, 'view_errorlog');
|
||||
INSERT INTO `auth_permission` VALUES (37, 'Can add login log', 10, 'add_loginlog');
|
||||
INSERT INTO `auth_permission` VALUES (38, 'Can change login log', 10, 'change_loginlog');
|
||||
INSERT INTO `auth_permission` VALUES (39, 'Can delete login log', 10, 'delete_loginlog');
|
||||
INSERT INTO `auth_permission` VALUES (40, 'Can view login log', 10, 'view_loginlog');
|
||||
INSERT INTO `auth_permission` VALUES (41, 'Can add notice', 11, 'add_notice');
|
||||
INSERT INTO `auth_permission` VALUES (42, 'Can change notice', 11, 'change_notice');
|
||||
INSERT INTO `auth_permission` VALUES (43, 'Can delete notice', 11, 'delete_notice');
|
||||
INSERT INTO `auth_permission` VALUES (44, 'Can view notice', 11, 'view_notice');
|
||||
INSERT INTO `auth_permission` VALUES (45, 'Can add op log', 12, 'add_oplog');
|
||||
INSERT INTO `auth_permission` VALUES (46, 'Can change op log', 12, 'change_oplog');
|
||||
INSERT INTO `auth_permission` VALUES (47, 'Can delete op log', 12, 'delete_oplog');
|
||||
INSERT INTO `auth_permission` VALUES (48, 'Can view op log', 12, 'view_oplog');
|
||||
INSERT INTO `auth_permission` VALUES (49, 'Can add tag', 13, 'add_tag');
|
||||
INSERT INTO `auth_permission` VALUES (50, 'Can change tag', 13, 'change_tag');
|
||||
INSERT INTO `auth_permission` VALUES (51, 'Can delete tag', 13, 'delete_tag');
|
||||
INSERT INTO `auth_permission` VALUES (52, 'Can view tag', 13, 'view_tag');
|
||||
INSERT INTO `auth_permission` VALUES (53, 'Can add user', 14, 'add_user');
|
||||
INSERT INTO `auth_permission` VALUES (54, 'Can change user', 14, 'change_user');
|
||||
INSERT INTO `auth_permission` VALUES (55, 'Can delete user', 14, 'delete_user');
|
||||
INSERT INTO `auth_permission` VALUES (56, 'Can view user', 14, 'view_user');
|
||||
INSERT INTO `auth_permission` VALUES (57, 'Can add thing', 15, 'add_thing');
|
||||
INSERT INTO `auth_permission` VALUES (58, 'Can change thing', 15, 'change_thing');
|
||||
INSERT INTO `auth_permission` VALUES (59, 'Can delete thing', 15, 'delete_thing');
|
||||
INSERT INTO `auth_permission` VALUES (60, 'Can view thing', 15, 'view_thing');
|
||||
INSERT INTO `auth_permission` VALUES (61, 'Can add record', 16, 'add_record');
|
||||
INSERT INTO `auth_permission` VALUES (62, 'Can change record', 16, 'change_record');
|
||||
INSERT INTO `auth_permission` VALUES (63, 'Can delete record', 16, 'delete_record');
|
||||
INSERT INTO `auth_permission` VALUES (64, 'Can view record', 16, 'view_record');
|
||||
INSERT INTO `auth_permission` VALUES (65, 'Can add order log', 17, 'add_orderlog');
|
||||
INSERT INTO `auth_permission` VALUES (66, 'Can change order log', 17, 'change_orderlog');
|
||||
INSERT INTO `auth_permission` VALUES (67, 'Can delete order log', 17, 'delete_orderlog');
|
||||
INSERT INTO `auth_permission` VALUES (68, 'Can view order log', 17, 'view_orderlog');
|
||||
INSERT INTO `auth_permission` VALUES (69, 'Can add order', 18, 'add_order');
|
||||
INSERT INTO `auth_permission` VALUES (70, 'Can change order', 18, 'change_order');
|
||||
INSERT INTO `auth_permission` VALUES (71, 'Can delete order', 18, 'delete_order');
|
||||
INSERT INTO `auth_permission` VALUES (72, 'Can view order', 18, 'view_order');
|
||||
INSERT INTO `auth_permission` VALUES (73, 'Can add comment', 19, 'add_comment');
|
||||
INSERT INTO `auth_permission` VALUES (74, 'Can change comment', 19, 'change_comment');
|
||||
INSERT INTO `auth_permission` VALUES (75, 'Can delete comment', 19, 'delete_comment');
|
||||
INSERT INTO `auth_permission` VALUES (76, 'Can view comment', 19, 'view_comment');
|
||||
INSERT INTO `auth_permission` VALUES (77, 'Can add banner', 20, 'add_banner');
|
||||
INSERT INTO `auth_permission` VALUES (78, 'Can change banner', 20, 'change_banner');
|
||||
INSERT INTO `auth_permission` VALUES (79, 'Can delete banner', 20, 'delete_banner');
|
||||
INSERT INTO `auth_permission` VALUES (80, 'Can view banner', 20, 'view_banner');
|
||||
INSERT INTO `auth_permission` VALUES (81, 'Can add address', 21, 'add_address');
|
||||
INSERT INTO `auth_permission` VALUES (82, 'Can change address', 21, 'change_address');
|
||||
INSERT INTO `auth_permission` VALUES (83, 'Can delete address', 21, 'delete_address');
|
||||
INSERT INTO `auth_permission` VALUES (84, 'Can view address', 21, 'view_address');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for auth_user
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `auth_user`;
|
||||
CREATE TABLE `auth_user` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`password` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`last_login` datetime(6) NULL DEFAULT NULL,
|
||||
`is_superuser` tinyint(1) NOT NULL,
|
||||
`username` varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`first_name` varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`last_name` varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`email` varchar(254) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`is_staff` tinyint(1) NOT NULL,
|
||||
`is_active` tinyint(1) NOT NULL,
|
||||
`date_joined` datetime(6) NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `username`(`username`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of auth_user
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for auth_user_groups
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `auth_user_groups`;
|
||||
CREATE TABLE `auth_user_groups` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`group_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `auth_user_groups_user_id_group_id_94350c0c_uniq`(`user_id`, `group_id`) USING BTREE,
|
||||
INDEX `auth_user_groups_group_id_97559544_fk_auth_group_id`(`group_id`) USING BTREE,
|
||||
CONSTRAINT `auth_user_groups_group_id_97559544_fk_auth_group_id` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `auth_user_groups_user_id_6a12ed8b_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of auth_user_groups
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for auth_user_user_permissions
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `auth_user_user_permissions`;
|
||||
CREATE TABLE `auth_user_user_permissions` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`permission_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `auth_user_user_permissions_user_id_permission_id_14a6b632_uniq`(`user_id`, `permission_id`) USING BTREE,
|
||||
INDEX `auth_user_user_permi_permission_id_1fbb5f2c_fk_auth_perm`(`permission_id`) USING BTREE,
|
||||
CONSTRAINT `auth_user_user_permi_permission_id_1fbb5f2c_fk_auth_perm` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `auth_user_user_permissions_user_id_a95ead1b_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of auth_user_user_permissions
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_ad
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_ad`;
|
||||
CREATE TABLE `b_ad` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`image` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`link` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`create_time` datetime(6) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_ad
|
||||
-- ----------------------------
|
||||
INSERT INTO `b_ad` VALUES (1, '', 'http://www.baidu.com111', '2024-02-04 17:26:04.553627');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_address
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_address`;
|
||||
CREATE TABLE `b_address` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`mobile` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`desc` varchar(300) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`default` tinyint(1) NULL DEFAULT NULL,
|
||||
`create_time` datetime(6) NULL DEFAULT NULL,
|
||||
`user_id` bigint(20) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `b_address_user_id_a37a8d6a_fk_b_user_id`(`user_id`) USING BTREE,
|
||||
CONSTRAINT `b_address_user_id_a37a8d6a_fk_b_user_id` FOREIGN KEY (`user_id`) REFERENCES `b_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_address
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_banner
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_banner`;
|
||||
CREATE TABLE `b_banner` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`image` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`create_time` datetime(6) NULL DEFAULT NULL,
|
||||
`thing_id` bigint(20) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `b_banner_thing_id_3f307d00_fk_b_thing_id`(`thing_id`) USING BTREE,
|
||||
CONSTRAINT `b_banner_thing_id_3f307d00_fk_b_thing_id` FOREIGN KEY (`thing_id`) REFERENCES `b_thing` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_banner
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_classification
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_classification`;
|
||||
CREATE TABLE `b_classification` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`title` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`create_time` datetime(6) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_classification
|
||||
-- ----------------------------
|
||||
INSERT INTO `b_classification` VALUES (1, '体育类', '2024-02-04 16:39:13.697593');
|
||||
INSERT INTO `b_classification` VALUES (2, '运动类', '2024-02-04 16:39:19.397394');
|
||||
INSERT INTO `b_classification` VALUES (3, '文艺类', '2024-02-04 16:39:24.633287');
|
||||
INSERT INTO `b_classification` VALUES (4, '电子类', '2024-02-04 16:39:59.841608');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_comment
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_comment`;
|
||||
CREATE TABLE `b_comment` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`content` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`comment_time` datetime(6) NULL DEFAULT NULL,
|
||||
`like_count` int(11) NOT NULL,
|
||||
`thing_id` bigint(20) NULL DEFAULT NULL,
|
||||
`user_id` bigint(20) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `b_comment_thing_id_57ab492b_fk_b_thing_id`(`thing_id`) USING BTREE,
|
||||
INDEX `b_comment_user_id_46f0670f_fk_b_user_id`(`user_id`) USING BTREE,
|
||||
CONSTRAINT `b_comment_thing_id_57ab492b_fk_b_thing_id` FOREIGN KEY (`thing_id`) REFERENCES `b_thing` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `b_comment_user_id_46f0670f_fk_b_user_id` FOREIGN KEY (`user_id`) REFERENCES `b_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_comment
|
||||
-- ----------------------------
|
||||
INSERT INTO `b_comment` VALUES (1, 'dasdf', '2024-02-04 16:58:15.144159', 1, 5, 4);
|
||||
INSERT INTO `b_comment` VALUES (2, 'dfasdfff', '2024-02-04 16:58:17.850901', 1, 5, 4);
|
||||
INSERT INTO `b_comment` VALUES (3, '的地方211', '2024-02-04 17:00:55.346951', 2, 5, 4);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_error_log
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_error_log`;
|
||||
CREATE TABLE `b_error_log` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`ip` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`url` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`method` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`content` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`log_time` datetime(6) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_error_log
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_login_log
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_login_log`;
|
||||
CREATE TABLE `b_login_log` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`ip` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`ua` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`log_time` datetime(6) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_login_log
|
||||
-- ----------------------------
|
||||
INSERT INTO `b_login_log` VALUES (1, 'admin', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36', '2024-02-04 16:36:19.239685');
|
||||
INSERT INTO `b_login_log` VALUES (2, 'aaa', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36', '2024-02-04 16:57:10.644691');
|
||||
INSERT INTO `b_login_log` VALUES (3, 'admin123', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36', '2024-02-04 17:18:37.112379');
|
||||
INSERT INTO `b_login_log` VALUES (4, 'admin', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36', '2024-02-04 17:25:59.480266');
|
||||
INSERT INTO `b_login_log` VALUES (5, 'aaa', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36', '2024-02-04 17:27:08.481837');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_notice
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_notice`;
|
||||
CREATE TABLE `b_notice` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`title` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`content` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`create_time` datetime(6) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_notice
|
||||
-- ----------------------------
|
||||
INSERT INTO `b_notice` VALUES (1, 'abcd', '欢迎申请', '2024-02-04 17:26:10.000000');
|
||||
INSERT INTO `b_notice` VALUES (2, '新建社团123', '安德森对方', '2024-02-04 17:26:20.948813');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_op_log
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_op_log`;
|
||||
CREATE TABLE `b_op_log` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`re_ip` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`re_time` datetime(6) NULL DEFAULT NULL,
|
||||
`re_url` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`re_method` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`re_content` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`access_time` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 25 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_op_log
|
||||
-- ----------------------------
|
||||
INSERT INTO `b_op_log` VALUES (1, '127.0.0.1', '2024-02-04 17:25:16.003630', '/myapp/admin/loginLog/list', 'GET', NULL, '25');
|
||||
INSERT INTO `b_op_log` VALUES (2, '127.0.0.1', '2024-02-04 17:25:16.125409', '/myapp/admin/opLog/list', 'GET', NULL, '28');
|
||||
INSERT INTO `b_op_log` VALUES (3, '127.0.0.1', '2024-02-04 17:25:16.735706', '/myapp/admin/errorLog/list', 'GET', NULL, '4');
|
||||
INSERT INTO `b_op_log` VALUES (4, '127.0.0.1', '2024-02-04 17:25:17.091962', '/myapp/admin/opLog/list', 'GET', NULL, '28');
|
||||
INSERT INTO `b_op_log` VALUES (5, '127.0.0.1', '2024-02-04 17:25:17.996686', '/myapp/admin/comment/list', 'GET', NULL, '24');
|
||||
INSERT INTO `b_op_log` VALUES (6, '127.0.0.1', '2024-02-04 17:25:18.508752', '/myapp/admin/tag/list', 'GET', NULL, '28');
|
||||
INSERT INTO `b_op_log` VALUES (7, '127.0.0.1', '2024-02-04 17:25:18.995965', '/myapp/admin/order/list', 'GET', NULL, '25');
|
||||
INSERT INTO `b_op_log` VALUES (8, '127.0.0.1', '2024-02-04 17:25:19.517164', '/myapp/admin/classification/list', 'GET', NULL, '25');
|
||||
INSERT INTO `b_op_log` VALUES (9, '127.0.0.1', '2024-02-04 17:25:19.951784', '/myapp/admin/order/list', 'GET', NULL, '8');
|
||||
INSERT INTO `b_op_log` VALUES (10, '127.0.0.1', '2024-02-04 17:25:20.517535', '/myapp/admin/tag/list', 'GET', NULL, '17');
|
||||
INSERT INTO `b_op_log` VALUES (11, '127.0.0.1', '2024-02-04 17:25:20.899065', '/myapp/admin/comment/list', 'GET', NULL, '7');
|
||||
INSERT INTO `b_op_log` VALUES (12, '127.0.0.1', '2024-02-04 17:25:21.391965', '/myapp/admin/user/list', 'GET', NULL, '20');
|
||||
INSERT INTO `b_op_log` VALUES (13, '127.0.0.1', '2024-02-04 17:25:21.677749', '/myapp/admin/comment/list', 'GET', NULL, '5');
|
||||
INSERT INTO `b_op_log` VALUES (14, '127.0.0.1', '2024-02-04 17:25:24.066175', '/myapp/index/comment/list', 'GET', NULL, '3');
|
||||
INSERT INTO `b_op_log` VALUES (15, '127.0.0.1', '2024-02-04 17:25:24.083944', '/myapp/index/comment/list', 'GET', NULL, '22');
|
||||
INSERT INTO `b_op_log` VALUES (16, '127.0.0.1', '2024-02-04 17:25:24.084992', '/myapp/index/comment/list', 'GET', NULL, '23');
|
||||
INSERT INTO `b_op_log` VALUES (17, '127.0.0.1', '2024-02-04 17:25:24.090525', '/myapp/index/comment/list', 'GET', NULL, '29');
|
||||
INSERT INTO `b_op_log` VALUES (18, '127.0.0.1', '2024-02-04 17:25:24.094806', '/upload/cover/1707036810262.jpeg', 'GET', NULL, '1');
|
||||
INSERT INTO `b_op_log` VALUES (19, '127.0.0.1', '2024-02-04 17:25:24.109564', '/upload/cover/1707036756214.jpeg', 'GET', NULL, '1');
|
||||
INSERT INTO `b_op_log` VALUES (20, '127.0.0.1', '2024-02-04 17:25:24.109564', '/upload/cover/1707036858212.jpeg', 'GET', NULL, '0');
|
||||
INSERT INTO `b_op_log` VALUES (21, '127.0.0.1', '2024-02-04 17:25:24.109564', '/upload/cover/1707036756214.jpeg', 'GET', NULL, '0');
|
||||
INSERT INTO `b_op_log` VALUES (22, '127.0.0.1', '2024-02-04 17:25:24.110577', '/upload/cover/1707036638009.jpeg', 'GET', NULL, '1');
|
||||
INSERT INTO `b_op_log` VALUES (23, '127.0.0.1', '2024-02-04 17:25:24.110577', '/upload/cover/1707036701716.jpeg', 'GET', NULL, '0');
|
||||
INSERT INTO `b_op_log` VALUES (24, '127.0.0.1', '2024-02-04 17:25:27.073752', '/myapp/admin/opLog/list', 'GET', NULL, '4');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_order
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_order`;
|
||||
CREATE TABLE `b_order` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`order_number` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`count` int(11) NOT NULL,
|
||||
`status` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`order_time` datetime(6) NULL DEFAULT NULL,
|
||||
`pay_time` datetime(6) NULL DEFAULT NULL,
|
||||
`receiver_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`receiver_address` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`receiver_phone` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`remark` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`thing_id` bigint(20) NULL DEFAULT NULL,
|
||||
`user_id` bigint(20) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `b_order_thing_id_4e345e2c_fk_b_thing_id`(`thing_id`) USING BTREE,
|
||||
INDEX `b_order_user_id_64854046_fk_b_user_id`(`user_id`) USING BTREE,
|
||||
CONSTRAINT `b_order_thing_id_4e345e2c_fk_b_thing_id` FOREIGN KEY (`thing_id`) REFERENCES `b_thing` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `b_order_user_id_64854046_fk_b_user_id` FOREIGN KEY (`user_id`) REFERENCES `b_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_order
|
||||
-- ----------------------------
|
||||
INSERT INTO `b_order` VALUES (1, '1707037383809', 1, '2', '2024-02-04 17:03:03.811334', NULL, NULL, NULL, NULL, NULL, 5, 4);
|
||||
INSERT INTO `b_order` VALUES (2, '1707037601900', 1, '2', '2024-02-04 17:06:41.903354', NULL, NULL, NULL, NULL, NULL, 5, 4);
|
||||
INSERT INTO `b_order` VALUES (3, '1707038198529', 1, '7', '2024-02-04 17:16:38.534185', NULL, NULL, NULL, NULL, NULL, 1, 4);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_order_log
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_order_log`;
|
||||
CREATE TABLE `b_order_log` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`action` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`log_time` datetime(6) NULL DEFAULT NULL,
|
||||
`thing_id` bigint(20) NULL DEFAULT NULL,
|
||||
`user_id` bigint(20) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `b_order_log_thing_id_7306f624_fk_b_thing_id`(`thing_id`) USING BTREE,
|
||||
INDEX `b_order_log_user_id_1003e839_fk_b_user_id`(`user_id`) USING BTREE,
|
||||
CONSTRAINT `b_order_log_thing_id_7306f624_fk_b_thing_id` FOREIGN KEY (`thing_id`) REFERENCES `b_thing` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `b_order_log_user_id_1003e839_fk_b_user_id` FOREIGN KEY (`user_id`) REFERENCES `b_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_order_log
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_record
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_record`;
|
||||
CREATE TABLE `b_record` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`title` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`record_time` datetime(6) NULL DEFAULT NULL,
|
||||
`classification_id` bigint(20) NULL DEFAULT NULL,
|
||||
`thing_id` bigint(20) NULL DEFAULT NULL,
|
||||
`user_id` bigint(20) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `b_record_classification_id_52591cc9_fk_b_classification_id`(`classification_id`) USING BTREE,
|
||||
INDEX `b_record_thing_id_d8e773c0_fk_b_thing_id`(`thing_id`) USING BTREE,
|
||||
INDEX `b_record_user_id_7e5958b0_fk_b_user_id`(`user_id`) USING BTREE,
|
||||
CONSTRAINT `b_record_classification_id_52591cc9_fk_b_classification_id` FOREIGN KEY (`classification_id`) REFERENCES `b_classification` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `b_record_thing_id_d8e773c0_fk_b_thing_id` FOREIGN KEY (`thing_id`) REFERENCES `b_thing` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `b_record_user_id_7e5958b0_fk_b_user_id` FOREIGN KEY (`user_id`) REFERENCES `b_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_record
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_tag
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_tag`;
|
||||
CREATE TABLE `b_tag` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`title` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`create_time` datetime(6) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_tag
|
||||
-- ----------------------------
|
||||
INSERT INTO `b_tag` VALUES (1, '美女多', '2024-02-04 16:38:34.240261');
|
||||
INSERT INTO `b_tag` VALUES (2, '高材生', '2024-02-04 16:38:41.618448');
|
||||
INSERT INTO `b_tag` VALUES (3, '帅哥多', '2024-02-04 16:38:48.542216');
|
||||
INSERT INTO `b_tag` VALUES (4, '读书', '2024-02-04 16:38:57.500728');
|
||||
INSERT INTO `b_tag` VALUES (5, '跑步', '2024-02-04 16:39:05.464820');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_thing
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_thing`;
|
||||
CREATE TABLE `b_thing` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`title` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`cover` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`description` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
|
||||
`mobile` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`location` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`status` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`create_time` datetime(6) NULL DEFAULT NULL,
|
||||
`pv` int(11) NOT NULL,
|
||||
`recommend_count` int(11) NOT NULL,
|
||||
`wish_count` int(11) NOT NULL,
|
||||
`collect_count` int(11) NOT NULL,
|
||||
`classification_id` bigint(20) NULL DEFAULT NULL,
|
||||
`user_id` bigint(20) NULL DEFAULT NULL,
|
||||
`email` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`zongzhi` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `b_thing_classification_id_47675ac4_fk_b_classification_id`(`classification_id`) USING BTREE,
|
||||
INDEX `b_thing_user_id_9918a633_fk_b_user_id`(`user_id`) USING BTREE,
|
||||
CONSTRAINT `b_thing_classification_id_47675ac4_fk_b_classification_id` FOREIGN KEY (`classification_id`) REFERENCES `b_classification` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `b_thing_user_id_9918a633_fk_b_user_id` FOREIGN KEY (`user_id`) REFERENCES `b_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_thing
|
||||
-- ----------------------------
|
||||
INSERT INTO `b_thing` VALUES (1, '街舞团', 'cover/1707036603261.jpeg', 'abcfdasdf', '13422221111', '教学楼3号楼1层', '0', '2024-02-04 16:45:44.682923', 4, 0, 1, 1, 2, NULL, '123@qq.com', '为人民服务');
|
||||
INSERT INTO `b_thing` VALUES (2, 'beyond502乐队', 'cover/1707036638009.jpeg', '江河湖海就将计就计哈哈哈哈哈哈哈哈', '13455555555', '6号宿舍楼', '0', '2024-02-04 16:51:15.254882', 1, 0, 0, 0, 3, NULL, '12345@qq.com', '为了音乐而生');
|
||||
INSERT INTO `b_thing` VALUES (3, '轮滑俱乐部', 'cover/1707036701716.jpeg', '哈哈哈哈哈哈哈哈哈哈', '13422221111', '9号宿舍楼', '0', '2024-02-04 16:52:13.713017', 0, 0, 0, 0, 2, NULL, '1234@126.com', '为了运动努力');
|
||||
INSERT INTO `b_thing` VALUES (4, '王羲之书法俱乐部', 'cover/1707036756214.jpeg', '江河湖海哼哼唧唧哼哼唧唧就哈哈哈哈话剧', '13211112222', '颐和园路5号', '0', '2024-02-04 16:53:09.100387', 2, 0, 0, 0, 3, NULL, '123@qq.com', '为了哈哈哈');
|
||||
INSERT INTO `b_thing` VALUES (5, '电子琴俱乐部', 'cover/1707036810262.jpeg', '就很好很好灌灌哈哈哈哈嘎嘎嘎嘎', '13455555555', '12号教学楼', '0', '2024-02-04 16:53:56.425555', 16, 0, 1, 1, 4, NULL, '12245@qq.com', '为了生活');
|
||||
INSERT INTO `b_thing` VALUES (6, '夜跑俱乐部', 'cover/1707036858212.jpeg', '就啊哈哈的观点嘎哈韩国', '13222221111', '9号教学楼', '0', '2024-02-04 16:54:43.049737', 3, 0, 0, 0, 1, NULL, '999888@qq.com', '为了跑步');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_thing_collect
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_thing_collect`;
|
||||
CREATE TABLE `b_thing_collect` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`thing_id` bigint(20) NOT NULL,
|
||||
`user_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `b_thing_collect_thing_id_user_id_45b9f252_uniq`(`thing_id`, `user_id`) USING BTREE,
|
||||
INDEX `b_thing_collect_user_id_e5d69968_fk_b_user_id`(`user_id`) USING BTREE,
|
||||
CONSTRAINT `b_thing_collect_thing_id_8edce8b3_fk_b_thing_id` FOREIGN KEY (`thing_id`) REFERENCES `b_thing` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `b_thing_collect_user_id_e5d69968_fk_b_user_id` FOREIGN KEY (`user_id`) REFERENCES `b_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_thing_collect
|
||||
-- ----------------------------
|
||||
INSERT INTO `b_thing_collect` VALUES (2, 1, 4);
|
||||
INSERT INTO `b_thing_collect` VALUES (1, 5, 4);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_thing_tag
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_thing_tag`;
|
||||
CREATE TABLE `b_thing_tag` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`thing_id` bigint(20) NOT NULL,
|
||||
`tag_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `b_thing_tag_thing_id_tag_id_a5d426b2_uniq`(`thing_id`, `tag_id`) USING BTREE,
|
||||
INDEX `b_thing_tag_tag_id_d02b28a1_fk_b_tag_id`(`tag_id`) USING BTREE,
|
||||
CONSTRAINT `b_thing_tag_tag_id_d02b28a1_fk_b_tag_id` FOREIGN KEY (`tag_id`) REFERENCES `b_tag` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `b_thing_tag_thing_id_fb8ecf3f_fk_b_thing_id` FOREIGN KEY (`thing_id`) REFERENCES `b_thing` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 22 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_thing_tag
|
||||
-- ----------------------------
|
||||
INSERT INTO `b_thing_tag` VALUES (1, 1, 2);
|
||||
INSERT INTO `b_thing_tag` VALUES (2, 1, 3);
|
||||
INSERT INTO `b_thing_tag` VALUES (3, 1, 4);
|
||||
INSERT INTO `b_thing_tag` VALUES (4, 1, 5);
|
||||
INSERT INTO `b_thing_tag` VALUES (5, 2, 1);
|
||||
INSERT INTO `b_thing_tag` VALUES (6, 2, 2);
|
||||
INSERT INTO `b_thing_tag` VALUES (7, 2, 3);
|
||||
INSERT INTO `b_thing_tag` VALUES (8, 2, 5);
|
||||
INSERT INTO `b_thing_tag` VALUES (9, 3, 1);
|
||||
INSERT INTO `b_thing_tag` VALUES (10, 3, 2);
|
||||
INSERT INTO `b_thing_tag` VALUES (11, 3, 3);
|
||||
INSERT INTO `b_thing_tag` VALUES (12, 3, 4);
|
||||
INSERT INTO `b_thing_tag` VALUES (13, 3, 5);
|
||||
INSERT INTO `b_thing_tag` VALUES (14, 4, 2);
|
||||
INSERT INTO `b_thing_tag` VALUES (15, 4, 4);
|
||||
INSERT INTO `b_thing_tag` VALUES (16, 4, 5);
|
||||
INSERT INTO `b_thing_tag` VALUES (17, 5, 2);
|
||||
INSERT INTO `b_thing_tag` VALUES (18, 5, 4);
|
||||
INSERT INTO `b_thing_tag` VALUES (19, 6, 1);
|
||||
INSERT INTO `b_thing_tag` VALUES (20, 6, 2);
|
||||
INSERT INTO `b_thing_tag` VALUES (21, 6, 5);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_thing_wish
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_thing_wish`;
|
||||
CREATE TABLE `b_thing_wish` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`thing_id` bigint(20) NOT NULL,
|
||||
`user_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `b_thing_wish_thing_id_user_id_9d647bbb_uniq`(`thing_id`, `user_id`) USING BTREE,
|
||||
INDEX `b_thing_wish_user_id_e2d94f6c_fk_b_user_id`(`user_id`) USING BTREE,
|
||||
CONSTRAINT `b_thing_wish_thing_id_f0864b16_fk_b_thing_id` FOREIGN KEY (`thing_id`) REFERENCES `b_thing` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `b_thing_wish_user_id_e2d94f6c_fk_b_user_id` FOREIGN KEY (`user_id`) REFERENCES `b_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_thing_wish
|
||||
-- ----------------------------
|
||||
INSERT INTO `b_thing_wish` VALUES (2, 1, 4);
|
||||
INSERT INTO `b_thing_wish` VALUES (1, 5, 4);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for b_user
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `b_user`;
|
||||
CREATE TABLE `b_user` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`password` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`role` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`status` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`nickname` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`avatar` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`mobile` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`gender` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`description` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
|
||||
`create_time` datetime(6) NULL DEFAULT NULL,
|
||||
`score` int(11) NULL DEFAULT NULL,
|
||||
`push_email` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`push_switch` tinyint(1) NULL DEFAULT NULL,
|
||||
`admin_token` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`token` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of b_user
|
||||
-- ----------------------------
|
||||
INSERT INTO `b_user` VALUES (1, 'admin', '78aafd3207ec4ef6d16f9fc07e95ebc3', '1', '0', NULL, '', NULL, NULL, NULL, NULL, '2024-02-04 16:36:13.029265', 0, NULL, 0, '21232f297a57a5a743894a0e4a801fc3', NULL);
|
||||
INSERT INTO `b_user` VALUES (2, 'admin123', '0192023a7bbd73250516f069df18b500', '1', '0', NULL, '', NULL, NULL, NULL, NULL, '2024-02-04 16:40:18.754982', 0, NULL, 0, '0192023a7bbd73250516f069df18b500', NULL);
|
||||
INSERT INTO `b_user` VALUES (3, 'test', '098f6bcd4621d373cade4e832627b4f6', '3', '0', NULL, '', NULL, NULL, NULL, NULL, '2024-02-04 16:40:35.603385', 0, NULL, 0, NULL, NULL);
|
||||
INSERT INTO `b_user` VALUES (4, 'aaa', '47bce5c74f589f4867dbd57e9ca9f808', '2', '0', '1233', '', NULL, NULL, NULL, NULL, '2024-02-04 16:57:07.608626', 0, NULL, 0, NULL, '47bce5c74f589f4867dbd57e9ca9f808');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for django_admin_log
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `django_admin_log`;
|
||||
CREATE TABLE `django_admin_log` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`action_time` datetime(6) NOT NULL,
|
||||
`object_id` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
|
||||
`object_repr` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`action_flag` smallint(5) UNSIGNED NOT NULL,
|
||||
`change_message` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`content_type_id` int(11) NULL DEFAULT NULL,
|
||||
`user_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `django_admin_log_content_type_id_c4bce8eb_fk_django_co`(`content_type_id`) USING BTREE,
|
||||
INDEX `django_admin_log_user_id_c564eba6_fk_auth_user_id`(`user_id`) USING BTREE,
|
||||
CONSTRAINT `django_admin_log_content_type_id_c4bce8eb_fk_django_co` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `django_admin_log_user_id_c564eba6_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of django_admin_log
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for django_content_type
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `django_content_type`;
|
||||
CREATE TABLE `django_content_type` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`app_label` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`model` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `django_content_type_app_label_model_76bd3d3b_uniq`(`app_label`, `model`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 22 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of django_content_type
|
||||
-- ----------------------------
|
||||
INSERT INTO `django_content_type` VALUES (1, 'admin', 'logentry');
|
||||
INSERT INTO `django_content_type` VALUES (3, 'auth', 'group');
|
||||
INSERT INTO `django_content_type` VALUES (2, 'auth', 'permission');
|
||||
INSERT INTO `django_content_type` VALUES (4, 'auth', 'user');
|
||||
INSERT INTO `django_content_type` VALUES (5, 'contenttypes', 'contenttype');
|
||||
INSERT INTO `django_content_type` VALUES (7, 'myapp', 'ad');
|
||||
INSERT INTO `django_content_type` VALUES (21, 'myapp', 'address');
|
||||
INSERT INTO `django_content_type` VALUES (20, 'myapp', 'banner');
|
||||
INSERT INTO `django_content_type` VALUES (8, 'myapp', 'classification');
|
||||
INSERT INTO `django_content_type` VALUES (19, 'myapp', 'comment');
|
||||
INSERT INTO `django_content_type` VALUES (9, 'myapp', 'errorlog');
|
||||
INSERT INTO `django_content_type` VALUES (10, 'myapp', 'loginlog');
|
||||
INSERT INTO `django_content_type` VALUES (11, 'myapp', 'notice');
|
||||
INSERT INTO `django_content_type` VALUES (12, 'myapp', 'oplog');
|
||||
INSERT INTO `django_content_type` VALUES (18, 'myapp', 'order');
|
||||
INSERT INTO `django_content_type` VALUES (17, 'myapp', 'orderlog');
|
||||
INSERT INTO `django_content_type` VALUES (16, 'myapp', 'record');
|
||||
INSERT INTO `django_content_type` VALUES (13, 'myapp', 'tag');
|
||||
INSERT INTO `django_content_type` VALUES (15, 'myapp', 'thing');
|
||||
INSERT INTO `django_content_type` VALUES (14, 'myapp', 'user');
|
||||
INSERT INTO `django_content_type` VALUES (6, 'sessions', 'session');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for django_migrations
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `django_migrations`;
|
||||
CREATE TABLE `django_migrations` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`app` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`applied` datetime(6) NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 22 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of django_migrations
|
||||
-- ----------------------------
|
||||
INSERT INTO `django_migrations` VALUES (1, 'contenttypes', '0001_initial', '2024-02-04 16:32:51.298695');
|
||||
INSERT INTO `django_migrations` VALUES (2, 'auth', '0001_initial', '2024-02-04 16:32:51.549701');
|
||||
INSERT INTO `django_migrations` VALUES (3, 'admin', '0001_initial', '2024-02-04 16:32:51.606242');
|
||||
INSERT INTO `django_migrations` VALUES (4, 'admin', '0002_logentry_remove_auto_add', '2024-02-04 16:32:51.613953');
|
||||
INSERT INTO `django_migrations` VALUES (5, 'admin', '0003_logentry_add_action_flag_choices', '2024-02-04 16:32:51.619196');
|
||||
INSERT INTO `django_migrations` VALUES (6, 'contenttypes', '0002_remove_content_type_name', '2024-02-04 16:32:51.687139');
|
||||
INSERT INTO `django_migrations` VALUES (7, 'auth', '0002_alter_permission_name_max_length', '2024-02-04 16:32:51.729044');
|
||||
INSERT INTO `django_migrations` VALUES (8, 'auth', '0003_alter_user_email_max_length', '2024-02-04 16:32:51.771331');
|
||||
INSERT INTO `django_migrations` VALUES (9, 'auth', '0004_alter_user_username_opts', '2024-02-04 16:32:51.777711');
|
||||
INSERT INTO `django_migrations` VALUES (10, 'auth', '0005_alter_user_last_login_null', '2024-02-04 16:32:51.813729');
|
||||
INSERT INTO `django_migrations` VALUES (11, 'auth', '0006_require_contenttypes_0002', '2024-02-04 16:32:51.817877');
|
||||
INSERT INTO `django_migrations` VALUES (12, 'auth', '0007_alter_validators_add_error_messages', '2024-02-04 16:32:51.823354');
|
||||
INSERT INTO `django_migrations` VALUES (13, 'auth', '0008_alter_user_username_max_length', '2024-02-04 16:32:51.865155');
|
||||
INSERT INTO `django_migrations` VALUES (14, 'auth', '0009_alter_user_last_name_max_length', '2024-02-04 16:32:51.907643');
|
||||
INSERT INTO `django_migrations` VALUES (15, 'auth', '0010_alter_group_name_max_length', '2024-02-04 16:32:51.951019');
|
||||
INSERT INTO `django_migrations` VALUES (16, 'auth', '0011_update_proxy_permissions', '2024-02-04 16:32:51.958587');
|
||||
INSERT INTO `django_migrations` VALUES (17, 'auth', '0012_alter_user_first_name_max_length', '2024-02-04 16:32:52.003585');
|
||||
INSERT INTO `django_migrations` VALUES (18, 'myapp', '0001_initial', '2024-02-04 16:32:52.698876');
|
||||
INSERT INTO `django_migrations` VALUES (19, 'myapp', '0002_thing_user', '2024-02-04 16:32:52.738582');
|
||||
INSERT INTO `django_migrations` VALUES (20, 'myapp', '0003_auto_20240204_1632', '2024-02-04 16:32:52.933013');
|
||||
INSERT INTO `django_migrations` VALUES (21, 'sessions', '0001_initial', '2024-02-04 16:32:52.969896');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for django_session
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `django_session`;
|
||||
CREATE TABLE `django_session` (
|
||||
`session_key` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`session_data` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`expire_date` datetime(6) NOT NULL,
|
||||
PRIMARY KEY (`session_key`) USING BTREE,
|
||||
INDEX `django_session_expire_date_a5c62663`(`expire_date`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of django_session
|
||||
-- ----------------------------
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
"""Django's command-line utility for administrative tasks."""
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
"""Run administrative tasks."""
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.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)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -0,0 +1,10 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
from myapp.models import Classification, Thing, Tag, User, Comment
|
||||
|
||||
admin.site.register(Classification)
|
||||
admin.site.register(Tag)
|
||||
admin.site.register(Thing)
|
||||
admin.site.register(User)
|
||||
admin.site.register(Comment)
|
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class MyappConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'myapp'
|
@ -0,0 +1,5 @@
|
||||
from rest_framework.throttling import AnonRateThrottle
|
||||
|
||||
|
||||
class MyRateThrottle(AnonRateThrottle):
|
||||
THROTTLE_RATES = {"anon": "2/min"}
|
@ -0,0 +1,13 @@
|
||||
from rest_framework.response import Response
|
||||
|
||||
|
||||
class APIResponse(Response):
|
||||
def __init__(self, code=0, msg='', data=None, status=200, headers=None, content_type=None, **kwargs):
|
||||
dic = {'code': code, 'msg': msg}
|
||||
if data is not None:
|
||||
dic['data'] = data
|
||||
|
||||
dic.update(kwargs) # 这里使用update
|
||||
super().__init__(data=dic, status=status,
|
||||
template_name=None, headers=headers,
|
||||
exception=False, content_type=content_type)
|
@ -0,0 +1,54 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
import time
|
||||
import json
|
||||
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
|
||||
from myapp import utils
|
||||
from myapp.serializers import OpLogSerializer
|
||||
|
||||
|
||||
class OpLogs(MiddlewareMixin):
|
||||
|
||||
def __init__(self, *args):
|
||||
super(OpLogs, self).__init__(*args)
|
||||
|
||||
self.start_time = None # 开始时间
|
||||
self.end_time = None # 响应时间
|
||||
self.data = {} # dict数据
|
||||
|
||||
def process_request(self, request):
|
||||
|
||||
self.start_time = time.time() # 开始时间
|
||||
|
||||
re_ip = utils.get_ip(request)
|
||||
re_method = request.method
|
||||
re_content = request.GET if re_method == 'GET' else request.POST
|
||||
if re_content:
|
||||
re_content = json.dumps(re_content)
|
||||
else:
|
||||
re_content = None
|
||||
|
||||
self.data.update(
|
||||
{
|
||||
're_url': request.path,
|
||||
're_method': re_method,
|
||||
're_ip': re_ip,
|
||||
# 're_content': re_content,
|
||||
}
|
||||
)
|
||||
# print(self.data)
|
||||
|
||||
def process_response(self, request, response):
|
||||
|
||||
# 耗时毫秒/ms
|
||||
self.end_time = time.time() # 响应时间
|
||||
access_time = self.end_time - self.start_time
|
||||
self.data['access_time'] = round(access_time * 1000)
|
||||
|
||||
# 入库
|
||||
# serializer = OpLogSerializer(data=self.data)
|
||||
# if serializer.is_valid():
|
||||
# serializer.save()
|
||||
|
||||
return response
|
@ -0,0 +1,221 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class User(models.Model):
|
||||
GENDER_CHOICES = (
|
||||
('M', '男'),
|
||||
('F', '女'),
|
||||
)
|
||||
ROLE_CHOICES = (
|
||||
('0', '管理员'),
|
||||
('1', '普通用户'),
|
||||
)
|
||||
STATUS_CHOICES = (
|
||||
('0', '正常'),
|
||||
('1', '封号'),
|
||||
)
|
||||
id = models.BigAutoField(primary_key=True)
|
||||
username = models.CharField(max_length=50, null=True)
|
||||
password = models.CharField(max_length=50, null=True)
|
||||
role = models.CharField(max_length=2, blank=True, null=True)
|
||||
status = models.CharField(max_length=1, choices=STATUS_CHOICES, default='0')
|
||||
nickname = models.CharField(blank=True, null=True, max_length=20)
|
||||
avatar = models.FileField(upload_to='avatar/', null=True)
|
||||
mobile = models.CharField(max_length=13, blank=True, null=True)
|
||||
email = models.CharField(max_length=50, blank=True, null=True)
|
||||
gender = models.CharField(max_length=1, choices=GENDER_CHOICES, blank=True, null=True)
|
||||
description = models.TextField(max_length=200, null=True)
|
||||
create_time = models.DateTimeField(auto_now_add=True, null=True)
|
||||
score = models.IntegerField(default=0, blank=True, null=True)
|
||||
push_email = models.CharField(max_length=40, blank=True, null=True)
|
||||
push_switch = models.BooleanField(blank=True, null=True, default=False)
|
||||
admin_token = models.CharField(max_length=32, blank=True, null=True)
|
||||
token = models.CharField(max_length=32, blank=True, null=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "b_user"
|
||||
|
||||
|
||||
class Tag(models.Model):
|
||||
id = models.BigAutoField(primary_key=True)
|
||||
title = models.CharField(max_length=100, blank=True, null=True)
|
||||
create_time = models.DateTimeField(auto_now_add=True, null=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "b_tag"
|
||||
|
||||
|
||||
class Classification(models.Model):
|
||||
list_display = ("title", "id")
|
||||
id = models.BigAutoField(primary_key=True)
|
||||
title = models.CharField(max_length=100, blank=True, null=True)
|
||||
create_time = models.DateTimeField(auto_now_add=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
class Meta:
|
||||
db_table = "b_classification"
|
||||
|
||||
|
||||
class Thing(models.Model):
|
||||
STATUS_CHOICES = (
|
||||
('0', '上架'),
|
||||
('1', '下架'),
|
||||
)
|
||||
id = models.BigAutoField(primary_key=True)
|
||||
classification = models.ForeignKey(Classification, on_delete=models.CASCADE, blank=True, null=True,
|
||||
related_name='classification_thing')
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True, related_name='user_thing')
|
||||
tag = models.ManyToManyField(Tag, blank=True)
|
||||
title = models.CharField(max_length=100, blank=True, null=True)
|
||||
cover = models.ImageField(upload_to='cover/', null=True)
|
||||
description = models.TextField(max_length=1000, blank=True, null=True)
|
||||
zongzhi = models.CharField(max_length=200, blank=True, null=True)
|
||||
email = models.CharField(max_length=200, blank=True, null=True)
|
||||
mobile = models.CharField(max_length=50, blank=True, null=True)
|
||||
location = models.CharField(max_length=50, blank=True, null=True)
|
||||
status = models.CharField(max_length=1, choices=STATUS_CHOICES, default='0')
|
||||
create_time = models.DateTimeField(auto_now_add=True, null=True)
|
||||
pv = models.IntegerField(default=0)
|
||||
recommend_count = models.IntegerField(default=0)
|
||||
wish = models.ManyToManyField(User, blank=True, related_name="wish_things")
|
||||
wish_count = models.IntegerField(default=0)
|
||||
collect = models.ManyToManyField(User, blank=True, related_name="collect_things")
|
||||
collect_count = models.IntegerField(default=0)
|
||||
|
||||
class Meta:
|
||||
db_table = "b_thing"
|
||||
|
||||
|
||||
class Comment(models.Model):
|
||||
id = models.BigAutoField(primary_key=True)
|
||||
content = models.CharField(max_length=200, blank=True, null=True)
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, related_name='user_comment')
|
||||
thing = models.ForeignKey(Thing, on_delete=models.CASCADE, null=True, related_name='thing_comment')
|
||||
comment_time = models.DateTimeField(auto_now_add=True, null=True)
|
||||
like_count = models.IntegerField(default=0)
|
||||
|
||||
class Meta:
|
||||
db_table = "b_comment"
|
||||
|
||||
|
||||
class Record(models.Model):
|
||||
id = models.BigAutoField(primary_key=True)
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, related_name='user_record')
|
||||
thing = models.ForeignKey(Thing, on_delete=models.CASCADE, null=True, related_name='thing_record')
|
||||
title = models.CharField(max_length=100, blank=True, null=True)
|
||||
classification = models.ForeignKey(Classification, on_delete=models.CASCADE, null=True,
|
||||
related_name='classification')
|
||||
record_time = models.DateTimeField(auto_now_add=True, null=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "b_record"
|
||||
|
||||
|
||||
class LoginLog(models.Model):
|
||||
id = models.BigAutoField(primary_key=True)
|
||||
username = models.CharField(max_length=50, blank=True, null=True)
|
||||
ip = models.CharField(max_length=100, blank=True, null=True)
|
||||
ua = models.CharField(max_length=200, blank=True, null=True)
|
||||
log_time = models.DateTimeField(auto_now_add=True, null=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "b_login_log"
|
||||
|
||||
|
||||
class OpLog(models.Model):
|
||||
id = models.BigAutoField(primary_key=True)
|
||||
re_ip = models.CharField(max_length=100, blank=True, null=True)
|
||||
re_time = models.DateTimeField(auto_now_add=True, null=True)
|
||||
re_url = models.CharField(max_length=200, blank=True, null=True)
|
||||
re_method = models.CharField(max_length=10, blank=True, null=True)
|
||||
re_content = models.CharField(max_length=200, blank=True, null=True)
|
||||
access_time = models.CharField(max_length=10, blank=True, null=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "b_op_log"
|
||||
|
||||
|
||||
class ErrorLog(models.Model):
|
||||
id = models.BigAutoField(primary_key=True)
|
||||
ip = models.CharField(max_length=100, blank=True, null=True)
|
||||
url = models.CharField(max_length=200, blank=True, null=True)
|
||||
method = models.CharField(max_length=10, blank=True, null=True)
|
||||
content = models.CharField(max_length=200, blank=True, null=True)
|
||||
log_time = models.DateTimeField(auto_now_add=True, null=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "b_error_log"
|
||||
|
||||
|
||||
class Order(models.Model):
|
||||
id = models.BigAutoField(primary_key=True)
|
||||
order_number = models.CharField(max_length=13, blank=True, null=True)
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, related_name='user_order')
|
||||
thing = models.ForeignKey(Thing, on_delete=models.CASCADE, null=True, related_name='thing_order')
|
||||
count = models.IntegerField(default=0)
|
||||
status = models.CharField(max_length=2, blank=True, null=True) # 1未审核 2已审核 7取消
|
||||
order_time = models.DateTimeField(auto_now_add=True, null=True)
|
||||
pay_time = models.DateTimeField(null=True)
|
||||
receiver_name = models.CharField(max_length=20, blank=True, null=True)
|
||||
receiver_address = models.CharField(max_length=50, blank=True, null=True)
|
||||
receiver_phone = models.CharField(max_length=20, blank=True, null=True)
|
||||
remark = models.CharField(max_length=30, blank=True, null=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "b_order"
|
||||
|
||||
|
||||
class OrderLog(models.Model):
|
||||
id = models.BigAutoField(primary_key=True)
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, related_name='user_order_log')
|
||||
thing = models.ForeignKey(Thing, on_delete=models.CASCADE, null=True, related_name='thing_order_log')
|
||||
action = models.CharField(max_length=2, blank=True, null=True)
|
||||
log_time = models.DateTimeField(auto_now_add=True, null=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "b_order_log"
|
||||
|
||||
|
||||
class Banner(models.Model):
|
||||
id = models.BigAutoField(primary_key=True)
|
||||
image = models.ImageField(upload_to='banner/', null=True)
|
||||
thing = models.ForeignKey(Thing, on_delete=models.CASCADE, null=True, related_name='thing_banner')
|
||||
create_time = models.DateTimeField(auto_now_add=True, null=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "b_banner"
|
||||
|
||||
|
||||
class Ad(models.Model):
|
||||
id = models.BigAutoField(primary_key=True)
|
||||
image = models.ImageField(upload_to='ad/', null=True)
|
||||
link = models.CharField(max_length=500, blank=True, null=True)
|
||||
create_time = models.DateTimeField(auto_now_add=True, null=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "b_ad"
|
||||
|
||||
|
||||
class Notice(models.Model):
|
||||
id = models.BigAutoField(primary_key=True)
|
||||
title = models.CharField(max_length=100, blank=True, null=True)
|
||||
content = models.CharField(max_length=1000, blank=True, null=True)
|
||||
create_time = models.DateTimeField(auto_now_add=True, null=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "b_notice"
|
||||
|
||||
|
||||
class Address(models.Model):
|
||||
id = models.BigAutoField(primary_key=True)
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, related_name='user_address')
|
||||
name = models.CharField(max_length=100, blank=True, null=True)
|
||||
mobile = models.CharField(max_length=30, blank=True, null=True)
|
||||
desc = models.CharField(max_length=300, blank=True, null=True)
|
||||
default = models.BooleanField(blank=True, null=True, default=False) # 是否默认地址
|
||||
create_time = models.DateTimeField(auto_now_add=True, null=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "b_address"
|
@ -0,0 +1,160 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from myapp.models import Thing, Classification, Tag, User, Comment, Record, LoginLog, Order, OrderLog, OpLog, Banner, \
|
||||
Ad, Notice, ErrorLog, Address
|
||||
|
||||
|
||||
class ThingSerializer(serializers.ModelSerializer):
|
||||
# 额外字段
|
||||
classification_title = serializers.ReadOnlyField(source='classification.title')
|
||||
|
||||
class Meta:
|
||||
model = Thing
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class DetailThingSerializer(serializers.ModelSerializer):
|
||||
# 额外字段
|
||||
classification_title = serializers.ReadOnlyField(source='classification.title')
|
||||
|
||||
class Meta:
|
||||
model = Thing
|
||||
# 排除多对多字段
|
||||
exclude = ('wish', 'collect',)
|
||||
|
||||
|
||||
class UpdateThingSerializer(serializers.ModelSerializer):
|
||||
# 额外字段
|
||||
classification_title = serializers.ReadOnlyField(source='classification.title')
|
||||
|
||||
class Meta:
|
||||
model = Thing
|
||||
# 排除多对多字段
|
||||
exclude = ('wish', 'collect',)
|
||||
|
||||
|
||||
class ListThingSerializer(serializers.ModelSerializer):
|
||||
# 额外字段
|
||||
classification_title = serializers.ReadOnlyField(source='classification.title')
|
||||
|
||||
class Meta:
|
||||
model = Thing
|
||||
# 排除字段
|
||||
exclude = ('wish', 'collect',)
|
||||
|
||||
|
||||
class ClassificationSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Classification
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class TagSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Tag
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class UserSerializer(serializers.ModelSerializer):
|
||||
create_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', required=False)
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = '__all__'
|
||||
# exclude = ('password',)
|
||||
|
||||
|
||||
class CommentSerializer(serializers.ModelSerializer):
|
||||
comment_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', required=False)
|
||||
# 额外字段
|
||||
title = serializers.ReadOnlyField(source='thing.title')
|
||||
username = serializers.ReadOnlyField(source='user.username')
|
||||
|
||||
class Meta:
|
||||
model = Comment
|
||||
fields = ['id', 'content', 'comment_time', 'like_count', 'thing', 'user', 'title', 'username']
|
||||
|
||||
|
||||
class RecordSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Record
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class LoginLogSerializer(serializers.ModelSerializer):
|
||||
log_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', required=False)
|
||||
|
||||
class Meta:
|
||||
model = LoginLog
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class OpLogSerializer(serializers.ModelSerializer):
|
||||
re_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', required=False)
|
||||
|
||||
class Meta:
|
||||
model = OpLog
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class ErrorLogSerializer(serializers.ModelSerializer):
|
||||
log_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', required=False)
|
||||
|
||||
class Meta:
|
||||
model = ErrorLog
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class OrderSerializer(serializers.ModelSerializer):
|
||||
order_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', required=False)
|
||||
expect_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', required=False)
|
||||
return_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', required=False)
|
||||
# extra
|
||||
username = serializers.ReadOnlyField(source='user.username')
|
||||
title = serializers.ReadOnlyField(source='thing.title')
|
||||
price = serializers.ReadOnlyField(source='thing.price')
|
||||
cover = serializers.FileField(source='thing.cover', required=False)
|
||||
|
||||
class Meta:
|
||||
model = Order
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class OrderLogSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = OrderLog
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class BannerSerializer(serializers.ModelSerializer):
|
||||
create_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', required=False)
|
||||
# extra
|
||||
title = serializers.ReadOnlyField(source='thing.title')
|
||||
|
||||
class Meta:
|
||||
model = Banner
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class AdSerializer(serializers.ModelSerializer):
|
||||
create_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', required=False)
|
||||
|
||||
class Meta:
|
||||
model = Ad
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class NoticeSerializer(serializers.ModelSerializer):
|
||||
create_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', required=False)
|
||||
|
||||
class Meta:
|
||||
model = Notice
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class AddressSerializer(serializers.ModelSerializer):
|
||||
create_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', required=False)
|
||||
|
||||
class Meta:
|
||||
model = Address
|
||||
fields = '__all__'
|
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
@ -0,0 +1,102 @@
|
||||
from django.urls import path
|
||||
|
||||
from myapp import views
|
||||
|
||||
app_name = 'myapp'
|
||||
urlpatterns = [
|
||||
# 后台管理api
|
||||
path('admin/overview/count', views.admin.overview.count),
|
||||
path('admin/overview/sysInfo', views.admin.overview.sysInfo),
|
||||
path('admin/thing/list', views.admin.thing.list_api),
|
||||
path('admin/thing/detail', views.admin.thing.detail),
|
||||
path('admin/thing/create', views.admin.thing.create),
|
||||
path('admin/thing/update', views.admin.thing.update),
|
||||
path('admin/thing/delete', views.admin.thing.delete),
|
||||
path('admin/comment/list', views.admin.comment.list_api),
|
||||
path('admin/comment/create', views.admin.comment.create),
|
||||
path('admin/comment/update', views.admin.comment.update),
|
||||
path('admin/comment/delete', views.admin.comment.delete),
|
||||
path('admin/classification/list', views.admin.classification.list_api),
|
||||
path('admin/classification/create', views.admin.classification.create),
|
||||
path('admin/classification/update', views.admin.classification.update),
|
||||
path('admin/classification/delete', views.admin.classification.delete),
|
||||
path('admin/tag/list', views.admin.tag.list_api),
|
||||
path('admin/tag/create', views.admin.tag.create),
|
||||
path('admin/tag/update', views.admin.tag.update),
|
||||
path('admin/tag/delete', views.admin.tag.delete),
|
||||
path('admin/record/list', views.admin.record.list_api),
|
||||
path('admin/record/create', views.admin.record.create),
|
||||
path('admin/record/update', views.admin.record.update),
|
||||
path('admin/record/delete', views.admin.record.delete),
|
||||
path('admin/banner/list', views.admin.banner.list_api),
|
||||
path('admin/banner/create', views.admin.banner.create),
|
||||
path('admin/banner/update', views.admin.banner.update),
|
||||
path('admin/banner/delete', views.admin.banner.delete),
|
||||
path('admin/ad/list', views.admin.ad.list_api),
|
||||
path('admin/ad/create', views.admin.ad.create),
|
||||
path('admin/ad/update', views.admin.ad.update),
|
||||
path('admin/ad/delete', views.admin.ad.delete),
|
||||
path('admin/notice/list', views.admin.notice.list_api),
|
||||
path('admin/notice/create', views.admin.notice.create),
|
||||
path('admin/notice/update', views.admin.notice.update),
|
||||
path('admin/notice/delete', views.admin.notice.delete),
|
||||
path('admin/order/list', views.admin.order.list_api),
|
||||
path('admin/order/create', views.admin.order.create),
|
||||
path('admin/order/update', views.admin.order.update),
|
||||
path('admin/order/cancel_order', views.admin.order.cancel_order),
|
||||
path('admin/order/pass_order', views.admin.order.pass_order),
|
||||
path('admin/order/delay', views.admin.order.delay),
|
||||
path('admin/order/delete', views.admin.order.delete),
|
||||
path('admin/loginLog/list', views.admin.loginLog.list_api),
|
||||
path('admin/loginLog/create', views.admin.loginLog.create),
|
||||
path('admin/loginLog/update', views.admin.loginLog.update),
|
||||
path('admin/loginLog/delete', views.admin.loginLog.delete),
|
||||
path('admin/opLog/list', views.admin.opLog.list_api),
|
||||
path('admin/errorLog/list', views.admin.errorLog.list_api),
|
||||
path('admin/user/list', views.admin.user.list_api),
|
||||
path('admin/user/create', views.admin.user.create),
|
||||
path('admin/user/update', views.admin.user.update),
|
||||
path('admin/user/updatePwd', views.admin.user.updatePwd),
|
||||
path('admin/user/delete', views.admin.user.delete),
|
||||
path('admin/user/info', views.admin.user.info),
|
||||
path('admin/adminLogin', views.admin.user.admin_login),
|
||||
|
||||
|
||||
# 前台管理api
|
||||
path('index/classification/list', views.index.classification.list_api),
|
||||
path('index/tag/list', views.index.tag.list_api),
|
||||
path('index/user/login', views.index.user.login),
|
||||
path('index/user/register', views.index.user.register),
|
||||
path('index/user/info', views.index.user.info),
|
||||
path('index/user/update', views.index.user.update),
|
||||
path('index/user/updatePwd', views.index.user.updatePwd),
|
||||
path('index/notice/list_api', views.index.notice.list_api),
|
||||
path('index/thing/list', views.index.thing.list_api),
|
||||
path('index/thing/detail', views.index.thing.detail),
|
||||
path('index/thing/increaseWishCount', views.index.thing.increaseWishCount),
|
||||
path('index/thing/addWishUser', views.index.thing.addWishUser),
|
||||
path('index/thing/removeWishUser', views.index.thing.removeWishUser),
|
||||
path('index/thing/getWishThingList', views.index.thing.getWishThingList),
|
||||
path('index/thing/addCollectUser', views.index.thing.addCollectUser),
|
||||
path('index/thing/removeCollectUser', views.index.thing.removeCollectUser),
|
||||
path('index/thing/getCollectThingList', views.index.thing.getCollectThingList),
|
||||
path('index/thing/increaseRecommendCount', views.index.thing.increaseRecommendCount),
|
||||
path('index/thing/listUserThing', views.index.thing.list_user_thing_api),
|
||||
path('index/thing/create', views.index.thing.create),
|
||||
path('index/thing/update', views.index.thing.update),
|
||||
path('index/comment/list', views.index.comment.list_api),
|
||||
path('index/comment/listMyComments', views.index.comment.list_my_comment),
|
||||
path('index/comment/create', views.index.comment.create),
|
||||
path('index/comment/delete', views.index.comment.delete),
|
||||
path('index/comment/like', views.index.comment.like),
|
||||
path('index/order/list', views.index.order.list_api),
|
||||
path('index/order/create', views.index.order.create),
|
||||
path('index/order/cancel_order', views.index.order.cancel_order),
|
||||
path('index/address/list', views.index.address.list_api),
|
||||
path('index/address/create', views.index.address.create),
|
||||
path('index/address/update', views.index.address.update),
|
||||
path('index/address/delete', views.index.address.delete),
|
||||
|
||||
|
||||
|
||||
]
|
@ -0,0 +1,2 @@
|
||||
from myapp.views.admin import *
|
||||
from myapp.views.index import *
|
@ -0,0 +1,14 @@
|
||||
from myapp.views.admin.thing import *
|
||||
from myapp.views.admin.classification import *
|
||||
from myapp.views.admin.tag import *
|
||||
from myapp.views.admin.user import *
|
||||
from myapp.views.admin.comment import *
|
||||
from myapp.views.admin.record import *
|
||||
from myapp.views.admin.overview import *
|
||||
from myapp.views.admin.loginLog import *
|
||||
from myapp.views.admin.order import *
|
||||
from myapp.views.admin.opLog import *
|
||||
from myapp.views.admin.errorLog import *
|
||||
from myapp.views.admin.banner import *
|
||||
from myapp.views.admin.ad import *
|
||||
from myapp.views.admin.notice import *
|
@ -0,0 +1,68 @@
|
||||
# Create your views here.
|
||||
from rest_framework.decorators import api_view, authentication_classes
|
||||
|
||||
from myapp.auth.authentication import AdminTokenAuthtication
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import Ad
|
||||
from myapp.permission.permission import isDemoAdminUser
|
||||
from myapp.serializers import AdSerializer
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
ads = Ad.objects.all().order_by('-create_time')
|
||||
serializer = AdSerializer(ads, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def create(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
serializer = AdSerializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='创建成功', data=serializer.data)
|
||||
|
||||
return APIResponse(code=1, msg='创建失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def update(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
ad = Ad.objects.get(pk=pk)
|
||||
except Ad.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
serializer = AdSerializer(ad, data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='更新成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
|
||||
return APIResponse(code=1, msg='更新失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def delete(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
ids = request.GET.get('ids')
|
||||
ids_arr = ids.split(',')
|
||||
Ad.objects.filter(id__in=ids_arr).delete()
|
||||
except Ad.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
return APIResponse(code=0, msg='删除成功')
|
@ -0,0 +1,68 @@
|
||||
# Create your views here.
|
||||
from rest_framework.decorators import api_view, authentication_classes
|
||||
|
||||
from myapp.auth.authentication import AdminTokenAuthtication
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import Banner
|
||||
from myapp.permission.permission import isDemoAdminUser
|
||||
from myapp.serializers import BannerSerializer
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
banners = Banner.objects.all().order_by('-create_time')
|
||||
serializer = BannerSerializer(banners, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def create(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
serializer = BannerSerializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='创建成功', data=serializer.data)
|
||||
|
||||
return APIResponse(code=1, msg='创建失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def update(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
banner = Banner.objects.get(pk=pk)
|
||||
except Banner.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
serializer = BannerSerializer(banner, data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='更新成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
|
||||
return APIResponse(code=1, msg='更新失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def delete(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
ids = request.GET.get('ids')
|
||||
ids_arr = ids.split(',')
|
||||
Banner.objects.filter(id__in=ids_arr).delete()
|
||||
except Banner.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
return APIResponse(code=0, msg='删除成功')
|
@ -0,0 +1,74 @@
|
||||
# Create your views here.
|
||||
from django.db import connection
|
||||
from django.db.models import Q
|
||||
from rest_framework.decorators import api_view, authentication_classes
|
||||
|
||||
from myapp.auth.authentication import AdminTokenAuthtication
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import Classification
|
||||
from myapp.permission.permission import isDemoAdminUser
|
||||
from myapp.serializers import ClassificationSerializer
|
||||
from myapp.utils import dict_fetchall
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
classifications = Classification.objects.all().order_by('-create_time')
|
||||
serializer = ClassificationSerializer(classifications, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def create(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
classification = Classification.objects.filter(title=request.data['title'])
|
||||
if len(classification) > 0:
|
||||
return APIResponse(code=1, msg='该名称已存在')
|
||||
|
||||
serializer = ClassificationSerializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='创建成功', data=serializer.data)
|
||||
|
||||
return APIResponse(code=1, msg='创建失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def update(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
print(pk)
|
||||
classification = Classification.objects.get(pk=pk)
|
||||
except Classification.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
serializer = ClassificationSerializer(classification, data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='更新成功', data=serializer.data)
|
||||
|
||||
return APIResponse(code=1, msg='更新失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def delete(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
ids = request.GET.get('ids')
|
||||
ids_arr = ids.split(',')
|
||||
# 删除自身和自身的子孩子
|
||||
Classification.objects.filter(Q(id__in=ids_arr)).delete()
|
||||
except Classification.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
return APIResponse(code=0, msg='删除成功')
|
@ -0,0 +1,69 @@
|
||||
# Create your views here.
|
||||
from rest_framework.decorators import api_view, authentication_classes
|
||||
|
||||
from myapp.auth.authentication import AdminTokenAuthtication
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import Comment
|
||||
from myapp.permission.permission import isDemoAdminUser
|
||||
from myapp.serializers import CommentSerializer
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
comments = Comment.objects.select_related("thing").all().order_by('-comment_time')
|
||||
# print(comments)
|
||||
serializer = CommentSerializer(comments, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def create(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
serializer = CommentSerializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='创建成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
|
||||
return APIResponse(code=1, msg='创建失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def update(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
comments = Comment.objects.get(pk=pk)
|
||||
except Comment.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
serializer = CommentSerializer(comments, data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='更新成功', data=serializer.data)
|
||||
|
||||
return APIResponse(code=1, msg='更新失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def delete(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
ids = request.GET.get('ids')
|
||||
ids_arr = ids.split(',')
|
||||
Comment.objects.filter(id__in=ids_arr).delete()
|
||||
except Comment.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
return APIResponse(code=0, msg='删除成功')
|
@ -0,0 +1,14 @@
|
||||
# Create your views here.
|
||||
from rest_framework.decorators import api_view
|
||||
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import ErrorLog
|
||||
from myapp.serializers import ErrorLogSerializer
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
errorLogs = ErrorLog.objects.all().order_by('-log_time')
|
||||
serializer = ErrorLogSerializer(errorLogs, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
@ -0,0 +1,60 @@
|
||||
# Create your views here.
|
||||
from rest_framework.decorators import api_view, authentication_classes
|
||||
|
||||
from myapp.auth.authentication import AdminTokenAuthtication
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import LoginLog
|
||||
from myapp.permission.permission import isDemoAdminUser
|
||||
from myapp.serializers import LoginLogSerializer
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
loginLogs = LoginLog.objects.all().order_by('-log_time')
|
||||
serializer = LoginLogSerializer(loginLogs, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def create(request):
|
||||
|
||||
serializer = LoginLogSerializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='创建成功', data=serializer.data)
|
||||
|
||||
return APIResponse(code=1, msg='创建失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def update(request):
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
loginLogs = LoginLog.objects.get(pk=pk)
|
||||
except LoginLog.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
serializer = LoginLogSerializer(loginLogs, data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='更新成功', data=serializer.data)
|
||||
|
||||
return APIResponse(code=1, msg='更新失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def delete(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
ids = request.GET.get('ids')
|
||||
ids_arr = ids.split(',')
|
||||
LoginLog.objects.filter(id__in=ids_arr).delete()
|
||||
except LoginLog.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
return APIResponse(code=0, msg='删除成功')
|
@ -0,0 +1,68 @@
|
||||
# Create your views here.
|
||||
from rest_framework.decorators import api_view, authentication_classes
|
||||
|
||||
from myapp.auth.authentication import AdminTokenAuthtication
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import Notice
|
||||
from myapp.permission.permission import isDemoAdminUser
|
||||
from myapp.serializers import NoticeSerializer
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
notices = Notice.objects.all().order_by('-create_time')
|
||||
serializer = NoticeSerializer(notices, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def create(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
serializer = NoticeSerializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='创建成功', data=serializer.data)
|
||||
|
||||
return APIResponse(code=1, msg='创建失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def update(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
notice = Notice.objects.get(pk=pk)
|
||||
except Notice.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
serializer = NoticeSerializer(notice, data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='更新成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
|
||||
return APIResponse(code=1, msg='更新失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def delete(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
ids = request.GET.get('ids')
|
||||
ids_arr = ids.split(',')
|
||||
Notice.objects.filter(id__in=ids_arr).delete()
|
||||
except Notice.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
return APIResponse(code=0, msg='删除成功')
|
@ -0,0 +1,14 @@
|
||||
# Create your views here.
|
||||
from rest_framework.decorators import api_view
|
||||
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import OpLog
|
||||
from myapp.serializers import OpLogSerializer
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
opLogs = OpLog.objects.all().order_by('-re_time')[:100]
|
||||
serializer = OpLogSerializer(opLogs, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
@ -0,0 +1,175 @@
|
||||
# Create your views here.
|
||||
import datetime
|
||||
|
||||
from rest_framework.decorators import api_view, authentication_classes
|
||||
|
||||
from myapp import utils
|
||||
from myapp.auth.authentication import AdminTokenAuthtication
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import Order, Thing
|
||||
from myapp.permission.permission import isDemoAdminUser
|
||||
from myapp.serializers import OrderSerializer
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
orders = Order.objects.all().order_by('-order_time')
|
||||
serializer = OrderSerializer(orders, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def create(request):
|
||||
"""
|
||||
创建订单
|
||||
"""
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
data = request.data.copy()
|
||||
if data['user'] is None or data['thing'] is None or data['count'] is None:
|
||||
return APIResponse(code=1, msg='参数错误')
|
||||
|
||||
thing = Thing.objects.get(pk=data['thing'])
|
||||
count = data['count']
|
||||
if thing.repertory < int(count):
|
||||
return APIResponse(code=1, msg='库存不足')
|
||||
|
||||
create_time = datetime.datetime.now()
|
||||
data['create_time'] = create_time
|
||||
data['order_number'] = str(utils.get_timestamp())
|
||||
data['status'] = '1'
|
||||
serializer = OrderSerializer(data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
# 减库存(支付后)
|
||||
# thing.repertory = thing.repertory - int(count)
|
||||
# thing.save()
|
||||
|
||||
return APIResponse(code=0, msg='创建成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
return APIResponse(code=1, msg='创建失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def update(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
order = Order.objects.get(pk=pk)
|
||||
except Order.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
serializer = OrderSerializer(order, data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='更新成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
return APIResponse(code=1, msg='更新失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def pass_order(request):
|
||||
"""
|
||||
取消
|
||||
"""
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
order = Order.objects.get(pk=pk)
|
||||
except Order.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
data = {
|
||||
'status': 2
|
||||
}
|
||||
serializer = OrderSerializer(order, data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
|
||||
return APIResponse(code=0, msg='成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
return APIResponse(code=1, msg='更新失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def cancel_order(request):
|
||||
"""
|
||||
取消
|
||||
"""
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
order = Order.objects.get(pk=pk)
|
||||
except Order.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
data = {
|
||||
'status': 7
|
||||
}
|
||||
serializer = OrderSerializer(order, data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
|
||||
return APIResponse(code=0, msg='取消成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
return APIResponse(code=1, msg='更新失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def delay(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
order = Order.objects.get(pk=pk)
|
||||
except Order.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
if order.delayed:
|
||||
return APIResponse(code=1, msg='已超最大延期次数')
|
||||
else:
|
||||
data = {
|
||||
"delayed": True,
|
||||
"expect_time": order.expect_time + datetime.timedelta(days=30)
|
||||
}
|
||||
serializer = OrderSerializer(order, data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='延期成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
return APIResponse(code=1, msg='延期失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def delete(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
ids = request.GET.get('ids')
|
||||
ids_arr = ids.split(',')
|
||||
Order.objects.filter(id__in=ids_arr).delete()
|
||||
except Order.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
return APIResponse(code=0, msg='删除成功')
|
@ -0,0 +1,98 @@
|
||||
# Create your views here.
|
||||
import datetime
|
||||
import locale
|
||||
import platform
|
||||
import random
|
||||
import time
|
||||
from multiprocessing import cpu_count
|
||||
|
||||
import psutil
|
||||
from django.db import connection
|
||||
from rest_framework.decorators import api_view, authentication_classes
|
||||
|
||||
from myapp import utils
|
||||
from myapp.handler import APIResponse
|
||||
|
||||
from myapp.models import Thing, Order
|
||||
from myapp.utils import dict_fetchall
|
||||
from myapp.auth.authentication import AdminTokenAuthtication
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def count(request):
|
||||
if request.method == 'GET':
|
||||
now = datetime.datetime.now()
|
||||
|
||||
# 统计排名(sql语句)
|
||||
sql_str = "select title, pv as count from b_thing order by count desc limit 10; "
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute(sql_str)
|
||||
order_rank_data = dict_fetchall(cursor)
|
||||
|
||||
# 统计分类比例(sql语句)
|
||||
sql_str = "select B.title, count(B.title) as count from b_thing A join B_classification B on " \
|
||||
"A.classification_id = B.id group by B.title order by count desc limit 5; "
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute(sql_str)
|
||||
classification_rank_data = dict_fetchall(cursor)
|
||||
|
||||
# 统计最近一周访问量(sql语句)
|
||||
visit_data = []
|
||||
week_days = utils.getWeekDays()
|
||||
for day in week_days:
|
||||
sql_str = "select re_ip, count(re_ip) as count from b_op_log where re_time like '" + day + "%' group by re_ip"
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute(sql_str)
|
||||
ip_data = dict_fetchall(cursor)
|
||||
uv = len(ip_data)
|
||||
pv = 0
|
||||
for item in ip_data:
|
||||
pv = pv + item['count']
|
||||
visit_data.append({
|
||||
"day": day,
|
||||
"uv": uv + random.randint(1, 20),
|
||||
"pv": pv + random.randint(20, 100)
|
||||
})
|
||||
|
||||
data = {
|
||||
'order_rank_data': order_rank_data,
|
||||
'classification_rank_data': classification_rank_data,
|
||||
'visit_data': visit_data
|
||||
}
|
||||
return APIResponse(code=0, msg='查询成功', data=data)
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def sysInfo(request):
|
||||
if request.method == 'GET':
|
||||
pyVersion = platform.python_version()
|
||||
osBuild = platform.architecture()
|
||||
node = platform.node()
|
||||
pf = platform.platform()
|
||||
processor = platform.processor()
|
||||
pyComp = platform.python_compiler()
|
||||
osName = platform.system()
|
||||
memory = psutil.virtual_memory()
|
||||
|
||||
data = {
|
||||
'sysName': '后台管理系统',
|
||||
'versionName': '1.1.0',
|
||||
'osName': osName,
|
||||
'pyVersion': pyVersion,
|
||||
'osBuild': osBuild,
|
||||
'node': node,
|
||||
'pf': pf,
|
||||
'processor': processor,
|
||||
'cpuCount': cpu_count(),
|
||||
'pyComp': pyComp,
|
||||
'cpuLoad': round((psutil.cpu_percent(1)), 2),
|
||||
'memory': round((float(memory.total) / 1024 / 1024 / 1024), 2),
|
||||
'usedMemory': round((float(memory.used) / 1024 / 1024 / 1024), 2),
|
||||
'percentMemory': round((float(memory.used) / float(memory.total) * 100), 2),
|
||||
'sysLan': locale.getdefaultlocale(),
|
||||
'sysZone': time.strftime('%Z', time.localtime())
|
||||
}
|
||||
|
||||
return APIResponse(code=0, msg='查询成功', data=data)
|
@ -0,0 +1,53 @@
|
||||
# Create your views here.
|
||||
from rest_framework.decorators import api_view
|
||||
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import Record
|
||||
from myapp.serializers import RecordSerializer
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
records = Record.objects.all()
|
||||
serializer = RecordSerializer(records, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def create(request):
|
||||
|
||||
serializer = RecordSerializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='创建成功', data=serializer.data)
|
||||
|
||||
return APIResponse(code=1, msg='创建失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def update(request):
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
records = Record.objects.get(pk=pk)
|
||||
except Record.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
serializer = RecordSerializer(records, data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='更新成功', data=serializer.data)
|
||||
|
||||
return APIResponse(code=1, msg='更新失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def delete(request):
|
||||
try:
|
||||
ids = request.GET.get('ids')
|
||||
ids_arr = ids.split(',')
|
||||
Record.objects.filter(id__in=ids_arr).delete()
|
||||
except Record.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
return APIResponse(code=0, msg='删除成功')
|
@ -0,0 +1,75 @@
|
||||
# Create your views here.
|
||||
from rest_framework.decorators import api_view, authentication_classes
|
||||
|
||||
from myapp import utils
|
||||
from myapp.auth.authentication import AdminTokenAuthtication
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import Tag
|
||||
from myapp.permission.permission import isDemoAdminUser
|
||||
from myapp.serializers import TagSerializer
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
tags = Tag.objects.all().order_by('-create_time')
|
||||
serializer = TagSerializer(tags, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def create(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
tags = Tag.objects.filter(title=request.data['title'])
|
||||
if len(tags) > 0:
|
||||
return APIResponse(code=1, msg='该名称已存在')
|
||||
|
||||
serializer = TagSerializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='创建成功', data=serializer.data)
|
||||
else:
|
||||
utils.log_error(request, '参数错误')
|
||||
|
||||
return APIResponse(code=1, msg='创建失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def update(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
tags = Tag.objects.get(pk=pk)
|
||||
except Tag.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
serializer = TagSerializer(tags, data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='更新成功', data=serializer.data)
|
||||
else:
|
||||
utils.log_error(request, '参数错误')
|
||||
|
||||
return APIResponse(code=1, msg='更新失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def delete(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
ids = request.GET.get('ids')
|
||||
ids_arr = ids.split(',')
|
||||
Tag.objects.filter(id__in=ids_arr).delete()
|
||||
except Tag.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
return APIResponse(code=0, msg='删除成功')
|
@ -0,0 +1,104 @@
|
||||
# Create your views here.
|
||||
from rest_framework.decorators import api_view, authentication_classes
|
||||
|
||||
from myapp import utils
|
||||
from myapp.auth.authentication import AdminTokenAuthtication
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import Classification, Thing, Tag
|
||||
from myapp.permission.permission import isDemoAdminUser
|
||||
from myapp.serializers import ThingSerializer, UpdateThingSerializer
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
keyword = request.GET.get("keyword", None)
|
||||
c = request.GET.get("c", None)
|
||||
tag = request.GET.get("tag", None)
|
||||
if keyword:
|
||||
things = Thing.objects.filter(title__contains=keyword).order_by('create_time')
|
||||
elif c:
|
||||
classification = Classification.objects.get(pk=c)
|
||||
things = classification.classification_thing.all()
|
||||
elif tag:
|
||||
tag = Tag.objects.get(id=tag)
|
||||
print(tag)
|
||||
things = tag.thing_set.all()
|
||||
else:
|
||||
things = Thing.objects.all().order_by('create_time')
|
||||
|
||||
serializer = ThingSerializer(things, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def detail(request):
|
||||
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
thing = Thing.objects.get(pk=pk)
|
||||
except Thing.DoesNotExist:
|
||||
utils.log_error(request, '对象不存在')
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
if request.method == 'GET':
|
||||
serializer = ThingSerializer(thing)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def create(request):
|
||||
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
serializer = ThingSerializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='创建成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
utils.log_error(request, '参数错误')
|
||||
|
||||
return APIResponse(code=1, msg='创建失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def update(request):
|
||||
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
thing = Thing.objects.get(pk=pk)
|
||||
except Thing.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
serializer = UpdateThingSerializer(thing, data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
utils.log_error(request, '参数错误')
|
||||
|
||||
return APIResponse(code=1, msg='更新失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def delete(request):
|
||||
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
ids = request.GET.get('ids')
|
||||
ids_arr = ids.split(',')
|
||||
Thing.objects.filter(id__in=ids_arr).delete()
|
||||
except Thing.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
return APIResponse(code=0, msg='删除成功')
|
@ -0,0 +1,176 @@
|
||||
# Create your views here.
|
||||
import datetime
|
||||
|
||||
from rest_framework.decorators import api_view, authentication_classes
|
||||
|
||||
from myapp import utils
|
||||
from myapp.auth.authentication import AdminTokenAuthtication
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import User
|
||||
from myapp.permission.permission import isDemoAdminUser
|
||||
from myapp.serializers import UserSerializer, LoginLogSerializer
|
||||
from myapp.utils import md5value
|
||||
|
||||
|
||||
def make_login_log(request):
|
||||
try:
|
||||
username = request.data['username']
|
||||
data = {
|
||||
"username": username,
|
||||
"ip": utils.get_ip(request),
|
||||
"ua": utils.get_ua(request)
|
||||
}
|
||||
serializer = LoginLogSerializer(data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
else:
|
||||
print(serializer.errors)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def admin_login(request):
|
||||
username = request.data['username']
|
||||
password = utils.md5value(request.data['password'])
|
||||
|
||||
users = User.objects.filter(username=username, password=password, role__in=['1', '3'])
|
||||
if len(users) > 0:
|
||||
user = users[0]
|
||||
data = {
|
||||
'username': username,
|
||||
'password': password,
|
||||
'admin_token': md5value(username) # 生成令牌
|
||||
}
|
||||
serializer = UserSerializer(user, data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
make_login_log(request)
|
||||
return APIResponse(code=0, msg='登录成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
|
||||
return APIResponse(code=1, msg='用户名或密码错误')
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def info(request):
|
||||
if request.method == 'GET':
|
||||
pk = request.GET.get('id', -1)
|
||||
user = User.objects.get(pk=pk)
|
||||
serializer = UserSerializer(user)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
keyword = request.GET.get("keyword", '')
|
||||
users = User.objects.filter(username__contains=keyword).order_by('-create_time')
|
||||
serializer = UserSerializer(users, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def create(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
print(request.data)
|
||||
if not request.data.get('username', None) or not request.data.get('password', None):
|
||||
return APIResponse(code=1, msg='用户名或密码不能为空')
|
||||
users = User.objects.filter(username=request.data['username'])
|
||||
if len(users) > 0:
|
||||
return APIResponse(code=1, msg='该用户名已存在')
|
||||
|
||||
data = request.data.copy()
|
||||
data.update({'password': utils.md5value(request.data['password'])})
|
||||
serializer = UserSerializer(data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='创建成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
|
||||
return APIResponse(code=1, msg='创建失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def update(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
user = User.objects.get(pk=pk)
|
||||
except User.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
data = request.data.copy()
|
||||
if 'username' in data.keys():
|
||||
del data['username']
|
||||
if 'password' in data.keys():
|
||||
del data['password']
|
||||
serializer = UserSerializer(user, data=data)
|
||||
print(serializer.is_valid())
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='更新成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
return APIResponse(code=1, msg='更新失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def updatePwd(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
user = User.objects.get(pk=pk)
|
||||
except User.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
password = request.data.get('password', None)
|
||||
newPassword1 = request.data.get('newPassword1', None)
|
||||
newPassword2 = request.data.get('newPassword2', None)
|
||||
|
||||
if not password or not newPassword1 or not newPassword2:
|
||||
return APIResponse(code=1, msg='不能为空')
|
||||
|
||||
if user.password != utils.md5value(password):
|
||||
return APIResponse(code=1, msg='原密码不正确')
|
||||
|
||||
if newPassword1 != newPassword2:
|
||||
return APIResponse(code=1, msg='两次密码不一致')
|
||||
|
||||
data = request.data.copy()
|
||||
data.update({'password': utils.md5value(newPassword1)})
|
||||
serializer = UserSerializer(user, data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='更新成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
|
||||
return APIResponse(code=1, msg='更新失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([AdminTokenAuthtication])
|
||||
def delete(request):
|
||||
if isDemoAdminUser(request):
|
||||
return APIResponse(code=1, msg='演示帐号无法操作')
|
||||
|
||||
try:
|
||||
ids = request.GET.get('ids')
|
||||
ids_arr = ids.split(',')
|
||||
User.objects.filter(id__in=ids_arr).delete()
|
||||
except User.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
return APIResponse(code=0, msg='删除成功')
|
@ -0,0 +1,8 @@
|
||||
from myapp.views.index.classification import *
|
||||
from myapp.views.index.tag import *
|
||||
from myapp.views.index.user import *
|
||||
from myapp.views.index.thing import *
|
||||
from myapp.views.index.comment import *
|
||||
from myapp.views.index.order import *
|
||||
from myapp.views.index.notice import *
|
||||
from myapp.views.index.address import *
|
@ -0,0 +1,87 @@
|
||||
# Create your views here.
|
||||
from rest_framework.decorators import api_view, authentication_classes
|
||||
|
||||
from myapp import utils
|
||||
from myapp.auth.authentication import TokenAuthtication
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import Address
|
||||
from myapp.serializers import AddressSerializer
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
userId = request.GET.get('userId', -1)
|
||||
|
||||
if userId != -1:
|
||||
addresses = Address.objects.filter(user=userId).order_by('-create_time')
|
||||
serializer = AddressSerializer(addresses, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
else:
|
||||
return APIResponse(code=1, msg='userId不能为空')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([TokenAuthtication])
|
||||
def create(request):
|
||||
|
||||
address_content = request.POST.get('desc', None)
|
||||
user = request.POST.get('user', None)
|
||||
default = request.POST.get('default', False)
|
||||
|
||||
if address_content is None or user is None:
|
||||
return APIResponse(code=1, msg='不能为空')
|
||||
|
||||
if default:
|
||||
# 其他置为false
|
||||
Address.objects.filter(user=user).update(default=False)
|
||||
|
||||
serializer = AddressSerializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='创建成功', data=serializer.data)
|
||||
else:
|
||||
utils.log_error(request, '参数错误')
|
||||
|
||||
return APIResponse(code=1, msg='创建失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([TokenAuthtication])
|
||||
def update(request):
|
||||
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
addresses = Address.objects.get(pk=pk)
|
||||
except Address.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
user = request.data['user']
|
||||
default = request.data['default']
|
||||
|
||||
if default:
|
||||
# 其他置为false
|
||||
Address.objects.filter(user=user).update(default=False)
|
||||
|
||||
serializer = AddressSerializer(addresses, data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='更新成功', data=serializer.data)
|
||||
else:
|
||||
utils.log_error(request, '参数错误')
|
||||
|
||||
return APIResponse(code=1, msg='更新失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([TokenAuthtication])
|
||||
def delete(request):
|
||||
|
||||
try:
|
||||
ids = request.GET.get('ids')
|
||||
ids_arr = ids.split(',')
|
||||
Address.objects.filter(id__in=ids_arr).delete()
|
||||
except Address.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
return APIResponse(code=0, msg='删除成功')
|
@ -0,0 +1,21 @@
|
||||
# Create your views here.
|
||||
from django.db import connection
|
||||
from rest_framework.decorators import api_view
|
||||
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import Classification
|
||||
from myapp.serializers import ClassificationSerializer
|
||||
from myapp.utils import dict_fetchall
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
classifications = Classification.objects.all().order_by('-create_time')
|
||||
serializer = ClassificationSerializer(classifications, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,87 @@
|
||||
# Create your views here.
|
||||
from rest_framework.decorators import api_view, authentication_classes, throttle_classes
|
||||
|
||||
from myapp.auth.MyRateThrottle import MyRateThrottle
|
||||
from myapp.auth.authentication import AdminTokenAuthtication
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import Comment
|
||||
from myapp.permission.permission import isDemoAdminUser
|
||||
from myapp.serializers import CommentSerializer
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
thingId = request.GET.get("thingId", None)
|
||||
order = request.GET.get("order", 'recent')
|
||||
|
||||
if thingId:
|
||||
if order == 'recent':
|
||||
orderBy = '-comment_time'
|
||||
else:
|
||||
orderBy = '-like_count'
|
||||
|
||||
comments = Comment.objects.select_related("thing").filter(thing=thingId).order_by(orderBy)
|
||||
# print(comments)
|
||||
serializer = CommentSerializer(comments, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
else:
|
||||
return APIResponse(code=1, msg='thingId不能为空')
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_my_comment(request):
|
||||
if request.method == 'GET':
|
||||
userId = request.GET.get("userId", None)
|
||||
order = request.GET.get("order", 'recent')
|
||||
|
||||
if userId:
|
||||
if order == 'recent':
|
||||
orderBy = '-comment_time'
|
||||
else:
|
||||
orderBy = '-like_count'
|
||||
|
||||
comments = Comment.objects.select_related("thing").filter(user=userId).order_by(orderBy)
|
||||
# print(comments)
|
||||
serializer = CommentSerializer(comments, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
else:
|
||||
return APIResponse(code=1, msg='userId不能为空')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@throttle_classes([MyRateThrottle])
|
||||
def create(request):
|
||||
serializer = CommentSerializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='创建成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
|
||||
return APIResponse(code=1, msg='创建失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def delete(request):
|
||||
try:
|
||||
ids = request.GET.get('ids')
|
||||
ids_arr = ids.split(',')
|
||||
Comment.objects.filter(id__in=ids_arr).delete()
|
||||
except Comment.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
return APIResponse(code=0, msg='删除成功')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def like(request):
|
||||
try:
|
||||
commentId = request.GET.get('commentId')
|
||||
comment = Comment.objects.get(pk=commentId)
|
||||
comment.like_count += 1
|
||||
comment.save()
|
||||
except Comment.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
return APIResponse(code=0, msg='推荐成功')
|
@ -0,0 +1,15 @@
|
||||
# Create your views here.
|
||||
from rest_framework.decorators import api_view
|
||||
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import Notice
|
||||
from myapp.serializers import NoticeSerializer
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
notices = Notice.objects.all().order_by('-create_time')
|
||||
serializer = NoticeSerializer(notices, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
@ -0,0 +1,85 @@
|
||||
# Create your views here.
|
||||
import datetime
|
||||
|
||||
from rest_framework.decorators import api_view, authentication_classes
|
||||
|
||||
from myapp import utils
|
||||
from myapp.auth.authentication import TokenAuthtication
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import Order, Thing
|
||||
from myapp.serializers import OrderSerializer
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
userId = request.GET.get('userId', -1)
|
||||
orderStatus = request.GET.get('orderStatus', '')
|
||||
|
||||
orders = Order.objects.all().filter(user=userId).filter(status__contains=orderStatus).order_by('-order_time')
|
||||
serializer = OrderSerializer(orders, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([TokenAuthtication])
|
||||
def create(request):
|
||||
|
||||
data = request.data.copy()
|
||||
if data['user'] is None or data['thing'] is None or data['count'] is None:
|
||||
return APIResponse(code=1, msg='参数错误')
|
||||
|
||||
# thing = Thing.objects.get(pk=data['thing'])
|
||||
# count = data['count']
|
||||
# if thing.repertory < int(count):
|
||||
# return APIResponse(code=1, msg='库存不足')
|
||||
|
||||
create_time = datetime.datetime.now()
|
||||
data['create_time'] = create_time
|
||||
data['order_number'] = str(utils.get_timestamp())
|
||||
data['status'] = '1'
|
||||
serializer = OrderSerializer(data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
# 减库存(支付后)
|
||||
# thing.repertory = thing.repertory - int(count)
|
||||
# thing.save()
|
||||
|
||||
return APIResponse(code=0, msg='创建成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
return APIResponse(code=1, msg='创建失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([TokenAuthtication])
|
||||
def cancel_order(request):
|
||||
"""
|
||||
cancal
|
||||
"""
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
order = Order.objects.get(pk=pk)
|
||||
except Order.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
data = {
|
||||
'status': 7
|
||||
}
|
||||
serializer = OrderSerializer(order, data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
# 加库存
|
||||
# thingId = request.data['thing']
|
||||
# thing = Thing.objects.get(pk=thingId)
|
||||
# thing.repertory = thing.repertory + 1
|
||||
# thing.save()
|
||||
|
||||
# 加积分
|
||||
# order.user.score = order.user.score + 1
|
||||
# order.user.save()
|
||||
|
||||
return APIResponse(code=0, msg='取消成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
return APIResponse(code=1, msg='更新失败')
|
@ -0,0 +1,15 @@
|
||||
# Create your views here.
|
||||
from rest_framework.decorators import api_view
|
||||
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import Tag
|
||||
from myapp.serializers import TagSerializer
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
tags = Tag.objects.all().order_by('-create_time')
|
||||
serializer = TagSerializer(tags, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
@ -0,0 +1,264 @@
|
||||
# Create your views here.
|
||||
from django.db import connection
|
||||
from rest_framework.decorators import api_view, authentication_classes
|
||||
|
||||
from myapp import utils
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import Classification, Thing, Tag, User
|
||||
from myapp.serializers import ThingSerializer, ClassificationSerializer, ListThingSerializer, DetailThingSerializer, \
|
||||
UpdateThingSerializer
|
||||
from myapp.utils import dict_fetchall
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_api(request):
|
||||
if request.method == 'GET':
|
||||
keyword = request.GET.get("keyword", None)
|
||||
c = request.GET.get("c", None)
|
||||
tag = request.GET.get("tag", None)
|
||||
sort = request.GET.get("sort", 'recent')
|
||||
|
||||
# 排序方式
|
||||
order = '-create_time'
|
||||
if sort == 'recent':
|
||||
order = '-create_time'
|
||||
elif sort == 'hot' or sort == 'recommend':
|
||||
order = '-pv'
|
||||
|
||||
if keyword:
|
||||
things = Thing.objects.filter(title__contains=keyword).filter(status='0').order_by(order)
|
||||
|
||||
# todo
|
||||
elif c and int(c) > -1:
|
||||
ids = [c]
|
||||
|
||||
things = Thing.objects.filter(classification_id__in=ids).filter(status='0').order_by(order)
|
||||
|
||||
elif tag:
|
||||
tag = Tag.objects.get(id=tag)
|
||||
print(tag)
|
||||
things = tag.thing_set.all().filter(status='0').order_by(order)
|
||||
else:
|
||||
things = Thing.objects.all().defer('wish').filter(status='0').order_by(order)
|
||||
|
||||
serializer = ListThingSerializer(things, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def detail(request):
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
thing = Thing.objects.get(pk=pk)
|
||||
thing.pv = thing.pv + 1
|
||||
thing.save()
|
||||
except Thing.DoesNotExist:
|
||||
utils.log_error(request, '对象不存在')
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
if request.method == 'GET':
|
||||
serializer = ThingSerializer(thing)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def increaseWishCount(request):
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
thing = Thing.objects.get(pk=pk)
|
||||
# wish_count加1
|
||||
thing.wish_count = thing.wish_count + 1
|
||||
thing.save()
|
||||
except Thing.DoesNotExist:
|
||||
utils.log_error(request, '对象不存在')
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
serializer = ThingSerializer(thing)
|
||||
return APIResponse(code=0, msg='操作成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def increaseRecommendCount(request):
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
thing = Thing.objects.get(pk=pk)
|
||||
# recommend_count加1
|
||||
thing.recommend_count = thing.recommend_count + 1
|
||||
thing.save()
|
||||
except Thing.DoesNotExist:
|
||||
utils.log_error(request, '对象不存在')
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
serializer = ThingSerializer(thing)
|
||||
return APIResponse(code=0, msg='操作成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def addWishUser(request):
|
||||
try:
|
||||
username = request.GET.get('username', None)
|
||||
thingId = request.GET.get('thingId', None)
|
||||
|
||||
if username and thingId:
|
||||
user = User.objects.get(username=username)
|
||||
thing = Thing.objects.get(pk=thingId)
|
||||
|
||||
if user not in thing.wish.all():
|
||||
thing.wish.add(user)
|
||||
thing.wish_count += 1
|
||||
thing.save()
|
||||
|
||||
except Thing.DoesNotExist:
|
||||
utils.log_error(request, '操作失败')
|
||||
return APIResponse(code=1, msg='操作失败')
|
||||
|
||||
serializer = ThingSerializer(thing)
|
||||
return APIResponse(code=0, msg='操作成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def removeWishUser(request):
|
||||
try:
|
||||
username = request.GET.get('username', None)
|
||||
thingId = request.GET.get('thingId', None)
|
||||
|
||||
if username and thingId:
|
||||
user = User.objects.get(username=username)
|
||||
thing = Thing.objects.get(pk=thingId)
|
||||
|
||||
if user in thing.wish.all():
|
||||
thing.wish.remove(user)
|
||||
thing.wish_count -= 1
|
||||
thing.save()
|
||||
|
||||
except Thing.DoesNotExist:
|
||||
utils.log_error(request, '操作失败')
|
||||
return APIResponse(code=1, msg='操作失败')
|
||||
|
||||
return APIResponse(code=0, msg='操作成功')
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def getWishThingList(request):
|
||||
try:
|
||||
username = request.GET.get('username', None)
|
||||
if username:
|
||||
user = User.objects.get(username=username)
|
||||
things = user.wish_things.all()
|
||||
serializer = ListThingSerializer(things, many=True)
|
||||
return APIResponse(code=0, msg='操作成功', data=serializer.data)
|
||||
else:
|
||||
return APIResponse(code=1, msg='username不能为空')
|
||||
|
||||
except Exception as e:
|
||||
utils.log_error(request, '操作失败' + str(e))
|
||||
return APIResponse(code=1, msg='获取心愿单失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def addCollectUser(request):
|
||||
try:
|
||||
username = request.GET.get('username', None)
|
||||
thingId = request.GET.get('thingId', None)
|
||||
|
||||
if username and thingId:
|
||||
user = User.objects.get(username=username)
|
||||
thing = Thing.objects.get(pk=thingId)
|
||||
|
||||
if user not in thing.collect.all():
|
||||
thing.collect.add(user)
|
||||
thing.collect_count += 1
|
||||
thing.save()
|
||||
|
||||
except Thing.DoesNotExist:
|
||||
utils.log_error(request, '操作失败')
|
||||
return APIResponse(code=1, msg='操作失败')
|
||||
|
||||
serializer = DetailThingSerializer(thing)
|
||||
return APIResponse(code=0, msg='操作成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def removeCollectUser(request):
|
||||
try:
|
||||
username = request.GET.get('username', None)
|
||||
thingId = request.GET.get('thingId', None)
|
||||
|
||||
if username and thingId:
|
||||
user = User.objects.get(username=username)
|
||||
thing = Thing.objects.get(pk=thingId)
|
||||
|
||||
if user in thing.collect.all():
|
||||
thing.collect.remove(user)
|
||||
thing.collect_count -= 1
|
||||
thing.save()
|
||||
|
||||
except Thing.DoesNotExist:
|
||||
utils.log_error(request, '操作失败')
|
||||
return APIResponse(code=1, msg='操作失败')
|
||||
|
||||
return APIResponse(code=0, msg='操作成功')
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def getCollectThingList(request):
|
||||
try:
|
||||
username = request.GET.get('username', None)
|
||||
if username:
|
||||
user = User.objects.get(username=username)
|
||||
things = user.collect_things.all()
|
||||
serializer = ListThingSerializer(things, many=True)
|
||||
return APIResponse(code=0, msg='操作成功', data=serializer.data)
|
||||
else:
|
||||
return APIResponse(code=1, msg='username不能为空')
|
||||
|
||||
except Exception as e:
|
||||
utils.log_error(request, '操作失败' + str(e))
|
||||
return APIResponse(code=1, msg='获取收藏失败')
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def list_user_thing_api(request):
|
||||
if request.method == 'GET':
|
||||
user = request.GET.get("user", None)
|
||||
|
||||
if user:
|
||||
things = Thing.objects.filter(user=user)
|
||||
serializer = ListThingSerializer(things, many=True)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
else:
|
||||
return APIResponse(code=1, msg='user不能为空')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def create(request):
|
||||
data = request.data.copy()
|
||||
data['status'] = '1'
|
||||
serializer = ThingSerializer(data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='创建成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
utils.log_error(request, '参数错误')
|
||||
|
||||
return APIResponse(code=1, msg='创建失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def update(request):
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
thing = Thing.objects.get(pk=pk)
|
||||
except Thing.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
serializer = UpdateThingSerializer(thing, data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
utils.log_error(request, '参数错误')
|
||||
|
||||
return APIResponse(code=1, msg='更新失败')
|
@ -0,0 +1,162 @@
|
||||
# Create your views here.
|
||||
import datetime
|
||||
|
||||
from rest_framework.decorators import api_view, authentication_classes
|
||||
|
||||
from myapp import utils
|
||||
from myapp.auth.authentication import TokenAuthtication
|
||||
from myapp.handler import APIResponse
|
||||
from myapp.models import User
|
||||
from myapp.serializers import UserSerializer, LoginLogSerializer
|
||||
from myapp.utils import md5value
|
||||
|
||||
|
||||
def make_login_log(request):
|
||||
try:
|
||||
username = request.data['username']
|
||||
data = {
|
||||
"username": username,
|
||||
"ip": utils.get_ip(request),
|
||||
"ua": utils.get_ua(request)
|
||||
}
|
||||
serializer = LoginLogSerializer(data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
else:
|
||||
print(serializer.errors)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def login(request):
|
||||
username = request.data['username']
|
||||
password = utils.md5value(request.data['password'])
|
||||
|
||||
users = User.objects.filter(username=username, password=password)
|
||||
if len(users) > 0:
|
||||
user = users[0]
|
||||
|
||||
if user.role in ['1', '3']:
|
||||
return APIResponse(code=1, msg='该帐号为后台管理员帐号')
|
||||
|
||||
data = {
|
||||
'username': username,
|
||||
'password': password,
|
||||
'token': md5value(username) # 生成令牌
|
||||
}
|
||||
serializer = UserSerializer(user, data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
make_login_log(request)
|
||||
return APIResponse(code=0, msg='登录成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
|
||||
return APIResponse(code=1, msg='用户名或密码错误')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
def register(request):
|
||||
print(request.data)
|
||||
username = request.data.get('username', None)
|
||||
password = request.data.get('password', None)
|
||||
repassword = request.data.get('repassword', None)
|
||||
if not username or not password or not repassword:
|
||||
return APIResponse(code=1, msg='用户名或密码不能为空')
|
||||
if password != repassword:
|
||||
return APIResponse(code=1, msg='密码不一致')
|
||||
users = User.objects.filter(username=username)
|
||||
if len(users) > 0:
|
||||
return APIResponse(code=1, msg='该用户名已存在')
|
||||
|
||||
data = {
|
||||
'username': username,
|
||||
'password': password,
|
||||
'role': 2, # 角色2
|
||||
'status': 0,
|
||||
}
|
||||
data.update({'password': utils.md5value(request.data['password'])})
|
||||
serializer = UserSerializer(data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='创建成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
|
||||
return APIResponse(code=1, msg='创建失败')
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def info(request):
|
||||
if request.method == 'GET':
|
||||
pk = request.GET.get('id', -1)
|
||||
user = User.objects.get(pk=pk)
|
||||
serializer = UserSerializer(user)
|
||||
return APIResponse(code=0, msg='查询成功', data=serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([TokenAuthtication])
|
||||
def update(request):
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
user = User.objects.get(pk=pk)
|
||||
except User.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
data = request.data.copy()
|
||||
if 'username' in data.keys():
|
||||
del data['username']
|
||||
if 'password' in data.keys():
|
||||
del data['password']
|
||||
if 'role' in data.keys():
|
||||
del data['role']
|
||||
serializer = UserSerializer(user, data=data)
|
||||
print(serializer.is_valid())
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='更新成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
|
||||
return APIResponse(code=1, msg='更新失败')
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([TokenAuthtication])
|
||||
def updatePwd(request):
|
||||
|
||||
try:
|
||||
pk = request.GET.get('id', -1)
|
||||
user = User.objects.get(pk=pk)
|
||||
except User.DoesNotExist:
|
||||
return APIResponse(code=1, msg='对象不存在')
|
||||
|
||||
print(user.role)
|
||||
if user.role != '2':
|
||||
return APIResponse(code=1, msg='参数非法')
|
||||
|
||||
password = request.data.get('password', None)
|
||||
newPassword1 = request.data.get('newPassword1', None)
|
||||
newPassword2 = request.data.get('newPassword2', None)
|
||||
|
||||
if not password or not newPassword1 or not newPassword2:
|
||||
return APIResponse(code=1, msg='不能为空')
|
||||
|
||||
if user.password != utils.md5value(password):
|
||||
return APIResponse(code=1, msg='原密码不正确')
|
||||
|
||||
if newPassword1 != newPassword2:
|
||||
return APIResponse(code=1, msg='两次密码不一致')
|
||||
|
||||
data = request.data.copy()
|
||||
data.update({'password': utils.md5value(newPassword1)})
|
||||
serializer = UserSerializer(user, data=data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return APIResponse(code=0, msg='更新成功', data=serializer.data)
|
||||
else:
|
||||
print(serializer.errors)
|
||||
|
||||
return APIResponse(code=1, msg='更新失败')
|
@ -0,0 +1,6 @@
|
||||
Django==3.2.11
|
||||
PyMySQL==1.0.2
|
||||
djangorestframework==3.13.0
|
||||
django-cors-headers==3.13.0
|
||||
Pillow==9.1.1
|
||||
psutil==5.9.4
|
@ -0,0 +1,4 @@
|
||||
import pymysql
|
||||
pymysql.install_as_MySQLdb()
|
||||
|
||||
print("===============install pymysql==============")
|
@ -0,0 +1,16 @@
|
||||
"""
|
||||
ASGI config for server project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
|
||||
|
||||
application = get_asgi_application()
|
@ -0,0 +1,150 @@
|
||||
"""
|
||||
Django settings for server project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 4.1.4.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/4.1/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/4.1/ref/settings/
|
||||
"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
# BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
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/4.1/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'django-insecure-sz@madp0ifx!b)^lg_g!f+5s*w7w_=sjgq-k+erzb%x42$^r!d'
|
||||
|
||||
# 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',
|
||||
'rest_framework',
|
||||
'corsheaders', # 跨域
|
||||
'myapp'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'corsheaders.middleware.CorsMiddleware', # 跨域配置
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'myapp.middlewares.LogMiddleware.OpLogs'
|
||||
]
|
||||
|
||||
CORS_ORIGIN_ALLOW_ALL = True # 允许跨域
|
||||
|
||||
ROOT_URLCONF = 'server.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'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 = 'server.wsgi.application'
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': 'python_team',
|
||||
'USER': 'root',
|
||||
'PASSWORD': '123456',
|
||||
'HOST': '127.0.0.1',
|
||||
'PORT': '3306',
|
||||
'OPTIONS': {
|
||||
"init_command": "SET foreign_key_checks = 0;",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/4.1/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/4.1/topics/i18n/
|
||||
|
||||
|
||||
LANGUAGE_CODE = 'zh-hans'
|
||||
|
||||
# 时区
|
||||
TIME_ZONE = 'Asia/Shanghai'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = False
|
||||
|
||||
# 日期时间格式
|
||||
DATE_FORMAT = 'Y-m-d'
|
||||
DATETIME_FORMAT = 'Y-m-d H:i:s'
|
||||
|
||||
# 上传文件路径
|
||||
# 并在urls.py配置+static
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'upload/')
|
||||
MEDIA_URL = '/upload/'
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/4.1/howto/static-files/
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
# 跨域配置
|
||||
CORS_ALLOW_CREDENTIALS = True
|
||||
CORS_ALLOW_ALL_ORIGINS = True
|
||||
CORS_ALLOW_HEADERS = '*'
|
@ -0,0 +1,25 @@
|
||||
"""server URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/4.1/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'))
|
||||
"""
|
||||
from django.conf.urls.static import static
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
|
||||
from server import settings
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('myapp/', include('myapp.urls')),
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
@ -0,0 +1,16 @@
|
||||
"""
|
||||
WSGI config for server 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/4.1/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
|
||||
|
||||
application = get_wsgi_application()
|
After Width: | Height: | Size: 784 KiB |
After Width: | Height: | Size: 784 KiB |
After Width: | Height: | Size: 901 B |
After Width: | Height: | Size: 784 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 77 KiB |
After Width: | Height: | Size: 388 B |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 218 KiB |
After Width: | Height: | Size: 213 KiB |
After Width: | Height: | Size: 784 KiB |
After Width: | Height: | Size: 784 KiB |
After Width: | Height: | Size: 901 B |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 388 B |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 784 KiB |
After Width: | Height: | Size: 901 B |
After Width: | Height: | Size: 784 KiB |
After Width: | Height: | Size: 784 KiB |
After Width: | Height: | Size: 784 KiB |
After Width: | Height: | Size: 784 KiB |
After Width: | Height: | Size: 901 B |
After Width: | Height: | Size: 7.4 KiB |
After Width: | Height: | Size: 901 B |
After Width: | Height: | Size: 7.4 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 784 KiB |
After Width: | Height: | Size: 784 KiB |
After Width: | Height: | Size: 784 KiB |
After Width: | Height: | Size: 234 KiB |
After Width: | Height: | Size: 213 KiB |
After Width: | Height: | Size: 292 KiB |
After Width: | Height: | Size: 208 KiB |