合并所有表 3.0 -yh

master
you hang 5 months ago committed by youahng
parent 8483062aff
commit c6299aad1d
  1. 207
      sql/teaching_db.sql
  2. 66
      src/main/java/com/teaching/backend/controller/WordController.java

@ -11,7 +11,7 @@
Target Server Version : 80037
File Encoding : 65001
Date: 11/06/2024 17:38:31
Date: 12/06/2024 15:14:04
*/
SET NAMES utf8mb4;
@ -365,25 +365,200 @@ CREATE TABLE `se_resource_thumb` (
INSERT INTO `se_resource_thumb` VALUES ('1796366535710904322', '2', '1', '1');
-- ----------------------------
-- Table structure for user
-- Table structure for ums_admin
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
`userAccount` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '账号',
`userPassword` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '密码',
`userName` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '用户昵称',
`userAvatar` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '用户头像',
`userRole` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'user' COMMENT '用户角色:user/admin/ban',
`createTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updateTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`isDelete` tinyint NOT NULL DEFAULT 0 COMMENT '是否删除',
DROP TABLE IF EXISTS `ums_admin`;
CREATE TABLE `ums_admin` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
`username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '用户名',
`password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '密码',
`phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '手机号',
`nick_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '昵称',
`icon` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '头像',
`create_time` datetime NULL DEFAULT NULL COMMENT '注册时间',
`status` int NULL DEFAULT 1 COMMENT '帐号启用状态:0->禁用;1->启用',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1793257199111405570 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户' ROW_FORMAT = DYNAMIC;
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of user
-- Records of ums_admin
-- ----------------------------
INSERT INTO `ums_admin` VALUES (1, 'xiao1111', '', '', '', '1111', '2024-06-03 13:30:29', 0);
INSERT INTO `ums_admin` VALUES (2, '123', '$2a$10$ACn80kN2ZEREGH3yOce9mui/KoWQllCHjNVXzXzrTI3gKJi/LB/YK', '123456789', '', '', '2024-06-05 23:23:45', 1);
INSERT INTO `ums_admin` VALUES (3, 'youhang', '$2a$10$TYJcMWBdDmmYfV/Kxi771ee7krjYJCLzI8O6MyjCofty9Y0OPLEna', '13547534472', 'yy', '', '2024-06-12 15:09:10', 1);
-- ----------------------------
-- Table structure for ums_admin_role_relation
-- ----------------------------
DROP TABLE IF EXISTS `ums_admin_role_relation`;
CREATE TABLE `ums_admin_role_relation` (
`id` int NOT NULL AUTO_INCREMENT,
`admin_id` int NULL DEFAULT NULL,
`role_id` int NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of ums_admin_role_relation
-- ----------------------------
INSERT INTO `ums_admin_role_relation` VALUES (1, 1, 2);
-- ----------------------------
-- Table structure for ums_menu
-- ----------------------------
DROP TABLE IF EXISTS `ums_menu`;
CREATE TABLE `ums_menu` (
`id` int NOT NULL AUTO_INCREMENT,
`parent_id` int NULL DEFAULT NULL COMMENT '父级ID',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '菜单名称',
`level` int NULL DEFAULT NULL COMMENT '菜单级数',
`sort` int NULL DEFAULT NULL COMMENT '菜单排序',
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '前端名称',
`icon` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '前端图标',
`hidden` int NULL DEFAULT NULL COMMENT '前端隐藏',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of ums_menu
-- ----------------------------
-- ----------------------------
-- Table structure for ums_resource
-- ----------------------------
DROP TABLE IF EXISTS `ums_resource`;
CREATE TABLE `ums_resource` (
`id` int NOT NULL AUTO_INCREMENT,
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '资源名称',
`url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '资源URL',
`description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '描述',
`category_id` int NULL DEFAULT NULL COMMENT '资源分类ID',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of ums_resource
-- ----------------------------
INSERT INTO `ums_resource` VALUES (1, '2024-06-04 09:56:19', '首页', '/home/advertise/**', NULL, 1);
-- ----------------------------
-- Table structure for ums_resource_category
-- ----------------------------
DROP TABLE IF EXISTS `ums_resource_category`;
CREATE TABLE `ums_resource_category` (
`id` int NOT NULL AUTO_INCREMENT,
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '分类名称',
`sort` int NULL DEFAULT NULL COMMENT '排序',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of ums_resource_category
-- ----------------------------
INSERT INTO `ums_resource_category` VALUES (1, '2024-06-04 09:57:23', '首页模块', 0);
-- ----------------------------
-- Table structure for ums_role
-- ----------------------------
DROP TABLE IF EXISTS `ums_role`;
CREATE TABLE `ums_role` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '名称',
`description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '描述',
`admin_count` int NULL DEFAULT NULL COMMENT '后台用户数量',
`create_time` datetime NOT NULL COMMENT '创建时间',
`status` int NULL DEFAULT 1 COMMENT '启用状态:0->禁用;1->启用',
`sort` int NULL DEFAULT 0,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of ums_role
-- ----------------------------
INSERT INTO `ums_role` VALUES (1, '老师', '能查看自己和所有学生的信息', 0, '2024-06-04 09:59:47', 1, 0);
INSERT INTO `ums_role` VALUES (2, '学生', '只能查看自己信息', 0, '2024-06-04 10:02:15', 1, 0);
-- ----------------------------
-- Table structure for ums_role_menu_relation
-- ----------------------------
DROP TABLE IF EXISTS `ums_role_menu_relation`;
CREATE TABLE `ums_role_menu_relation` (
`id` int NOT NULL AUTO_INCREMENT,
`role_id` int NULL DEFAULT NULL COMMENT '角色ID',
`menu_id` int NULL DEFAULT NULL COMMENT '菜单ID',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of ums_role_menu_relation
-- ----------------------------
-- ----------------------------
-- Table structure for ums_role_resource_relation
-- ----------------------------
DROP TABLE IF EXISTS `ums_role_resource_relation`;
CREATE TABLE `ums_role_resource_relation` (
`id` int NOT NULL AUTO_INCREMENT,
`role_id` int NULL DEFAULT NULL COMMENT '角色ID',
`resource_id` int NULL DEFAULT NULL COMMENT '资源ID',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of ums_role_resource_relation
-- ----------------------------
INSERT INTO `ums_role_resource_relation` VALUES (1, 1, 1);
INSERT INTO `ums_role_resource_relation` VALUES (2, 2, 1);
-- ----------------------------
-- Table structure for ums_student
-- ----------------------------
DROP TABLE IF EXISTS `ums_student`;
CREATE TABLE `ums_student` (
`id` int NOT NULL,
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '姓名',
`sex` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '性别',
`nationality` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '民族',
`number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '学号',
`birthday` datetime NULL DEFAULT NULL COMMENT '生日',
`phone` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '手机号',
`faculty` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '院系',
`major` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '专业',
`year` date NULL DEFAULT NULL COMMENT '入学年份',
`class` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '班级',
`user_id` int NULL DEFAULT NULL COMMENT 'user_id',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of ums_student
-- ----------------------------
-- ----------------------------
-- Table structure for ums_teacher
-- ----------------------------
DROP TABLE IF EXISTS `ums_teacher`;
CREATE TABLE `ums_teacher` (
`id` int NOT NULL,
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '姓名',
`sex` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '性别',
`nationality` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '民族',
`profession` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '专业',
`education` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '学历',
`degree` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '学位',
`professional_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '职称',
`emergency_contact` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '手机号',
`join_work_time` datetime NULL DEFAULT NULL COMMENT '参加工作时间',
`political_status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '政治面貌',
`user_id` int NULL DEFAULT NULL COMMENT 'user_id',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of ums_teacher
-- ----------------------------
INSERT INTO `user` VALUES (1793257199111405569, 'youhang', '84fccf8fe96cab775b23698a9c9b7eaa', '游航', NULL, 'admin', '2024-05-22 20:26:48', '2024-05-22 20:27:53', 0);
SET FOREIGN_KEY_CHECKS = 1;

@ -1,66 +0,0 @@
package com.teaching.backend.controller;
import com.teaching.backend.utils.WordUtil;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.Map;
@RestController
public class WordController {
private String outputPath;
@PostMapping("/Word/get")
public ResponseEntity<byte[]> createWord(@RequestParam("outputPath") String outputPath) {
String filename = "generatedWord.docx";
System.out.println(outputPath);
WordUtil wordUtil = new WordUtil();
// 设置模板文件存放的目录
wordUtil.setBaseDir("C:\\Users\\jian\\Desktop\\123345\\");
// 设置模板文件名称
wordUtil.setTemplateFile("123.ftl");
// 设置 Word 生成的输出目录
wordUtil.setOutputDir(outputPath);
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("username1", "姜钧瀚");
String generatedFilePath = wordUtil.createWord(dataMap);
if (generatedFilePath.equals("操作失败")) {
System.out.println("操作失败");
return ResponseEntity.badRequest().body("操作失败".getBytes());
}
// 读取生成的 Word 文件内容
File file = new File(generatedFilePath);
byte[] fileContent;
try {
fileContent = Files.readAllBytes(file.toPath());
} catch (IOException e) {
e.printStackTrace();
return ResponseEntity.badRequest().body("文件读取失败".getBytes());
}
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
headers.setContentDispositionFormData("attachment", filename);
//返回word文件
return new ResponseEntity<>(fileContent, headers, HttpStatus.OK);
}
}
Loading…
Cancel
Save