From 90fbee7b081d4c970265850781693481eb797d4b Mon Sep 17 00:00:00 2001 From: wb-chenhaohao Date: Sun, 21 Aug 2022 02:36:25 +0800 Subject: [PATCH 1/3] =?UTF-8?q?prod=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-prod.yml | 2 +- source/xzs/xzs-sql-v3.9.0/xzs-mysql.sql | 289 +++++++++ source/xzs/xzs-sql-v3.9.0/xzs-postgresql.sql | 584 ++++++++++++++++++ 3 files changed, 874 insertions(+), 1 deletion(-) create mode 100644 source/xzs/xzs-sql-v3.9.0/xzs-mysql.sql create mode 100644 source/xzs/xzs-sql-v3.9.0/xzs-postgresql.sql diff --git a/source/xzs/src/main/resources/application-prod.yml b/source/xzs/src/main/resources/application-prod.yml index 1f9d6784..211112b5 100644 --- a/source/xzs/src/main/resources/application-prod.yml +++ b/source/xzs/src/main/resources/application-prod.yml @@ -5,5 +5,5 @@ spring: datasource: url: jdbc:mysql://localhost:3306/xzs?useSSL=false&useUnicode=true&serverTimezone=Asia/Shanghai&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&allowMultiQueries=true username: root - password: 123456 + password: sxgs@xzs driver-class-name: com.mysql.cj.jdbc.Driver diff --git a/source/xzs/xzs-sql-v3.9.0/xzs-mysql.sql b/source/xzs/xzs-sql-v3.9.0/xzs-mysql.sql new file mode 100644 index 00000000..ac9c8886 --- /dev/null +++ b/source/xzs/xzs-sql-v3.9.0/xzs-mysql.sql @@ -0,0 +1,289 @@ +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; +use xzs; +-- ---------------------------- +-- Table structure for t_exam_paper +-- ---------------------------- +DROP TABLE IF EXISTS `t_exam_paper`; +CREATE TABLE `t_exam_paper` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `subject_id` int NULL DEFAULT NULL, + `paper_type` int NULL DEFAULT NULL, + `grade_level` int NULL DEFAULT NULL, + `score` int NULL DEFAULT NULL, + `question_count` int NULL DEFAULT NULL, + `suggest_time` int NULL DEFAULT NULL, + `limit_start_time` datetime NULL DEFAULT NULL, + `limit_end_time` datetime NULL DEFAULT NULL, + `frame_text_content_id` int NULL DEFAULT NULL, + `create_user` int NULL DEFAULT NULL, + `create_time` datetime NULL DEFAULT NULL, + `deleted` bit(1) NULL DEFAULT NULL, + `task_exam_id` int NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of t_exam_paper +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_exam_paper_answer +-- ---------------------------- +DROP TABLE IF EXISTS `t_exam_paper_answer`; +CREATE TABLE `t_exam_paper_answer` ( + `id` int NOT NULL AUTO_INCREMENT, + `exam_paper_id` int NULL DEFAULT NULL, + `paper_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `paper_type` int NULL DEFAULT NULL, + `subject_id` int NULL DEFAULT NULL, + `system_score` int NULL DEFAULT NULL, + `user_score` int NULL DEFAULT NULL, + `paper_score` int NULL DEFAULT NULL, + `question_correct` int NULL DEFAULT NULL, + `question_count` int NULL DEFAULT NULL, + `do_time` int NULL DEFAULT NULL, + `status` int NULL DEFAULT NULL, + `create_user` int NULL DEFAULT NULL, + `create_time` datetime NULL DEFAULT NULL, + `task_exam_id` int NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of t_exam_paper_answer +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_exam_paper_question_customer_answer +-- ---------------------------- +DROP TABLE IF EXISTS `t_exam_paper_question_customer_answer`; +CREATE TABLE `t_exam_paper_question_customer_answer` ( + `id` int NOT NULL AUTO_INCREMENT, + `question_id` int NULL DEFAULT NULL, + `exam_paper_id` int NULL DEFAULT NULL, + `exam_paper_answer_id` int NULL DEFAULT NULL, + `question_type` int NULL DEFAULT NULL, + `subject_id` int NULL DEFAULT NULL, + `customer_score` int NULL DEFAULT NULL, + `question_score` int NULL DEFAULT NULL, + `question_text_content_id` int NULL DEFAULT NULL, + `answer` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `text_content_id` int NULL DEFAULT NULL, + `do_right` bit(1) NULL DEFAULT NULL, + `create_user` int NULL DEFAULT NULL, + `create_time` datetime NULL DEFAULT NULL, + `item_order` int NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of t_exam_paper_question_customer_answer +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_message +-- ---------------------------- +DROP TABLE IF EXISTS `t_message`; +CREATE TABLE `t_message` ( + `id` int NOT NULL AUTO_INCREMENT, + `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `content` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `create_time` datetime NULL DEFAULT NULL, + `send_user_id` int NULL DEFAULT NULL, + `send_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `send_real_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `receive_user_count` int NULL DEFAULT NULL, + `read_count` int NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of t_message +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_message_user +-- ---------------------------- +DROP TABLE IF EXISTS `t_message_user`; +CREATE TABLE `t_message_user` ( + `id` int NOT NULL AUTO_INCREMENT, + `message_id` int NULL DEFAULT NULL, + `receive_user_id` int NULL DEFAULT NULL, + `receive_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `receive_real_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `readed` bit(1) NULL DEFAULT NULL, + `create_time` datetime NULL DEFAULT NULL, + `read_time` datetime NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of t_message_user +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_question +-- ---------------------------- +DROP TABLE IF EXISTS `t_question`; +CREATE TABLE `t_question` ( + `id` int NOT NULL AUTO_INCREMENT, + `question_type` int NULL DEFAULT NULL, + `subject_id` int NULL DEFAULT NULL, + `score` int NULL DEFAULT NULL, + `grade_level` int NULL DEFAULT NULL, + `difficult` int NULL DEFAULT NULL, + `correct` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL, + `info_text_content_id` int NULL DEFAULT NULL, + `create_user` int NULL DEFAULT NULL, + `status` int NULL DEFAULT NULL, + `create_time` datetime NULL DEFAULT NULL, + `deleted` bit(1) NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of t_question +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_subject +-- ---------------------------- +DROP TABLE IF EXISTS `t_subject`; +CREATE TABLE `t_subject` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `level` int NULL DEFAULT NULL, + `level_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `item_order` int NULL DEFAULT NULL, + `deleted` bit(1) NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of t_subject +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_task_exam +-- ---------------------------- +DROP TABLE IF EXISTS `t_task_exam`; +CREATE TABLE `t_task_exam` ( + `id` int NOT NULL AUTO_INCREMENT, + `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `grade_level` int NULL DEFAULT NULL, + `frame_text_content_id` int NULL DEFAULT NULL, + `create_user` int NULL DEFAULT NULL, + `create_time` datetime NULL DEFAULT NULL, + `deleted` bit(1) NULL DEFAULT NULL, + `create_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of t_task_exam +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_task_exam_customer_answer +-- ---------------------------- +DROP TABLE IF EXISTS `t_task_exam_customer_answer`; +CREATE TABLE `t_task_exam_customer_answer` ( + `id` int NOT NULL AUTO_INCREMENT, + `task_exam_id` int NULL DEFAULT NULL, + `create_user` int NULL DEFAULT NULL, + `create_time` datetime NULL DEFAULT NULL, + `text_content_id` int NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of t_task_exam_customer_answer +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_text_content +-- ---------------------------- +DROP TABLE IF EXISTS `t_text_content`; +CREATE TABLE `t_text_content` ( + `id` int NOT NULL AUTO_INCREMENT, + `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL, + `create_time` datetime NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of t_text_content +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_user +-- ---------------------------- +DROP TABLE IF EXISTS `t_user`; +CREATE TABLE `t_user` ( + `id` int NOT NULL AUTO_INCREMENT, + `user_uuid` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `real_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `age` int NULL DEFAULT NULL, + `sex` int NULL DEFAULT NULL, + `birth_day` datetime NULL DEFAULT NULL, + `user_level` int NULL DEFAULT NULL, + `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `role` int NULL DEFAULT NULL, + `status` int NULL DEFAULT NULL, + `image_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `create_time` datetime NULL DEFAULT NULL, + `modify_time` datetime NULL DEFAULT NULL, + `last_active_time` datetime NULL DEFAULT NULL, + `deleted` bit(1) NULL DEFAULT NULL, + `wx_open_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of t_user +-- ---------------------------- +INSERT INTO `t_user` VALUES (1, 'd2d29da2-dcb3-4013-b874-727626236f47', 'student', 'D1AGFL+Gx37t0NPG4d6biYP5Z31cNbwhK5w1lUeiHB2zagqbk8efYfSjYoh1Z/j1dkiRjHU+b0EpwzCh8IGsksJjzD65ci5LsnodQVf4Uj6D3pwoscXGqmkjjpzvSJbx42swwNTA+QoDU8YLo7JhtbUK2X0qCjFGpd+8eJ5BGvk=', '学生', 18, 1, '2019-09-01 16:00:00', 1, '19171171610', 1, 1, 'https://www.mindskip.net:9008/image/ba607a75-83ba-4530-8e23-660b72dc4953/头像.jpg', '2019-09-07 18:55:02', '2020-02-04 08:26:54', NULL, b'0', NULL); +INSERT INTO `t_user` VALUES (2, '52045f5f-a13f-4ccc-93dd-f7ee8270ad4c', 'admin', 'D1AGFL+Gx37t0NPG4d6biYP5Z31cNbwhK5w1lUeiHB2zagqbk8efYfSjYoh1Z/j1dkiRjHU+b0EpwzCh8IGsksJjzD65ci5LsnodQVf4Uj6D3pwoscXGqmkjjpzvSJbx42swwNTA+QoDU8YLo7JhtbUK2X0qCjFGpd+8eJ5BGvk=', '管理员', 30, 1, '2019-09-07 18:56:07', NULL, NULL, 3, 1, NULL, '2019-09-07 18:56:21', NULL, NULL, b'0', NULL); + +-- ---------------------------- +-- Table structure for t_user_event_log +-- ---------------------------- +DROP TABLE IF EXISTS `t_user_event_log`; +CREATE TABLE `t_user_event_log` ( + `id` int NOT NULL AUTO_INCREMENT, + `user_id` int NULL DEFAULT NULL, + `user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `real_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL, + `create_time` datetime NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of t_user_event_log +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_user_token +-- ---------------------------- +DROP TABLE IF EXISTS `t_user_token`; +CREATE TABLE `t_user_token` ( + `id` int NOT NULL AUTO_INCREMENT, + `token` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `user_id` int NULL DEFAULT NULL, + `wx_open_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `create_time` datetime NULL DEFAULT NULL, + `end_time` datetime NULL DEFAULT NULL, + `user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT; + +-- ---------------------------- +-- Records of t_user_token +-- ---------------------------- + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/source/xzs/xzs-sql-v3.9.0/xzs-postgresql.sql b/source/xzs/xzs-sql-v3.9.0/xzs-postgresql.sql new file mode 100644 index 00000000..3a6c4214 --- /dev/null +++ b/source/xzs/xzs-sql-v3.9.0/xzs-postgresql.sql @@ -0,0 +1,584 @@ +-- ---------------------------- +-- Sequence structure for t_exam_paper_answer_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."t_exam_paper_answer_id_seq"; +CREATE SEQUENCE "public"."t_exam_paper_answer_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 2147483647 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for t_exam_paper_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."t_exam_paper_id_seq"; +CREATE SEQUENCE "public"."t_exam_paper_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 2147483647 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for t_exam_paper_question_customer_answer_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."t_exam_paper_question_customer_answer_id_seq"; +CREATE SEQUENCE "public"."t_exam_paper_question_customer_answer_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 2147483647 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for t_message_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."t_message_id_seq"; +CREATE SEQUENCE "public"."t_message_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 2147483647 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for t_message_user_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."t_message_user_id_seq"; +CREATE SEQUENCE "public"."t_message_user_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 2147483647 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for t_question_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."t_question_id_seq"; +CREATE SEQUENCE "public"."t_question_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 2147483647 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for t_subject_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."t_subject_id_seq"; +CREATE SEQUENCE "public"."t_subject_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 2147483647 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for t_task_exam_customer_answer_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."t_task_exam_customer_answer_id_seq"; +CREATE SEQUENCE "public"."t_task_exam_customer_answer_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 2147483647 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for t_task_exam_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."t_task_exam_id_seq"; +CREATE SEQUENCE "public"."t_task_exam_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 2147483647 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for t_text_content_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."t_text_content_id_seq"; +CREATE SEQUENCE "public"."t_text_content_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 2147483647 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for t_user_event_log_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."t_user_event_log_id_seq"; +CREATE SEQUENCE "public"."t_user_event_log_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 2147483647 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for t_user_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."t_user_id_seq"; +CREATE SEQUENCE "public"."t_user_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 2147483647 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for t_user_token_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."t_user_token_id_seq"; +CREATE SEQUENCE "public"."t_user_token_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 2147483647 +START 1 +CACHE 1; + +-- ---------------------------- +-- Table structure for t_exam_paper +-- ---------------------------- +DROP TABLE IF EXISTS "public"."t_exam_paper"; +CREATE TABLE "public"."t_exam_paper" ( + "id" int4 NOT NULL DEFAULT nextval('t_exam_paper_id_seq'::regclass), + "name" varchar(255) COLLATE "pg_catalog"."default", + "subject_id" int4, + "paper_type" int4, + "grade_level" int4, + "score" int4, + "question_count" int4, + "suggest_time" int4, + "limit_start_time" timestamp(6), + "limit_end_time" timestamp(6), + "frame_text_content_id" int4, + "create_user" int4, + "create_time" timestamp(6), + "deleted" bool, + "task_exam_id" int4 +) +; + +-- ---------------------------- +-- Records of t_exam_paper +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_exam_paper_answer +-- ---------------------------- +DROP TABLE IF EXISTS "public"."t_exam_paper_answer"; +CREATE TABLE "public"."t_exam_paper_answer" ( + "id" int4 NOT NULL DEFAULT nextval('t_exam_paper_answer_id_seq'::regclass), + "exam_paper_id" int4, + "paper_name" varchar(255) COLLATE "pg_catalog"."default", + "paper_type" int4, + "subject_id" int4, + "system_score" int4, + "user_score" int4, + "paper_score" int4, + "question_correct" int4, + "question_count" int4, + "do_time" int4, + "status" int4, + "create_user" int4, + "create_time" timestamp(6), + "task_exam_id" int4 +) +; + +-- ---------------------------- +-- Records of t_exam_paper_answer +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_exam_paper_question_customer_answer +-- ---------------------------- +DROP TABLE IF EXISTS "public"."t_exam_paper_question_customer_answer"; +CREATE TABLE "public"."t_exam_paper_question_customer_answer" ( + "id" int4 NOT NULL DEFAULT nextval('t_exam_paper_question_customer_answer_id_seq'::regclass), + "question_id" int4, + "exam_paper_id" int4, + "exam_paper_answer_id" int4, + "question_type" int4, + "subject_id" int4, + "customer_score" int4, + "question_score" int4, + "question_text_content_id" int4, + "answer" varchar(255) COLLATE "pg_catalog"."default", + "text_content_id" int4, + "do_right" bool, + "create_user" int4, + "create_time" timestamp(6), + "item_order" int4 +) +; + +-- ---------------------------- +-- Records of t_exam_paper_question_customer_answer +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_message +-- ---------------------------- +DROP TABLE IF EXISTS "public"."t_message"; +CREATE TABLE "public"."t_message" ( + "id" int4 NOT NULL DEFAULT nextval('t_message_id_seq'::regclass), + "title" varchar(255) COLLATE "pg_catalog"."default", + "content" varchar(500) COLLATE "pg_catalog"."default", + "send_user_id" int4, + "send_user_name" varchar(255) COLLATE "pg_catalog"."default", + "send_real_name" varchar(255) COLLATE "pg_catalog"."default", + "read_count" int4, + "receive_user_count" int4, + "create_time" timestamp(6) +) +; + +-- ---------------------------- +-- Records of t_message +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_message_user +-- ---------------------------- +DROP TABLE IF EXISTS "public"."t_message_user"; +CREATE TABLE "public"."t_message_user" ( + "id" int4 NOT NULL DEFAULT nextval('t_message_user_id_seq'::regclass), + "message_id" int4, + "receive_user_id" int4, + "receive_user_name" varchar(255) COLLATE "pg_catalog"."default", + "receive_real_name" varchar(255) COLLATE "pg_catalog"."default", + "readed" bool, + "read_time" timestamp(6), + "create_time" timestamp(6) +) +; + +-- ---------------------------- +-- Records of t_message_user +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_question +-- ---------------------------- +DROP TABLE IF EXISTS "public"."t_question"; +CREATE TABLE "public"."t_question" ( + "id" int4 NOT NULL DEFAULT nextval('t_question_id_seq'::regclass), + "question_type" int4, + "subject_id" int4, + "score" int4, + "grade_level" int4, + "difficult" int4, + "correct" text COLLATE "pg_catalog"."default", + "info_text_content_id" int4, + "create_user" int4, + "status" int4, + "create_time" timestamp(6), + "deleted" bool +) +; + +-- ---------------------------- +-- Records of t_question +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_subject +-- ---------------------------- +DROP TABLE IF EXISTS "public"."t_subject"; +CREATE TABLE "public"."t_subject" ( + "id" int4 NOT NULL DEFAULT nextval('t_subject_id_seq'::regclass), + "name" varchar(255) COLLATE "pg_catalog"."default", + "level" int4, + "level_name" varchar(255) COLLATE "pg_catalog"."default", + "item_order" int4, + "deleted" bool +) +; + + +-- ---------------------------- +-- Records of t_subject +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_task_exam +-- ---------------------------- +DROP TABLE IF EXISTS "public"."t_task_exam"; +CREATE TABLE "public"."t_task_exam" ( + "id" int4 NOT NULL DEFAULT nextval('t_task_exam_id_seq'::regclass), + "title" varchar(255) COLLATE "pg_catalog"."default", + "grade_level" int4, + "frame_text_content_id" int4, + "create_user" int4, + "create_user_name" varchar(255) COLLATE "pg_catalog"."default", + "create_time" timestamp(6), + "deleted" bool +) +; + +-- ---------------------------- +-- Records of t_task_exam +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_task_exam_customer_answer +-- ---------------------------- +DROP TABLE IF EXISTS "public"."t_task_exam_customer_answer"; +CREATE TABLE "public"."t_task_exam_customer_answer" ( + "id" int4 NOT NULL DEFAULT nextval('t_task_exam_customer_answer_id_seq'::regclass), + "task_exam_id" int4, + "text_content_id" int4, + "create_user" int4, + "create_time" timestamp(6) +) +; + +-- ---------------------------- +-- Records of t_task_exam_customer_answer +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_text_content +-- ---------------------------- +DROP TABLE IF EXISTS "public"."t_text_content"; +CREATE TABLE "public"."t_text_content" ( + "id" int4 NOT NULL DEFAULT nextval('t_text_content_id_seq'::regclass), + "content" text COLLATE "pg_catalog"."default", + "create_time" timestamp(6) +) +; + +-- ---------------------------- +-- Records of t_text_content +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_user +-- ---------------------------- +DROP TABLE IF EXISTS "public"."t_user"; +CREATE TABLE "public"."t_user" ( + "id" int4 NOT NULL DEFAULT nextval('t_user_id_seq'::regclass), + "user_uuid" uuid, + "user_name" varchar(255) COLLATE "pg_catalog"."default", + "password" varchar(255) COLLATE "pg_catalog"."default", + "real_name" varchar(255) COLLATE "pg_catalog"."default", + "age" int4, + "sex" int4, + "birth_day" timestamp(6), + "user_level" int4, + "phone" varchar(255) COLLATE "pg_catalog"."default", + "role" int4, + "status" int4, + "image_path" varchar(255) COLLATE "pg_catalog"."default", + "create_time" timestamp(6), + "modify_time" timestamp(6), + "last_active_time" timestamp(6), + "deleted" bool, + "wx_open_id" varchar COLLATE "pg_catalog"."default" +) +; + +-- ---------------------------- +-- Records of t_user +-- ---------------------------- +INSERT INTO "public"."t_user" VALUES (2, '55bad52c-cdf7-4321-87b8-e37d958b24cf', 'admin', 'D1AGFL+Gx37t0NPG4d6biYP5Z31cNbwhK5w1lUeiHB2zagqbk8efYfSjYoh1Z/j1dkiRjHU+b0EpwzCh8IGsksJjzD65ci5LsnodQVf4Uj6D3pwoscXGqmkjjpzvSJbx42swwNTA+QoDU8YLo7JhtbUK2X0qCjFGpd+8eJ5BGvk=', '管理员', 18, 1, '2019-09-02 00:00:00', 13, '1561651651616156', 3, 1, NULL, '2019-07-23 07:17:16.923', '2020-02-08 10:52:42.234', '2019-07-23 07:17:16.923', 'f', NULL); +INSERT INTO "public"."t_user" VALUES (1, 'b41eaab1-926a-4824-94e8-da9259986ab6', 'student', 'RA6atJcbedAQUA/3jTcC85RuVuedZEgkeWUCiagtwhz6SjEKerC4IvFQe1OGSvbk+tPZGfkInRrmipPgHU6tzcpaQfdJkV9cXSGoxyldrWSFxblfpGGDxVisQrtrH7N1AEyi6u3h4iYrwkf4sPV8xoU8ZpOhlKmLEjDEq/an6rQ=', '学生', 16, 2, '1979-06-05 00:00:00', 1, '19171171610', 1, 1, 'https://www.mindskip.net:9008/image/ba607a75-83ba-4530-8e23-660b72dc4953/头像.jpg', '2019-07-23 05:02:29.027', '2020-02-05 09:36:52.138', '2019-07-23 05:02:29.027', 'f', NULL); + +-- ---------------------------- +-- Table structure for t_user_event_log +-- ---------------------------- +DROP TABLE IF EXISTS "public"."t_user_event_log"; +CREATE TABLE "public"."t_user_event_log" ( + "id" int4 NOT NULL DEFAULT nextval('t_user_event_log_id_seq'::regclass), + "user_id" int4, + "user_name" varchar(255) COLLATE "pg_catalog"."default", + "real_name" varchar(255) COLLATE "pg_catalog"."default", + "content" text COLLATE "pg_catalog"."default", + "create_time" timestamp(6) +) +; + +-- ---------------------------- +-- Records of t_user_event_log +-- ---------------------------- + +-- ---------------------------- +-- Table structure for t_user_token +-- ---------------------------- +DROP TABLE IF EXISTS "public"."t_user_token"; +CREATE TABLE "public"."t_user_token" ( + "id" int4 NOT NULL DEFAULT nextval('t_user_token_id_seq'::regclass), + "token" uuid, + "user_id" int4, + "wx_open_id" varchar(255) COLLATE "pg_catalog"."default", + "create_time" timestamp(6), + "end_time" timestamp(6), + "user_name" varchar(255) COLLATE "pg_catalog"."default" +) +; + +-- ---------------------------- +-- Records of t_user_token +-- ---------------------------- + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."t_exam_paper_answer_id_seq" +OWNED BY "public"."t_exam_paper_answer"."id"; +SELECT setval('"public"."t_exam_paper_answer_id_seq"', 1, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."t_exam_paper_id_seq" +OWNED BY "public"."t_exam_paper"."id"; +SELECT setval('"public"."t_exam_paper_id_seq"', 1, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."t_exam_paper_question_customer_answer_id_seq" +OWNED BY "public"."t_exam_paper_question_customer_answer"."id"; +SELECT setval('"public"."t_exam_paper_question_customer_answer_id_seq"', 1, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."t_message_id_seq" +OWNED BY "public"."t_message"."id"; +SELECT setval('"public"."t_message_id_seq"', 1, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."t_message_user_id_seq" +OWNED BY "public"."t_message_user"."id"; +SELECT setval('"public"."t_message_user_id_seq"', 1, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."t_question_id_seq" +OWNED BY "public"."t_question"."id"; +SELECT setval('"public"."t_question_id_seq"', 1, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."t_subject_id_seq" +OWNED BY "public"."t_subject"."id"; +SELECT setval('"public"."t_subject_id_seq"', 1, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."t_task_exam_customer_answer_id_seq" +OWNED BY "public"."t_task_exam_customer_answer"."id"; +SELECT setval('"public"."t_task_exam_customer_answer_id_seq"', 1, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."t_task_exam_id_seq" +OWNED BY "public"."t_task_exam"."id"; +SELECT setval('"public"."t_task_exam_id_seq"', 1, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."t_text_content_id_seq" +OWNED BY "public"."t_text_content"."id"; +SELECT setval('"public"."t_text_content_id_seq"', 1, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."t_user_event_log_id_seq" +OWNED BY "public"."t_user_event_log"."id"; +SELECT setval('"public"."t_user_event_log_id_seq"', 1, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."t_user_id_seq" +OWNED BY "public"."t_user"."id"; +SELECT setval('"public"."t_user_id_seq"', 3, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."t_user_token_id_seq" +OWNED BY "public"."t_user_token"."id"; +SELECT setval('"public"."t_user_token_id_seq"', 1, true); + +-- ---------------------------- +-- Primary Key structure for table t_exam_paper +-- ---------------------------- +ALTER TABLE "public"."t_exam_paper" ADD CONSTRAINT "t_exam_paper_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Primary Key structure for table t_exam_paper_answer +-- ---------------------------- +ALTER TABLE "public"."t_exam_paper_answer" ADD CONSTRAINT "t_exam_paper_answer_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Primary Key structure for table t_exam_paper_question_customer_answer +-- ---------------------------- +ALTER TABLE "public"."t_exam_paper_question_customer_answer" ADD CONSTRAINT "t_exam_paper_question_customer_answer_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Primary Key structure for table t_message +-- ---------------------------- +ALTER TABLE "public"."t_message" ADD CONSTRAINT "t_message_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Primary Key structure for table t_message_user +-- ---------------------------- +ALTER TABLE "public"."t_message_user" ADD CONSTRAINT "t_message_user_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Primary Key structure for table t_question +-- ---------------------------- +ALTER TABLE "public"."t_question" ADD CONSTRAINT "t_question_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Primary Key structure for table t_subject +-- ---------------------------- +ALTER TABLE "public"."t_subject" ADD CONSTRAINT "t_subject_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Primary Key structure for table t_task_exam +-- ---------------------------- +ALTER TABLE "public"."t_task_exam" ADD CONSTRAINT "t_task_exam_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Primary Key structure for table t_task_exam_customer_answer +-- ---------------------------- +ALTER TABLE "public"."t_task_exam_customer_answer" ADD CONSTRAINT "t_task_exam_customer_answer_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Primary Key structure for table t_text_content +-- ---------------------------- +ALTER TABLE "public"."t_text_content" ADD CONSTRAINT "t_text_content_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Primary Key structure for table t_user +-- ---------------------------- +ALTER TABLE "public"."t_user" ADD CONSTRAINT "t_user_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Primary Key structure for table t_user_event_log +-- ---------------------------- +ALTER TABLE "public"."t_user_event_log" ADD CONSTRAINT "t_user_event_log_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Primary Key structure for table t_user_token +-- ---------------------------- +ALTER TABLE "public"."t_user_token" ADD CONSTRAINT "t_user_token_pkey" PRIMARY KEY ("id"); -- Gitee From ca351334c88e33720c32b40915c70a46f1256983 Mon Sep 17 00:00:00 2001 From: chh Date: Mon, 22 Aug 2022 19:11:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=9A=8F=E6=9C=BA=E5=87=BA=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/ExamPaperController.java | 9 ++ .../xzs/service/ExamPaperService.java | 3 + .../mindskip/xzs/service/QuestionService.java | 2 + .../service/impl/ExamPaperServiceImpl.java | 49 ++++++- .../xzs/service/impl/QuestionServiceImpl.java | 4 + .../exam/ExamPaperEditrandomRequestVM.java | 135 ++++++++++++++++++ 6 files changed, 198 insertions(+), 4 deletions(-) create mode 100644 source/xzs/src/main/java/com/mindskip/xzs/viewmodel/admin/exam/ExamPaperEditrandomRequestVM.java diff --git a/source/xzs/src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java b/source/xzs/src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java index 14173e7c..8e19467d 100644 --- a/source/xzs/src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java +++ b/source/xzs/src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java @@ -6,6 +6,7 @@ import com.mindskip.xzs.domain.ExamPaper; import com.mindskip.xzs.service.ExamPaperService; import com.mindskip.xzs.utility.DateTimeUtil; import com.mindskip.xzs.utility.PageInfoHelper; +import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditrandomRequestVM; import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperPageRequestVM; import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVM; import com.mindskip.xzs.viewmodel.admin.exam.ExamResponseVM; @@ -59,6 +60,14 @@ public class ExamPaperController extends BaseApiController { return RestResponse.ok(newVM); } + @RequestMapping(value = "/random", method = RequestMethod.POST) + public RestResponse random(@RequestBody @Valid ExamPaperEditrandomRequestVM model) { + ExamPaperEditRequestVM paperModel = examPaperService.randomPaper(model); + ExamPaper examPaper = examPaperService.savePaperFromVM(paperModel, getCurrentUser()); + ExamPaperEditRequestVM newVM = examPaperService.examPaperToVM(examPaper.getId()); + return RestResponse.ok(newVM); + } + @RequestMapping(value = "/select/{id}", method = RequestMethod.POST) public RestResponse select(@PathVariable Integer id) { ExamPaperEditRequestVM vm = examPaperService.examPaperToVM(id); diff --git a/source/xzs/src/main/java/com/mindskip/xzs/service/ExamPaperService.java b/source/xzs/src/main/java/com/mindskip/xzs/service/ExamPaperService.java index b815850d..098d4b2f 100644 --- a/source/xzs/src/main/java/com/mindskip/xzs/service/ExamPaperService.java +++ b/source/xzs/src/main/java/com/mindskip/xzs/service/ExamPaperService.java @@ -3,6 +3,7 @@ package com.mindskip.xzs.service; import com.mindskip.xzs.domain.ExamPaper; import com.mindskip.xzs.domain.User; import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVM; +import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditrandomRequestVM; import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperPageRequestVM; import com.mindskip.xzs.viewmodel.student.dashboard.PaperFilter; import com.mindskip.xzs.viewmodel.student.dashboard.PaperInfo; @@ -19,6 +20,8 @@ public interface ExamPaperService extends BaseService { PageInfo studentPage(ExamPaperPageVM requestVM); + ExamPaperEditRequestVM randomPaper(ExamPaperEditrandomRequestVM requestVM); + ExamPaper savePaperFromVM(ExamPaperEditRequestVM examPaperEditRequestVM, User user); ExamPaperEditRequestVM examPaperToVM(Integer id); diff --git a/source/xzs/src/main/java/com/mindskip/xzs/service/QuestionService.java b/source/xzs/src/main/java/com/mindskip/xzs/service/QuestionService.java index 50c957ec..a2f98847 100644 --- a/source/xzs/src/main/java/com/mindskip/xzs/service/QuestionService.java +++ b/source/xzs/src/main/java/com/mindskip/xzs/service/QuestionService.java @@ -11,6 +11,8 @@ public interface QuestionService extends BaseService { PageInfo page(QuestionPageRequestVM requestVM); + List list(QuestionPageRequestVM requestVM); + Question insertFullQuestion(QuestionEditRequestVM model, Integer userId); Question updateFullQuestion(QuestionEditRequestVM model); diff --git a/source/xzs/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java b/source/xzs/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java index b35f36f5..c6b7ee33 100644 --- a/source/xzs/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java +++ b/source/xzs/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java @@ -1,6 +1,5 @@ package com.mindskip.xzs.service.impl; -import com.mindskip.xzs.domain.*; import com.mindskip.xzs.domain.TextContent; import com.mindskip.xzs.domain.enums.ExamPaperTypeEnum; import com.mindskip.xzs.domain.exam.ExamPaperQuestionItemObject; @@ -18,9 +17,11 @@ import com.mindskip.xzs.utility.JsonUtil; import com.mindskip.xzs.utility.ModelMapperSingle; import com.mindskip.xzs.utility.ExamUtil; import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVM; +import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditrandomRequestVM; import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperPageRequestVM; import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperTitleItemVM; import com.mindskip.xzs.viewmodel.admin.question.QuestionEditRequestVM; +import com.mindskip.xzs.viewmodel.admin.question.QuestionPageRequestVM; import com.mindskip.xzs.viewmodel.student.dashboard.PaperFilter; import com.mindskip.xzs.viewmodel.student.dashboard.PaperInfo; import com.mindskip.xzs.viewmodel.student.exam.ExamPaperPageVM; @@ -34,9 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Arrays; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -79,6 +78,48 @@ public class ExamPaperServiceImpl extends BaseServiceImpl implements examPaperMapper.studentPage(requestVM)); } + @Override + public ExamPaperEditRequestVM randomPaper(ExamPaperEditrandomRequestVM requestVM) { + ExamPaperEditRequestVM editRequestVM = new ExamPaperEditRequestVM(); + editRequestVM.setLevel(requestVM.getLevel()); + editRequestVM.setLimitDateTime(requestVM.getLimitDateTime()); + editRequestVM.setScore(requestVM.getScore()); + editRequestVM.setName(requestVM.getName()); + editRequestVM.setPaperType(requestVM.getPaperType()); + editRequestVM.setSubjectId(requestVM.getSubjectId()); + editRequestVM.setSuggestTime(requestVM.getSuggestTime()); + + editRequestVM.setTitleItems(new ArrayList<>()); + + // 单选题 + addQuestionItem(editRequestVM, requestVM, requestVM.getRadioQuestionSum(), 1); + // 多选题 + addQuestionItem(editRequestVM, requestVM, requestVM.getMultiSelectQuestionSum(), 2); + return editRequestVM; + } + + /** + * 随机抽取题目 + * @param editRequestVM + * @param questionSum + * @param questionType 题目类型 + */ + private void addQuestionItem(ExamPaperEditRequestVM editRequestVM, ExamPaperEditrandomRequestVM requestVM, int questionSum, int questionType) { + QuestionPageRequestVM questionRequest = new QuestionPageRequestVM(); + questionRequest.setQuestionType(questionType); + questionRequest.setSubjectId(requestVM.getSubjectId()); + questionRequest.setPageSize(10000); + List questionList = questionService.list(questionRequest); + // 生成随机数 + ExamPaperTitleItemVM radioQuestionItem = new ExamPaperTitleItemVM(); + radioQuestionItem.setName("一、单选题"); + radioQuestionItem.setQuestionItems(new ArrayList<>()); + Random random = new Random(questionList.size()); + for (int i = 0; i < questionSum; i++) { + radioQuestionItem.getQuestionItems().add(questionService.getQuestionEditRequestVM(questionList.get(random.nextInt(questionList.size())))); + } + editRequestVM.getTitleItems().add(radioQuestionItem); + } @Override @Transactional diff --git a/source/xzs/src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java b/source/xzs/src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java index bfea93b5..4f6c43f2 100644 --- a/source/xzs/src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java +++ b/source/xzs/src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java @@ -52,6 +52,10 @@ public class QuestionServiceImpl extends BaseServiceImpl implements Qu ); } + @Override + public List list(QuestionPageRequestVM requestVM) { + return questionMapper.page(requestVM); + } @Override @Transactional diff --git a/source/xzs/src/main/java/com/mindskip/xzs/viewmodel/admin/exam/ExamPaperEditrandomRequestVM.java b/source/xzs/src/main/java/com/mindskip/xzs/viewmodel/admin/exam/ExamPaperEditrandomRequestVM.java new file mode 100644 index 00000000..6cf2824b --- /dev/null +++ b/source/xzs/src/main/java/com/mindskip/xzs/viewmodel/admin/exam/ExamPaperEditrandomRequestVM.java @@ -0,0 +1,135 @@ +package com.mindskip.xzs.viewmodel.admin.exam; + + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.List; + +public class ExamPaperEditrandomRequestVM { + + private Integer id; + @NotNull + private Integer level; + @NotNull + private Integer subjectId; + @NotNull + private Integer paperType; + @NotBlank + private String name; + @NotNull + private Integer suggestTime; + + private List limitDateTime; + + private String score; + + /** 单选题数量*/ + private Integer radioQuestionSum; + + /** 多选题数量*/ + private Integer multiSelectQuestionSum; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getLevel() { + return level; + } + + public void setLevel(Integer level) { + this.level = level; + } + + public Integer getSubjectId() { + return subjectId; + } + + public void setSubjectId(Integer subjectId) { + this.subjectId = subjectId; + } + + public Integer getPaperType() { + return paperType; + } + + public void setPaperType(Integer paperType) { + this.paperType = paperType; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getSuggestTime() { + return suggestTime; + } + + public void setSuggestTime(Integer suggestTime) { + this.suggestTime = suggestTime; + } + + public List getLimitDateTime() { + return limitDateTime; + } + + public void setLimitDateTime(List limitDateTime) { + this.limitDateTime = limitDateTime; + } + + public String getScore() { + return score; + } + + public void setScore(String score) { + this.score = score; + } + + /** + * get radioQuestionSum + * + * @return radioQuestionSum + */ + public Integer getRadioQuestionSum() { + return radioQuestionSum; + } + + /** + * set radioQuestionSum + * + * @param radioQuestionSum radioQuestionSum + * @return ExamPaperEditrandomRequestVM. + */ + public ExamPaperEditrandomRequestVM setRadioQuestionSum(Integer radioQuestionSum) { + this.radioQuestionSum = radioQuestionSum; + return this; + } + + /** + * get multiSelectQuestionSum + * + * @return multiSelectQuestionSum + */ + public Integer getMultiSelectQuestionSum() { + return multiSelectQuestionSum; + } + + /** + * set multiSelectQuestionSum + * + * @param multiSelectQuestionSum multiSelectQuestionSum + * @return ExamPaperEditrandomRequestVM. + */ + public ExamPaperEditrandomRequestVM setMultiSelectQuestionSum(Integer multiSelectQuestionSum) { + this.multiSelectQuestionSum = multiSelectQuestionSum; + return this; + } +} -- Gitee From 56b3a3d2ca4ee4f5e0448bfefc772fd9076bad4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=9B=E6=9E=97=E8=BF=B7=E9=9B=BE?= Date: Wed, 24 Aug 2022 16:34:25 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E9=9A=8F=E6=9C=BA=E5=8D=B7=E5=AD=90?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 丛林迷雾 --- .../xzs-admin/src/views/exam/paper/edit.vue | 86 +++++++++++++++---- .../service/impl/ExamPaperServiceImpl.java | 49 ++++++++--- .../exam/ExamPaperEditrandomRequestVM.java | 45 +++------- 3 files changed, 116 insertions(+), 64 deletions(-) diff --git a/source/vue/xzs-admin/src/views/exam/paper/edit.vue b/source/vue/xzs-admin/src/views/exam/paper/edit.vue index 91851828..3bbcda50 100644 --- a/source/vue/xzs-admin/src/views/exam/paper/edit.vue +++ b/source/vue/xzs-admin/src/views/exam/paper/edit.vue @@ -25,6 +25,22 @@ + + +
+ + + + + + + + + + +
+
+ @@ -52,7 +68,15 @@ 提交 重置 - 添加标题 + + + 添加题目 + + + 添加标题 + 随机添加 + + @@ -107,9 +131,11 @@ export default { limitDateTime: [], name: '', suggestTime: null, - titleItems: [] + titleItems: [], + questionSum: [0, 0] }, subjectFilter: null, + random: 0, formLoading: false, rules: { level: [ @@ -154,6 +180,8 @@ export default { if (id && parseInt(id) !== 0) { _this.formLoading = true examPaperApi.select(id).then(re => { + // TODO 随机生成这里简单做,结合编辑,后面处理questionSum + re.response.questionSum = [0, 0] _this.form = re.response _this.formLoading = false }) @@ -165,19 +193,34 @@ export default { this.$refs.form.validate((valid) => { if (valid) { this.formLoading = true - examPaperApi.edit(this.form).then(re => { - if (re.code === 1) { - _this.$message.success(re.message) - _this.delCurrentView(_this).then(() => { - _this.$router.push('/exam/paper/list') - }) - } else { - _this.$message.error(re.message) + if (this.random === 1) { + console.log(this.form) + examPaperApi.random(this.form).then(re => { + if (re.code === 1) { + _this.$message.success(re.message) + this.formLoading = false + } else { + _this.$message.error(re.message) + this.formLoading = false + } + }).catch(e => { + this.formLoading = false + }) + } else { + examPaperApi.edit(this.form).then(re => { + if (re.code === 1) { + _this.$message.success(re.message) + _this.delCurrentView(_this).then(() => { + _this.$router.push('/exam/paper/list') + }) + } else { + _this.$message.error(re.message) + this.formLoading = false + } + }).catch(e => { this.formLoading = false - } - }).catch(e => { - this.formLoading = false - }) + }) + } } else { return false } @@ -188,6 +231,11 @@ export default { name: '', questionItems: [] }) + this.random = 0 + }, + addRandom () { + this.random = 1 + this.form.titleItems = [] }, addQuestion (titleItem) { this.currentTitleItem = titleItem @@ -248,7 +296,8 @@ export default { limitDateTime: [], name: '', suggestTime: null, - titleItems: [] + titleItems: [], + questionSum: [0, 0] } this.form.id = lastId }, @@ -272,7 +321,10 @@ export default { .q-title { margin: 0px 5px 0px 5px; } - .q-item-content { - } } +.ks-random-subject { + padding: 8px 16px; + width: 200px; + text-align: right; +} diff --git a/source/xzs/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java b/source/xzs/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java index c6b7ee33..486a5f2d 100644 --- a/source/xzs/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java +++ b/source/xzs/src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java @@ -80,6 +80,7 @@ public class ExamPaperServiceImpl extends BaseServiceImpl implements @Override public ExamPaperEditRequestVM randomPaper(ExamPaperEditrandomRequestVM requestVM) { + ExamPaperEditRequestVM editRequestVM = new ExamPaperEditRequestVM(); editRequestVM.setLevel(requestVM.getLevel()); editRequestVM.setLimitDateTime(requestVM.getLimitDateTime()); @@ -88,37 +89,59 @@ public class ExamPaperServiceImpl extends BaseServiceImpl implements editRequestVM.setPaperType(requestVM.getPaperType()); editRequestVM.setSubjectId(requestVM.getSubjectId()); editRequestVM.setSuggestTime(requestVM.getSuggestTime()); - editRequestVM.setTitleItems(new ArrayList<>()); - // 单选题 - addQuestionItem(editRequestVM, requestVM, requestVM.getRadioQuestionSum(), 1); - // 多选题 - addQuestionItem(editRequestVM, requestVM, requestVM.getMultiSelectQuestionSum(), 2); + // 提供性能可以加线程 + ExamPaperTitleItemVM examPaperTitleItemVM; + for (QuestionTypeEnum questionType : QuestionTypeEnum.values()) { + // 单选题 + examPaperTitleItemVM = addQuestionItem(requestVM, questionType); + if (examPaperTitleItemVM == null) { + continue; + } + editRequestVM.getTitleItems().add(examPaperTitleItemVM); + } + return editRequestVM; } /** * 随机抽取题目 - * @param editRequestVM - * @param questionSum - * @param questionType 题目类型 + * + * @param requestVM + * @param questionType 题目类型 */ - private void addQuestionItem(ExamPaperEditRequestVM editRequestVM, ExamPaperEditrandomRequestVM requestVM, int questionSum, int questionType) { + private ExamPaperTitleItemVM addQuestionItem(ExamPaperEditrandomRequestVM requestVM, QuestionTypeEnum questionType) { + + if (questionType.getCode() > 2) { + // 暂时只有选择题 + return null; + } + QuestionPageRequestVM questionRequest = new QuestionPageRequestVM(); - questionRequest.setQuestionType(questionType); + questionRequest.setQuestionType(questionType.getCode()); questionRequest.setSubjectId(requestVM.getSubjectId()); questionRequest.setPageSize(10000); List questionList = questionService.list(questionRequest); - // 生成随机数 + + if (CollectionUtils.isEmpty(questionList)) { + return null; + } + ExamPaperTitleItemVM radioQuestionItem = new ExamPaperTitleItemVM(); - radioQuestionItem.setName("一、单选题"); + radioQuestionItem.setName(questionType.getSubjectNo()); radioQuestionItem.setQuestionItems(new ArrayList<>()); + // 生成随机数 Random random = new Random(questionList.size()); + + int questionSum = requestVM.getQuestionSum().get(questionType.getCode() - 1); for (int i = 0; i < questionSum; i++) { + radioQuestionItem.getQuestionItems().add(questionService.getQuestionEditRequestVM(questionList.get(random.nextInt(questionList.size())))); } - editRequestVM.getTitleItems().add(radioQuestionItem); + + return radioQuestionItem; + } @Override diff --git a/source/xzs/src/main/java/com/mindskip/xzs/viewmodel/admin/exam/ExamPaperEditrandomRequestVM.java b/source/xzs/src/main/java/com/mindskip/xzs/viewmodel/admin/exam/ExamPaperEditrandomRequestVM.java index 6cf2824b..b8bfe566 100644 --- a/source/xzs/src/main/java/com/mindskip/xzs/viewmodel/admin/exam/ExamPaperEditrandomRequestVM.java +++ b/source/xzs/src/main/java/com/mindskip/xzs/viewmodel/admin/exam/ExamPaperEditrandomRequestVM.java @@ -23,11 +23,8 @@ public class ExamPaperEditrandomRequestVM { private String score; - /** 单选题数量*/ - private Integer radioQuestionSum; - - /** 多选题数量*/ - private Integer multiSelectQuestionSum; + /** 各种题目数量*/ + private List questionSum; public Integer getId() { return id; @@ -94,42 +91,22 @@ public class ExamPaperEditrandomRequestVM { } /** - * get radioQuestionSum - * - * @return radioQuestionSum - */ - public Integer getRadioQuestionSum() { - return radioQuestionSum; - } - - /** - * set radioQuestionSum - * - * @param radioQuestionSum radioQuestionSum - * @return ExamPaperEditrandomRequestVM. - */ - public ExamPaperEditrandomRequestVM setRadioQuestionSum(Integer radioQuestionSum) { - this.radioQuestionSum = radioQuestionSum; - return this; - } - - /** - * get multiSelectQuestionSum + * get questionSum * - * @return multiSelectQuestionSum + * @return questionSum */ - public Integer getMultiSelectQuestionSum() { - return multiSelectQuestionSum; + public List getQuestionSum() { + return questionSum; } /** - * set multiSelectQuestionSum + * set questionSum * - * @param multiSelectQuestionSum multiSelectQuestionSum + * @param questionSum questionSum * @return ExamPaperEditrandomRequestVM. */ - public ExamPaperEditrandomRequestVM setMultiSelectQuestionSum(Integer multiSelectQuestionSum) { - this.multiSelectQuestionSum = multiSelectQuestionSum; + public ExamPaperEditrandomRequestVM setQuestionSum(List questionSum) { + this.questionSum = questionSum; return this; } -} +} \ No newline at end of file -- Gitee