fanxp vor 2 Jahren
Ursprung
Commit
eaf6f4bf2d

+ 2 - 2
src/main/java/com/xjrsoft/module/organization/controller/UserController.java

@@ -393,9 +393,9 @@ public class UserController {
 
     @PostMapping("/register")
     @ApiOperation(value = "家长注册")
-    public R register(@Valid @RequestBody AddUserDto dto) {
+    public R register(@Valid @RequestBody RegisterDto dto) {
         // 验证验证码
-        if (!smsCtcc.captchaVerify(dto.getMobile(), dto.getCode())) {
+        if (!smsCtcc.captchaVerify(dto.getMobile(), dto.getSmsCode())) {
             return R.error("验证码不正确!");
         }
         // 赋值家长角色

+ 1 - 1
src/main/java/com/xjrsoft/module/organization/dto/RegisterDto.java

@@ -10,5 +10,5 @@ public class RegisterDto extends AddUserDto{
 
     @ApiModelProperty(value = "验证码")
     @NotBlank(message = "验证码不能为空!")
-    private String code;
+    private String smsCode;
 }

+ 6 - 6
src/main/resources/sqlScript/init_sql.sql

@@ -843,8 +843,8 @@ create table class_time
     `create_date` date null default null COMMENT '创建时间',
     `modify_date` date null default null COMMENT '修改时间',
     primary key (`id`),
-    unique key `only`(`time_group`,`time_period`,`number`)
-) engine=innodb default charset=utf8mb4 comment '上课时间';
+    unique key `only`(`time_period`,`number`)
+) engine=innodb default charset=utf8mb4 COLLATE = utf8mb4_0900_ai_ci comment '上课时间';
 
 -- ----------------------------
 -- 课表
@@ -854,11 +854,11 @@ create table course_table
 (
     id bigint not null comment '主键编号' ,
     `base_semester_id` bigint not null COMMENT '学期ID(base_semester)',
-    teacher_id int not null default 0 comment '教师编号(用户表)',
+    teacher_id bigint not null default 0 comment '教师编号(用户表)',
     teacher_name varchar(50) not null default '' comment '教师名称',
-    course_id int not null default 0 comment '课程编号(course)',
+    course_id bigint not null default 0 comment '课程编号(course)',
     course_name varchar(200) not null default '' comment '课程名称',
-    class_id int not null default 0 comment '班级编号(class)',
+    class_id bigint not null default 0 comment '班级编号(class)',
     class_name varchar(200) not null default '' comment '班级名称',
     week int not null comment '周',
     weeks int not null comment '星期几(1-7)',
@@ -872,6 +872,6 @@ create table course_table
     `create_date` date null default null COMMENT '创建时间',
     `modify_date` date null default null COMMENT '修改时间',
     primary key (`id`)
-) engine=innodb default charset=utf8mb4 comment '课表';
+) engine=innodb default charset=utf8mb4 COLLATE = utf8mb4_0900_ai_ci comment '课表';
 
 SET FOREIGN_KEY_CHECKS = 1;

+ 192 - 0
src/test/java/com/xjrsoft/xjrsoftboot/WordTest.java

@@ -0,0 +1,192 @@
+package com.xjrsoft.xjrsoftboot;
+
+
+import org.apache.poi.hwpf.HWPFDocument;
+import org.apache.poi.hwpf.extractor.WordExtractor;
+import org.apache.poi.xwpf.usermodel.*;
+import org.junit.jupiter.api.Test;
+
+import java.io.*;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class WordTest {
+    @Test
+    public void WordTest() throws IOException {
+        InputStream is = new FileInputStream("/Users/fanxp/Downloads/2023年春期 班级总课程表.docx");
+        XWPFDocument doc = new XWPFDocument(is);
+
+        List<XWPFParagraph> paras = doc.getParagraphs(); //将得到包含段落列表
+        //获取标题
+        for (XWPFParagraph para : paras) {
+//            System.out.println(para.getText());
+
+            //获取文档中所有的表格
+            List<XWPFTable> tables = doc.getTables();
+
+            List<XWPFTableRow> rows;
+
+            List<XWPFTableCell> cells;
+
+            for (XWPFTable table : tables) {
+                rows = table.getRows();
+                for (XWPFTableRow row : rows) {
+                    //获取行对应的单元格
+                    cells = row.getTableCells();
+                    for (XWPFTableCell cell : cells) {
+                        System.out.println(cell.getText());;
+                    }
+                }
+            }
+        }
+        close(is);
+    }
+
+    /**
+
+     * 关闭输入流
+
+     * @param is
+
+     */
+
+    private void close(InputStream is) {
+        if (is != null) {
+            try {
+                is.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * 获取正文文件内容,docx方法
+     *
+     * @param path
+     * @return
+     */
+    public Map<String, String> getContentDocx(String path) {
+        Map<String, String> map = new HashMap();
+        StringBuffer content = new StringBuffer("");
+        String result = "0";  // 0表示获取正常,1表示获取异常
+        InputStream is = null;
+        try {
+            is = new FileInputStream(new File(path));
+            // 2007版本的word
+            XWPFDocument xwpf = new XWPFDocument(is);    // 2007版本,仅支持docx文件处理
+            List<XWPFParagraph> paragraphs = xwpf.getParagraphs();
+            if (paragraphs != null && paragraphs.size() > 0) {
+                for (XWPFParagraph paragraph : paragraphs) {
+                    if (!paragraph.getParagraphText().startsWith("    ")) {
+                        content.append("    ").append(paragraph.getParagraphText().trim()).append("\r\n");
+                    } else {
+                        content.append(paragraph.getParagraphText());
+                    }
+                }
+            }
+        } catch (Exception e) {
+            System.out.println("docx解析正文异常:" + e);
+            result = "1"; // 出现异常
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (IOException e) {
+                    System.out.println("" + e);
+                }
+            }
+            map.put("result", result);
+            map.put("content", content.toString());
+        }
+        return map;
+    }
+
+    /**
+     * 获取正文文件内容,doc方法
+     *
+     * @param path
+     * @return
+     */
+    public Map<String, String> getContentDoc(String path) {
+        Map<String, String> map = new HashMap();
+        StringBuffer content = new StringBuffer("");
+        String result = "0";  // 0表示获取正常,1表示获取异常
+        InputStream is = null;
+        try {
+            is = new FileInputStream(new File(path));
+            // 2003版本的word
+            WordExtractor extractor = new WordExtractor(is);  // 2003版本 仅doc格式文件可处理,docx文件不可处理
+            String[] paragraphText = extractor.getParagraphText();   // 获取段落,段落缩进无法获取,可以在前添加空格填充
+            if (paragraphText != null && paragraphText.length > 0) {
+                for (String paragraph : paragraphText) {
+                    if (!paragraph.startsWith("    ")) {
+                        content.append("    ").append(paragraph.trim()).append("\r\n");
+                    } else {
+                        content.append(paragraph);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            System.out.println("doc解析正文异常:" + e);
+            result = "1"; // 出现异常
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (IOException e) {
+                    System.out.println("" + e);
+                }
+            }
+            map.put("result", result);
+            map.put("content", content.toString());
+        }
+        return map;
+    }
+
+    /**
+     * 获取正文文件内容,wps方法
+     *
+     * @param path
+     * @return
+     */
+    public Map<String, String> getContentWps(String path) {
+        Map<String, String> map = new HashMap();
+        StringBuffer content = new StringBuffer("");
+        String result = "0";  // 0表示获取正常,1表示获取异常
+        InputStream is = null;
+        try {
+            is = new FileInputStream(new File(path));
+            // wps版本word
+            HWPFDocument hwpf = new HWPFDocument(is);
+            WordExtractor wordExtractor = new WordExtractor(hwpf);
+            // 文档文本内容
+            String[] paragraphText1 = wordExtractor.getParagraphText();
+            if (paragraphText1 != null && paragraphText1.length > 0) {
+                for (String paragraph : paragraphText1) {
+                    if (!paragraph.startsWith("    ")) {
+                        content.append("     ").append(paragraph.trim()).append("\r\n");
+                    } else {
+                        content.append(paragraph);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            System.out.println("wps解析正文异常:" + e);
+            result = "1"; // 出现异常
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (IOException e) {
+                    System.out.println("" + e);
+                }
+            }
+            map.put("result", result);
+            map.put("content", content.toString());
+        }
+        return map;
+    }
+
+}