├── .gitattributes ├── .gitignore ├── README.md ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── example │ │ ├── Application.java │ │ ├── config │ │ ├── AdminHandlerInterceptor.java │ │ ├── LoginHandlerInterceptor.java │ │ └── MyMvcConfig.java │ │ ├── controller │ │ ├── ForgetController.java │ │ ├── LoginController.java │ │ ├── MainPageController.java │ │ ├── RegisterController.java │ │ ├── UserCenterController.java │ │ ├── UserController.java │ │ └── admin │ │ │ ├── UpdateBookController.java │ │ │ ├── UpdateNoticeController.java │ │ │ ├── UpdateUserController.java │ │ │ └── UpdateWordController.java │ │ ├── dto │ │ └── LetterDTO.java │ │ ├── mapper │ │ ├── BookMapper.java │ │ ├── GradeMapper.java │ │ ├── ListenMapper.java │ │ ├── NoticeMapper.java │ │ ├── SentenceMapper.java │ │ ├── TaskDetailMapper.java │ │ ├── TaskMapper.java │ │ ├── UserMapper.java │ │ └── WordMapper.java │ │ ├── pojo │ │ ├── Book.java │ │ ├── Grade.java │ │ ├── Listen.java │ │ ├── Notice.java │ │ ├── Sentence.java │ │ ├── Task.java │ │ ├── TaskDetail.java │ │ ├── User.java │ │ └── Word.java │ │ ├── service │ │ ├── BookService.java │ │ ├── GradeService.java │ │ ├── Impl │ │ │ ├── BookServiceImpl.java │ │ │ ├── GradeServiceImpl.java │ │ │ ├── ListenServiceImpl.java │ │ │ ├── NoticeServiceImpl.java │ │ │ ├── SendEmailImpl.java │ │ │ ├── SentenceServiceImpl.java │ │ │ ├── TaskServiceImpl.java │ │ │ ├── UserServiceImpl.java │ │ │ └── WordServiceImpl.java │ │ ├── ListenService.java │ │ ├── NoticeService.java │ │ ├── SendEmail.java │ │ ├── SentenceService.java │ │ ├── TaskService.java │ │ ├── UserService.java │ │ └── WordService.java │ │ └── util │ │ ├── DataUtils.java │ │ ├── IDUtils.java │ │ ├── JsonResult.java │ │ └── MathUtil.java └── resources │ ├── application.yml │ └── mybatis │ └── mapper │ ├── BookMapper.xml │ ├── GradeMapper.xml │ ├── ListenMapper.xml │ ├── NoticeMapper.xml │ ├── SentenceMapper.xml │ ├── TaskDetailMapper.xml │ ├── TaskMapper.xml │ ├── UserMapper.xml │ └── WordMapper.xml └── test └── java └── com └── example ├── MyspringbootApplicationTests.java └── TestController.java /.gitattributes: -------------------------------------------------------------------------------- 1 | *.js linguist-language=Java 2 | *.css linguist-language=Java 3 | *.html linguist-language=Java 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | logs/ 3 | out/ 4 | !.mvn/wrapper/maven-wrapper.jar 5 | 6 | ### STS ### 7 | .apt_generated 8 | .classpath 9 | .factorypath 10 | .project 11 | .settings 12 | .springBeans 13 | .sts4-cache 14 | 15 | ### IntelliJ IDEA ### 16 | .idea 17 | *.iws 18 | *.iml 19 | *.ipr 20 | log/ 21 | 22 | ### NetBeans ### 23 | nbproject/private/ 24 | build/ 25 | nbbuild/ 26 | dist/ 27 | nbdist/ 28 | .nb-gradle/ 29 | 30 | ### Mac 31 | .DS_Store 32 | */.DS_Store 33 | 34 | ### VS Code ### 35 | *.project 36 | *.factorypath 37 | 38 | ### 屏蔽,需要完整代码联系博主:微信847064370 39 | *.html 40 | templates/ 41 | static/ 42 | webapp/ 43 | *.sql 44 | 45 | 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2023最新消息,新增学习进度,学习统计图,单词复习,生词本 (新功能),后台查询功能,新增单词题目检测功能 2 | # 功能介绍 3 | 基于SpringBoot+MyBatis+Thymeleaf实现英语学习系统。 4 | 5 | - 客户端包括:注册登录模块,单词模块,阅读模块,听力模块,学习进度模块,每日一句模块、单词题目练习 6 | - 注册登录模块:注册登录功能分为登录、注册、忘记密码及管理员登陆四个模块。 7 | - 单词模块:在系统中,用户可以根据自身的需求选择不同的英语单词的背诵。 8 | - 阅读模块:用户可以进行阅读练习。 9 | - 听力模块:用户可以进行听力练习 10 | - 学习进度模块:用户可以查看学习进度。 11 | - 名人名言模块:首页显示英语名人名言。 12 | - 学习进度,学习统计图,单词复习,生词本 (新功能) 13 | - 题目练习,错题本,清空学习记录(新功能) 14 | - 后台管理端包括:用户管理,单词管理,书籍管理,题目管理,等级管理 15 | - 管理员可以通过进入后台页面可以进行添加用户的操作,还可以进行编辑和删除用户的操作。在单词管理和书籍管理中,管理员可以对单词库中的单词进行增加、删除和修改。 16 | 17 | 18 | 详细介绍:[https://liuyanzhao.com/shop/study-english.html](https://liuyanzhao.com/shop/study-english.html)
19 | 预览地址:[http://english.liuyanzhao.com](http://english.liuyanzhao.com) 账号admin密码123456 20 | 21 | - 2023-5月 新增单词题目检测功能,可以看演示站或者详细介绍页面 22 | - 2023-4月 后台所有管理加查询功能 23 | - 2022-4月 生词本、今日单词复习功能 24 | - 2022-3月 今日单词复习默写功能、学习进度统计图 25 | 26 | ## 技术组成 27 | - SpringBoot 28 | - MyBatis 29 | - Thymeleaf 30 | - MySQL 31 | - Maven 32 | 33 | - 说明:本系统没有使用较复杂的框架,代码容易理解。 34 | 35 | ## 预览 36 | 具体最新功能图片见网站介绍页面 https://liuyanzhao.com/shop/study-english.html 37 | 1-首页.png 38 | ![1-首页.png](img/1-首页.png) 39 | 2-单词详情.png 40 | ![2-单词详情.png](img/2-单词详情.png) 41 | 2-学习任务统计图(新).png 42 | ![2-学习任务统计图(新).png](img/2-学习任务统计图(新).png) 43 | 2-学习任务进度(新).png 44 | ![2-学习任务进度(新).png](img/2-学习任务进度(新).png) 45 | 3-单词搜索.png 46 | ![3-单词搜索.png](img/3-单词搜索.png) 47 | 4-阅读列表.png 48 | ![4-阅读列表.png](img/4-阅读列表.png) 49 | 5-阅读详情.png 50 | ![5-阅读详情.png](img/5-阅读详情.png) 51 | 6-听力列表.png 52 | ![6-听力列表.png](img/6-听力列表.png) 53 | 7-听力详情.png 54 | ![7-听力详情.png](img/7-听力详情.png) 55 | 8-公告列表.png 56 | ![8-公告列表.png](img/8-公告列表.png) 57 | 9-用户中心-学习进度.png 58 | ![9-用户中心-学习进度.png](img/9-用户中心-学习进度.png) 59 | 10-添加学习任务.png 60 | ![10-添加学习任务.png](img/10-添加学习任务.png) 61 | 11-听力前往学习.png 62 | ![11-听力前往学习.png](img/11-听力前往学习.png) 63 | 12-阅读前往学习.png 64 | ![12-阅读前往学习.png](img/12-阅读前往学习.png) 65 | 13-单词前往学习.png 66 | ![13-单词前往学习.png](img/13-单词前往学习.png) 67 | 14-登录页面.png 68 | ![14-登录页面.png](img/14-登录页面.png) 69 | 15-注册页面.png 70 | ![15-注册页面.png](img/15-注册页面.png) 71 | 16-忘记密码页面.png 72 | ![16-忘记密码页面.png](img/16-忘记密码页面.png) 73 | 17-管理员单词管理(新).png 74 | ![17-管理员单词管理(新).png](img/17-管理员单词管理(新).png) 75 | 17-管理员单词管理.png 76 | ![17-管理员单词管理.png](img/17-管理员单词管理.png) 77 | 18-单词编辑.png 78 | ![18-单词编辑.png](img/18-单词编辑.png) 79 | 19-书籍管理.png 80 | ![19-书籍管理.png](img/19-书籍管理.png) 81 | 20-书籍编辑.png 82 | ![20-书籍编辑.png](img/20-书籍编辑.png) 83 | 21-用户管理.png 84 | ![21-用户管理.png](img/21-用户管理.png) 85 | 22-公告管理.png 86 | ![22-公告管理.png](img/22-公告管理.png) 87 | 88 | 89 | 90 | 91 | ## 联系方式 Contact Me 92 | 目前只开源后端代码,需要前端和sql等完整代码请联系博主
93 | 同时也提供部署或讲解服务
94 | 微信/QQ:847064370
95 | Email: 847064370@qq.com 96 | [博主博客主页](https://liuyanzhao.com/shop.html)
97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.6.RELEASE 9 | 10 | 11 | com.example 12 | StudyEnglish 13 | 0.0.1-SNAPSHOT 14 | StudyEnglish 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 1.1.10 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-jdbc 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-mail 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-thymeleaf 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-web 38 | 39 | 40 | org.mybatis.spring.boot 41 | mybatis-spring-boot-starter 42 | 2.1.2 43 | 44 | 45 | 46 | 47 | com.github.pagehelper 48 | pagehelper-spring-boot-starter 49 | 1.2.5 50 | 51 | 52 | 53 | mysql 54 | mysql-connector-java 55 | runtime 56 | 57 | 58 | org.projectlombok 59 | lombok 60 | true 61 | 62 | 63 | 64 | 65 | org.springframework.boot 66 | spring-boot-starter-test 67 | test 68 | 69 | 70 | org.junit.vintage 71 | junit-vintage-engine 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | com.alibaba 80 | druid-spring-boot-starter 81 | ${druid.version} 82 | 83 | 84 | 85 | 86 | 87 | aliyun 88 | http://maven.aliyun.com/nexus/content/groups/public 89 | 90 | 91 | 92 | 93 | 94 | aliyun 95 | http://maven.aliyun.com/nexus/content/groups/public 96 | 97 | 98 | 99 | 100 | 101 | StudyEnglish 102 | 103 | 104 | org.springframework.boot 105 | spring-boot-maven-plugin 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /src/main/java/com/example/Application.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.ApplicationContext; 6 | 7 | @SpringBootApplication 8 | public class Application { 9 | 10 | public static void main(String[] args) { 11 | ApplicationContext context = SpringApplication.run(Application.class, args); 12 | String serverPort = context.getEnvironment().getProperty("server.port"); 13 | System.out.println("Project started at http://localhost:" + serverPort); 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/example/config/AdminHandlerInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.example.config; 2 | 3 | import com.example.pojo.User; 4 | import org.springframework.web.servlet.HandlerInterceptor; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | 9 | public class AdminHandlerInterceptor implements HandlerInterceptor { 10 | @Override 11 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 12 | //登录成功之后,应该有用户的session. 13 | //request.getSession().getAttribute 得到`loginUser`的session 14 | User loginUser = (User) request.getSession().getAttribute("loginUser"); 15 | if (loginUser == null) { 16 | request.setAttribute("msg", "没有权限,请先登录"); 17 | request.getRequestDispatcher("/login").forward(request, response); 18 | return false; 19 | } else { 20 | if(loginUser.getRole() == 0) { 21 | request.setAttribute("msg", "非管理员没有权限访问后台,请先登录"); 22 | request.getRequestDispatcher("/login").forward(request, response); 23 | return false; 24 | } 25 | return true; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/example/config/LoginHandlerInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.example.config; 2 | 3 | import org.springframework.web.servlet.HandlerInterceptor; 4 | import org.springframework.web.servlet.ModelAndView; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | 9 | public class LoginHandlerInterceptor implements HandlerInterceptor { 10 | @Override 11 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 12 | //登录成功之后,应该有用户的session. 13 | //request.getSession().getAttribute 得到`loginUser`的session 14 | Object loginUser = request.getSession().getAttribute("loginUser"); 15 | if (loginUser == null) { 16 | request.setAttribute("msg", "没有权限,请先登录"); 17 | request.getRequestDispatcher("/login").forward(request, response); 18 | return false; 19 | } else { 20 | return true; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/example/config/MyMvcConfig.java: -------------------------------------------------------------------------------- 1 | package com.example.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 5 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | @Configuration 9 | public class MyMvcConfig implements WebMvcConfigurer { 10 | 11 | //拦截所有,放行部分路径 12 | @Override 13 | public void addInterceptors(InterceptorRegistry registry) { 14 | registry.addInterceptor(new LoginHandlerInterceptor()).addPathPatterns("/userCenter/**").addPathPatterns("/admin/**"); 15 | registry.addInterceptor(new AdminHandlerInterceptor()).addPathPatterns("/admin").addPathPatterns("/admin/**"); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/example/controller/ForgetController.java: -------------------------------------------------------------------------------- 1 | package com.example.controller; 2 | 3 | import com.example.pojo.User; 4 | import com.example.service.Impl.SendEmailImpl; 5 | import com.example.service.Impl.UserServiceImpl; 6 | import com.example.util.IDUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.Model; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | 12 | import java.util.UUID; 13 | 14 | @Controller 15 | public class ForgetController { 16 | 17 | @Autowired 18 | private UserServiceImpl userService; 19 | 20 | @Autowired 21 | private SendEmailImpl sendEmail; 22 | 23 | 24 | //进行注册 25 | @RequestMapping("/doForget") 26 | public String register(User user, Model model) { 27 | // 判断用户或者邮箱是否存在 28 | User check = userService.findByUserNameAndEmail(user); 29 | if (check == null) { 30 | model.addAttribute("msg", "用户名和邮箱不匹配"); 31 | return "forget"; 32 | } 33 | //发送邮件激活 34 | String email = user.getEmail(); 35 | String subject = "来自学英语网网站的密码重置"; 36 | String newPassword = UUID.randomUUID().toString().substring(0, 8); 37 | check.setPassword(newPassword); 38 | userService.updateUser(check); 39 | 40 | String context = "您的密码已经被重置为" + newPassword; 41 | sendEmail.SendEmail(email, subject, context); 42 | //回到主页面给用户提示 43 | model.addAttribute("msg", "您的密码已经发送到邮箱中"); 44 | return "register"; 45 | } 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/example/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.example.controller; 2 | 3 | import com.example.pojo.User; 4 | import com.example.service.Impl.UserServiceImpl; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.ui.Model; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | 11 | import javax.servlet.http.HttpSession; 12 | 13 | @Controller 14 | public class LoginController { 15 | 16 | 17 | @Autowired 18 | private UserServiceImpl userService; 19 | 20 | /** 21 | * 普通用户登录 22 | * 登录成功,添加session 23 | */ 24 | @RequestMapping("/doLogin") 25 | public String login(User user, Model model, HttpSession session) { 26 | User usr = userService.loginByUserNameAndPasswordAndActiveStatus(user); 27 | if (usr != null) { 28 | //设置session 29 | session.setAttribute("loginUser", usr); 30 | System.out.println("成功登录"); 31 | 32 | if (user.getRole() == 1) { 33 | return "redirect:/admin"; 34 | } else { 35 | return "redirect:/userCenter"; 36 | } 37 | } else { 38 | model.addAttribute("msg", "密码或账号输入错误"); 39 | return "login"; 40 | } 41 | } 42 | 43 | /** 44 | * 管理员用户登录 45 | */ 46 | @RequestMapping("/toAdmin") 47 | public String toAdmin() { 48 | return "admin/index"; 49 | } 50 | 51 | @RequestMapping("/admin") 52 | public String AdminLogin() { 53 | return "admin/main"; 54 | } 55 | 56 | /** 57 | * 注销 58 | */ 59 | @RequestMapping("/logout") 60 | public String logout(HttpSession session) { 61 | session.invalidate(); 62 | return "redirect:/"; 63 | } 64 | 65 | 66 | @GetMapping("/login") 67 | public String login() { 68 | return "login"; 69 | } 70 | 71 | @GetMapping("/register") 72 | public String register() { 73 | return "register"; 74 | } 75 | 76 | 77 | @GetMapping("/forget") 78 | public String forget() { 79 | return "forget"; 80 | } 81 | 82 | 83 | /** 84 | * 跳转管理员主页 85 | */ 86 | @RequestMapping("/admin/main") 87 | public String toAdminPage(Model model) { 88 | return "admin/main"; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/com/example/controller/MainPageController.java: -------------------------------------------------------------------------------- 1 | package com.example.controller; 2 | 3 | import com.example.dto.LetterDTO; 4 | import com.example.pojo.*; 5 | import com.example.service.*; 6 | import com.example.service.Impl.NoticeServiceImpl; 7 | import com.example.service.Impl.SentenceServiceImpl; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | import java.util.Objects; 16 | 17 | @Controller 18 | public class MainPageController { 19 | 20 | @Autowired 21 | private NoticeServiceImpl noticeService; 22 | @Autowired 23 | private SentenceServiceImpl sentenceService; 24 | 25 | @Autowired 26 | private GradeService gradeService; 27 | 28 | @Autowired 29 | private WordService wordService; 30 | 31 | @Autowired 32 | private BookService bookService; 33 | 34 | 35 | @Autowired 36 | private ListenService listenService; 37 | 38 | public final String LETTERS_OF_26 = "abcdefghijklmnopqrstuvwxyz"; 39 | 40 | 41 | /** 42 | * 公共的,方法执行前执行 43 | * 44 | * @param model 45 | */ 46 | @ModelAttribute 47 | public void populateModel(Model model) { 48 | // ----> 以下为公共的 49 | //随机查询每日一句 50 | Sentence sentence = sentenceService.queryRandomSentence(); 51 | model.addAttribute("sentence", sentence); 52 | 53 | // 字母词汇表 54 | List letterList = new ArrayList<>(); 55 | letterList.add(new LetterDTO("a")); 56 | letterList.add(new LetterDTO("b")); 57 | letterList.add(new LetterDTO("c")); 58 | for (LetterDTO letterDTO : letterList) { 59 | letterDTO.setWordList(wordService.findByInitWord(letterDTO.getLetter(), 20)); 60 | } 61 | 62 | model.addAttribute("letterList", letterList); 63 | } 64 | 65 | 66 | /** 67 | * 首页 68 | * 69 | * @param model 70 | * @return 71 | */ 72 | @GetMapping("/") 73 | public String index(@RequestParam(required = false) Integer gradeId, Model model) { 74 | 75 | 76 | // 词汇表 77 | List gradeList = new ArrayList<>(); 78 | if (gradeId != null) { 79 | Grade grade = gradeService.queryGradeById(gradeId); 80 | if (grade == null) { 81 | return "redirect:/"; 82 | } 83 | gradeList.add(grade); 84 | } else { 85 | gradeList = gradeService.queryAllGrade(); 86 | } 87 | for (Grade temp : gradeList) { 88 | List wordList = wordService.queryByGradeId(temp.getGradeId(), 20); 89 | temp.setWordList(wordList); 90 | } 91 | model.addAttribute("gradeList", gradeList); 92 | return "index"; 93 | } 94 | 95 | 96 | /** 97 | * 字母列表 98 | * 99 | * @return 100 | */ 101 | @GetMapping("/word/letter/all") 102 | public String wordLetterList(Model model) { 103 | 104 | List allLetterList = new ArrayList<>(); 105 | for (int i = 0; i < LETTERS_OF_26.length(); i++) { 106 | LetterDTO letterDTO = new LetterDTO(); 107 | String letter = LETTERS_OF_26.charAt(i) + ""; 108 | letterDTO.setLetter(letter); 109 | letterDTO.setWordList(wordService.findByInitWord(letterDTO.getLetter(), 20)); 110 | allLetterList.add(letterDTO); 111 | } 112 | 113 | model.addAttribute("allLetterList", allLetterList); 114 | 115 | return "wordLetterAll"; 116 | } 117 | 118 | 119 | /** 120 | * 单个字母 121 | * 122 | * @return 123 | */ 124 | @GetMapping("/word/letter/{letter}") 125 | public String singleLetter(@PathVariable("letter") String letter, Model model) { 126 | LetterDTO letterDTO = new LetterDTO(); 127 | letterDTO.setLetter(letter); 128 | letterDTO.setWordList(wordService.findByInitWord(letterDTO.getLetter(), null)); 129 | model.addAttribute("letter", letterDTO); 130 | 131 | return "wordLetterDetail"; 132 | } 133 | 134 | 135 | /** 136 | * 单个字母 137 | * 138 | * @return 139 | */ 140 | @GetMapping("/word/{wordId}") 141 | public String singleLetter(@PathVariable("wordId") Integer wordId, Model model) { 142 | Word word = wordService.queryWordById(wordId); 143 | if (word == null) { 144 | return "redirect:/"; 145 | } 146 | model.addAttribute("word", word); 147 | 148 | return "wordDetail"; 149 | } 150 | 151 | /** 152 | * 书籍列表 153 | * 154 | * @return 155 | */ 156 | @GetMapping("/book/all") 157 | public String bookList(Model model) { 158 | 159 | List bookList = bookService.queryAllBook(); 160 | model.addAttribute("bookList", bookList); 161 | return "bookList"; 162 | } 163 | 164 | /** 165 | * 书籍列表 166 | * 167 | * @return 168 | */ 169 | @GetMapping("/book/{bookId}") 170 | public String bookDetail(@PathVariable("bookId") Integer bookId, Model model) { 171 | Book book = bookService.queryBookById(bookId); 172 | if (book == null) { 173 | return "redirect:/"; 174 | } 175 | book.setContent(book.getContent().replace("\r\n", "
").replace("\n", "
")); 176 | model.addAttribute("book", book); 177 | return "bookDetail"; 178 | } 179 | 180 | 181 | /** 182 | * 听力列表 183 | * 184 | * @return 185 | */ 186 | @GetMapping("/listen/all") 187 | public String listenList(Model model) { 188 | 189 | List listenList = listenService.queryAllListen(); 190 | model.addAttribute("listenList", listenList); 191 | return "listenList"; 192 | } 193 | 194 | /** 195 | * 听力列表 196 | * 197 | * @return 198 | */ 199 | @GetMapping("/listen/{listenId}") 200 | public String listenDetail(@PathVariable("listenId") Integer listenId, Model model) { 201 | Listen listen = listenService.queryListenById(listenId); 202 | if (listen == null) { 203 | return "redirect:/"; 204 | } 205 | listen.setContent(listen.getContent().replace("\r\n", "
").replace("\n", "
")); 206 | model.addAttribute("listen", listen); 207 | return "listenDetail"; 208 | } 209 | 210 | /** 211 | * 名人名言列表 212 | * 213 | * @return 214 | */ 215 | @GetMapping("/sentence/all") 216 | public String sentenceList(Model model) { 217 | List sentenceList = sentenceService.queryAllSentence(); 218 | model.addAttribute("sentenceList", sentenceList); 219 | return "sentenceList"; 220 | } 221 | 222 | /** 223 | * 名人名言列表 224 | * 225 | * @return 226 | */ 227 | @GetMapping("/notice/all") 228 | public String noticeList(Model model) { 229 | List noticeList = noticeService.queryAllNotice(); 230 | model.addAttribute("noticeList", noticeList); 231 | return "noticeList"; 232 | } 233 | 234 | /** 235 | * 名人名言列表 236 | * 237 | * @return 238 | */ 239 | @GetMapping("/search") 240 | public String sentenceList(@RequestParam String keywords, Model model) { 241 | List wordList = wordService.queryWordByName(keywords); 242 | List gradeList = gradeService.queryAllGrade(); 243 | 244 | for (Word word : wordList) { 245 | for (Grade grade : gradeList) { 246 | if (Objects.equals(word.getGrade(), grade.getGradeId())) { 247 | if (grade.getWordList() == null) { 248 | grade.setWordList(new ArrayList<>()); 249 | } 250 | grade.getWordList().add(word); 251 | } 252 | } 253 | } 254 | model.addAttribute("gradeList", gradeList); 255 | model.addAttribute("keywords", keywords); 256 | return "wordSearchResult"; 257 | } 258 | 259 | 260 | } 261 | -------------------------------------------------------------------------------- /src/main/java/com/example/controller/RegisterController.java: -------------------------------------------------------------------------------- 1 | package com.example.controller; 2 | 3 | import com.example.pojo.User; 4 | import com.example.service.Impl.SendEmailImpl; 5 | import com.example.service.Impl.UserServiceImpl; 6 | import com.example.util.IDUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.Model; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | 12 | @Controller 13 | public class RegisterController { 14 | 15 | @Autowired 16 | private UserServiceImpl userService; 17 | 18 | @Autowired 19 | private SendEmailImpl sendEmail; 20 | 21 | 22 | //进行注册 23 | @RequestMapping("/doRegister") 24 | public String register(User user, Model model) { 25 | // 判断用户或者邮箱是否存在 26 | User checkUserName = userService.findByUserName(user.getUserName()); 27 | if (checkUserName != null) { 28 | //回到主页面给用户提示 29 | model.addAttribute("msg", "用户名" + user.getUserName() + "已注册"); 30 | return "register"; 31 | } 32 | User checkEmail = userService.findByUserName(user.getUserName()); 33 | if (checkEmail != null) { 34 | //回到主页面给用户提示 35 | model.addAttribute("msg", "电子邮箱" + user.getEmail() + "已注册"); 36 | return "register"; 37 | } 38 | //激活状态为0 39 | user.setActiveStatus(0); 40 | //得到一个UUID 41 | String activeCode = IDUtils.getUUID(); 42 | user.setActiveCode(activeCode); 43 | //加入到数据库 44 | userService.addUser(user); 45 | System.out.println("增加成功"); 46 | //发送邮件激活 47 | String email = user.getEmail(); 48 | String subject = "来自学英语网网站的激活邮件"; 49 | String context = "激活请点击:" + activeCode + ""; 50 | sendEmail.SendEmail(email, subject, context); 51 | //回到主页面给用户提示 52 | model.addAttribute("msg", "注册成功请去邮箱中激活"); 53 | return "register"; 54 | } 55 | 56 | //验证激活码 登录 57 | @RequestMapping("/user/checkCode") 58 | public String active(String activeCode, Model model) { 59 | //查询这个激活码 60 | User user = userService.queryUserByActiveCode(activeCode); 61 | if (user != null) { 62 | model.addAttribute("msg", "恭喜你激活成功,现在可以立即登录"); 63 | //给这个用户激活 64 | user.setActiveStatus(1); 65 | //把激活码清除 66 | user.setActiveCode(" "); 67 | userService.updateUser(user); 68 | } 69 | return "login"; 70 | } 71 | 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/example/controller/UserCenterController.java: -------------------------------------------------------------------------------- 1 | package com.example.controller; 2 | 3 | import com.example.pojo.*; 4 | import com.example.service.*; 5 | import com.example.util.MathUtil; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.servlet.http.HttpSession; 12 | import java.util.*; 13 | 14 | @Controller 15 | public class UserCenterController { 16 | 17 | 18 | @Autowired 19 | private WordService wordService; 20 | 21 | @Autowired 22 | private BookService bookService; 23 | 24 | 25 | @Autowired 26 | private ListenService listenService; 27 | 28 | @Autowired 29 | private TaskService taskService; 30 | 31 | public static Map gradeMap = new HashMap<>(); 32 | 33 | static { 34 | gradeMap.put(1, "四级"); 35 | gradeMap.put(2, "六级"); 36 | gradeMap.put(3, "雅思"); 37 | gradeMap.put(4, "托福"); 38 | } 39 | 40 | 41 | public static Map typeMap = new HashMap<>(); 42 | 43 | static { 44 | typeMap.put("book", "阅读"); 45 | typeMap.put("listen", "听力"); 46 | typeMap.put("word", "单词"); 47 | } 48 | 49 | 50 | /** 51 | * 用户中心 52 | * 53 | * @return 54 | */ 55 | @GetMapping("/userCenter") 56 | public String manage(HttpSession session, Model model) { 57 | User user = (User) session.getAttribute("loginUser"); 58 | if (user == null) { 59 | return "/login"; 60 | } 61 | model.addAttribute("user", user); 62 | 63 | // 学习进度 64 | List taskList = taskService.findByUserId(user.getUserId()); 65 | for (Task task : taskList) { 66 | Integer total = 0; 67 | if ("word".equals(task.getType())) { 68 | total = wordService.queryAllWordNumberByGrade(task.getGrade()); 69 | } else if ("book".equals(task.getType())) { 70 | total = bookService.countByGrade(task.getGrade()); 71 | } else if ("listen".equals(task.getType())) { 72 | total = listenService.countByGrade(task.getGrade()); 73 | } 74 | Integer finish = taskService.countByTask(task); 75 | task.setTotal(total); 76 | task.setFinish(finish); 77 | task.setPercent(MathUtil.toPercent(finish, total)); 78 | } 79 | 80 | model.addAttribute("taskList", taskList); 81 | return "userCenter"; 82 | } 83 | 84 | /** 85 | * 选择页面 86 | * 87 | * @return 88 | */ 89 | @GetMapping("/userCenter/{type}") 90 | public String manage(@PathVariable("type") String type, HttpSession session, Model model) { 91 | User user = (User) session.getAttribute("loginUser"); 92 | if (user == null) { 93 | return "/login"; 94 | } 95 | model.addAttribute("user", user); 96 | List gradeList = new ArrayList<>(); 97 | if ("book".equals(type)) { 98 | gradeList = bookService.getAllGrade(); 99 | } else if ("listen".equals(type)) { 100 | gradeList = listenService.getAllGrade(); 101 | } else if ("word".equals(type)) { 102 | gradeList = wordService.getAllGrade(); 103 | } 104 | model.addAttribute("gradeList", gradeList); 105 | model.addAttribute("type", type); 106 | model.addAttribute("typeName", typeMap.get(type)); 107 | return "userCenterSelect"; 108 | } 109 | 110 | /** 111 | * 选择提交 112 | * 113 | * @return 114 | */ 115 | @GetMapping("/userCenter/doSelect") 116 | public String doSelect(@RequestParam("grade") Integer grade, 117 | @RequestParam("type") String type, HttpSession session, Model model) { 118 | User user = (User) session.getAttribute("loginUser"); 119 | if (user == null) { 120 | return "/login"; 121 | } 122 | Task task = new Task(); 123 | task.setType(type); 124 | task.setGrade(grade); 125 | task.setUserId(user.getUserId()); 126 | task.setName(typeMap.get(type) + gradeMap.get(grade)); 127 | taskService.addTask(task); 128 | return "redirect:/userCenter"; 129 | } 130 | 131 | /** 132 | * 取消进度 133 | * 134 | * @param id 135 | * @param session 136 | * @return 137 | */ 138 | @GetMapping("/userCenter/task/cancel") 139 | public String cancelTask(@RequestParam("id") Integer id, HttpSession session) { 140 | User user = (User) session.getAttribute("loginUser"); 141 | if (user == null) { 142 | return "/login"; 143 | } 144 | 145 | Task task = taskService.queryTaskById(id); 146 | if (task == null || !Objects.equals(task.getUserId(), user.getUserId())) { 147 | return "redirect:/userCenter"; 148 | } 149 | // 删除任务进度 150 | taskService.deleteTask(id); 151 | 152 | return "redirect:/userCenter"; 153 | } 154 | 155 | /** 156 | * 完成一个 157 | * 158 | * @param session 159 | * @return 160 | */ 161 | @GetMapping("/userCenter/task/finishDetail") 162 | public String finishTaskDetail(@RequestParam("taskId") Integer taskId, 163 | @RequestParam("businessId") Integer businessId, 164 | HttpSession session) { 165 | User user = (User) session.getAttribute("loginUser"); 166 | if (user == null) { 167 | return "/login"; 168 | } 169 | 170 | 171 | TaskDetail taskDetail = new TaskDetail(); 172 | taskDetail.setBusinessId(businessId); 173 | taskDetail.setTaskId(taskId); 174 | taskService.addTaskDetail(taskDetail); 175 | return "redirect:/userCenter/task/" + taskId; 176 | } 177 | 178 | /** 179 | * 取消完成一个 180 | * 181 | * @param session 182 | * @return 183 | */ 184 | @GetMapping("/userCenter/task/cancelFinishDetail") 185 | public String cancelFinishTaskDetail(@RequestParam("taskId") Integer taskId, 186 | @RequestParam("businessId") Integer businessId, 187 | HttpSession session) { 188 | User user = (User) session.getAttribute("loginUser"); 189 | if (user == null) { 190 | return "/login"; 191 | } 192 | 193 | taskService.deleteTaskDetail(taskId, businessId); 194 | return "redirect:/userCenter/task/" + taskId; 195 | } 196 | 197 | /** 198 | * 用户中心 199 | * 200 | * @return 201 | */ 202 | @GetMapping("/userCenter/task/{taskId}") 203 | public String taskDetail(@PathVariable("taskId") Integer taskId, HttpSession session, Model model) { 204 | User user = (User) session.getAttribute("loginUser"); 205 | if (user == null) { 206 | return "/login"; 207 | } 208 | model.addAttribute("user", user); 209 | 210 | // 学习进度 211 | Task task = taskService.queryTaskById(taskId); 212 | if (task == null) { 213 | return "redirect:/"; 214 | } 215 | 216 | if ("word".equals(task.getType())) { 217 | Integer total = wordService.queryAllWordNumberByGrade(task.getGrade()); 218 | Integer finish = taskService.countByTask(task); 219 | task.setTotal(total); 220 | task.setFinish(finish); 221 | if (finish.equals(total)) { 222 | return "redirect:/userCenter"; 223 | } 224 | // 查询未完成的,下一个 225 | Word word = wordService.getNext(taskId); 226 | if (word == null) { 227 | return "redirect:/userCenter"; 228 | } 229 | 230 | model.addAttribute("word", word); 231 | model.addAttribute("businessId", word.getWordId()); 232 | task.setPercent(MathUtil.toPercent(finish, total)); 233 | 234 | model.addAttribute("task", task); 235 | model.addAttribute("isTask", true); 236 | return "wordDetail"; 237 | } else if ("book".equals(task.getType())) { 238 | Integer total = bookService.countByGrade(task.getGrade()); 239 | Integer finish = taskService.countByTask(task); 240 | task.setTotal(total); 241 | task.setFinish(finish); 242 | if (finish.equals(total)) { 243 | return "redirect:/userCenter"; 244 | } 245 | // 查询未完成的,下一个 246 | Book book = bookService.getNext(taskId); 247 | if (book == null) { 248 | return "redirect:/userCenter"; 249 | } 250 | book.setContent(book.getContent().replace("\r\n", "
").replace("\n", "
")); 251 | 252 | model.addAttribute("businessId", book.getBookId()); 253 | model.addAttribute("book", book); 254 | task.setPercent(MathUtil.toPercent(finish, total)); 255 | model.addAttribute("task", task); 256 | 257 | model.addAttribute("isTask", true); 258 | return "bookDetail"; 259 | } else if ("listen".equals(task.getType())) { 260 | Integer total = listenService.countByGrade(task.getGrade()); 261 | Integer finish = taskService.countByTask(task); 262 | task.setTotal(total); 263 | task.setFinish(finish); 264 | if (finish.equals(total)) { 265 | return "redirect:/userCenter"; 266 | } 267 | // 查询未完成的,下一个 268 | Listen listen = listenService.getNext(taskId); 269 | if (listen == null) { 270 | return "redirect:/userCenter"; 271 | } 272 | listen.setContent(listen.getContent().replace("\r\n", "
").replace("\n", "
")); 273 | 274 | model.addAttribute("listen", listen); 275 | model.addAttribute("businessId", listen.getListenId()); 276 | 277 | task.setPercent(MathUtil.toPercent(finish, total)); 278 | model.addAttribute("task", task); 279 | 280 | model.addAttribute("isTask", true); 281 | return "listenDetail"; 282 | } 283 | return "redirect:/userCenter"; 284 | } 285 | 286 | 287 | } 288 | -------------------------------------------------------------------------------- /src/main/java/com/example/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.example.controller; 2 | 3 | import com.example.pojo.User; 4 | import com.example.service.Impl.UserServiceImpl; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.ui.Model; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | 11 | import javax.servlet.http.HttpSession; 12 | 13 | @Controller 14 | public class UserController { 15 | @Autowired 16 | UserServiceImpl userService; 17 | 18 | //用户自己修改名字 19 | //接收前端传来的字符串 20 | @RequestMapping("/getStringParam/{newname}") 21 | public String getStringParam(@PathVariable("newname") String newName, HttpSession session) { 22 | //从session中拿到用户,修改session的姓名 23 | User loginUser = (User) session.getAttribute("loginUser"); 24 | loginUser.setUserName(newName); 25 | //修改数据库中的名字 26 | userService.updateUser(loginUser); 27 | 28 | 29 | return "redirect:/userCenter"; 30 | } 31 | 32 | //前往用户修改信息页面 33 | @RequestMapping("/toUser") 34 | public String toUser(HttpSession session, Model model) { 35 | //从session中拿到用户,修改session的姓名 36 | User loginUser = (User) session.getAttribute("loginUser"); 37 | 38 | model.addAttribute("loginUser", loginUser); 39 | 40 | 41 | return "user/user"; 42 | } 43 | 44 | //用户修改信息 45 | @RequestMapping("/userUpdate/{userId}") 46 | public String userUpdate(@PathVariable("userId") Integer userId, User user, HttpSession session, Model model) { 47 | 48 | //修改信息 49 | userService.updateUser(user); 50 | 51 | //设置session 52 | session.setAttribute("loginUser", user); 53 | 54 | return "redirect:/userCenter"; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/example/controller/admin/UpdateBookController.java: -------------------------------------------------------------------------------- 1 | package com.example.controller.admin; 2 | 3 | import com.example.pojo.Book; 4 | import com.example.service.Impl.BookServiceImpl; 5 | import com.example.service.Impl.NoticeServiceImpl; 6 | import com.example.util.DataUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.Model; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.PostMapping; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | 14 | import java.text.ParseException; 15 | import java.util.List; 16 | 17 | @Controller 18 | public class UpdateBookController { 19 | @Autowired 20 | NoticeServiceImpl noticeService; 21 | @Autowired 22 | DataUtils dataUtils; 23 | @Autowired 24 | BookServiceImpl bookService; 25 | 26 | /** 27 | * 28 | * 查看书籍 29 | */ 30 | @RequestMapping("/admin/viewBook") 31 | public String viewBook(Model model){ 32 | List book = bookService.queryAllBook(); 33 | model.addAttribute("book",book); 34 | return "admin/Book-View"; 35 | } 36 | 37 | 38 | /** 39 | * 40 | * 修改书籍 41 | */ 42 | //去修改页面 43 | @RequestMapping("/admin/toUpdateBook/{bookId}") 44 | public String toUpdateBook(@PathVariable("bookId")Integer bookId,Model model){ 45 | 46 | Book book = bookService.queryBookById(bookId); 47 | model.addAttribute("book",book); 48 | return "admin/Book-Update"; 49 | } 50 | //进行修改提交,回到view页面 51 | @RequestMapping("/admin/updateBook/{bookId}") 52 | public String updateBook(@PathVariable("bookId")Integer bookId,Book book){ 53 | 54 | 55 | bookService.updateBook(book); 56 | return "redirect:/admin/viewBook"; 57 | } 58 | /** 59 | * 60 | * 删除书籍 61 | */ 62 | 63 | @RequestMapping("/admin/deleteBook/{bookId}") 64 | public String deleteBook(@PathVariable("bookId") Integer bookId){ 65 | 66 | bookService.deleteBook(bookId); 67 | 68 | return "redirect:/admin/viewBook"; 69 | } 70 | 71 | /** 72 | * 73 | * 增加书籍 74 | */ 75 | 76 | @RequestMapping("/admin/toAddBook") 77 | public String toAddBook(){ 78 | return "admin/Book-Add"; 79 | } 80 | @PostMapping("/admin/addBook") 81 | public String addBook(Book book) throws ParseException { 82 | 83 | 84 | bookService.addBook(book); 85 | return "redirect:/admin/viewBook"; 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/example/controller/admin/UpdateNoticeController.java: -------------------------------------------------------------------------------- 1 | package com.example.controller.admin; 2 | 3 | import com.example.pojo.Notice; 4 | import com.example.service.Impl.NoticeServiceImpl; 5 | import com.example.util.DataUtils; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.PostMapping; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | 13 | import java.text.ParseException; 14 | import java.util.Date; 15 | import java.util.List; 16 | 17 | @Controller 18 | public class UpdateNoticeController { 19 | @Autowired 20 | NoticeServiceImpl noticeService; 21 | @Autowired 22 | DataUtils dataUtils; 23 | 24 | /** 25 | * 26 | * 查看公告 27 | */ 28 | @RequestMapping("/admin/viewNotice") 29 | public String viewNotice(Model model){ 30 | List notice = noticeService.queryAllNotice(); 31 | model.addAttribute("notice",notice); 32 | return "admin/Notice-View"; 33 | } 34 | 35 | 36 | /** 37 | * 38 | * 修改公告 39 | */ 40 | //去修改页面 41 | @RequestMapping("/admin/toUpdateNotice/{noticeId}") 42 | public String toUpdateNotice(@PathVariable("noticeId")Integer noticeId,Model model){ 43 | 44 | Notice notice = noticeService.queryNoticeById(noticeId); 45 | model.addAttribute("notice",notice); 46 | return "admin/Notice-Update"; 47 | } 48 | //进行修改提交,回到view页面 49 | @RequestMapping("/admin/updateNotice/{noticeId}") 50 | public String updateNotice(@PathVariable("noticeId")Integer noticeId,Notice notice){ 51 | 52 | Date creatTime = notice.getCreatTime(); 53 | System.out.println(creatTime); 54 | noticeService.updateNotice(notice); 55 | return "redirect:/admin/viewNotice"; 56 | } 57 | /** 58 | * 59 | * 删除公告 60 | */ 61 | 62 | @RequestMapping("/admin/deleteNotice/{noticeId}") 63 | public String deleteNotice(@PathVariable("noticeId") Integer noticeId){ 64 | 65 | noticeService.deleteNotice(noticeId); 66 | 67 | return "redirect:/admin/viewNotice"; 68 | } 69 | 70 | /** 71 | * 72 | * 增加公告 73 | */ 74 | 75 | @RequestMapping("/admin/toAddNotice") 76 | public String toAaddNotice(){ 77 | return "admin/Notice-Add"; 78 | } 79 | @PostMapping("/admin/addNotice") 80 | public String addNotice(Notice notice) throws ParseException { 81 | //得到当前日期 82 | Date date = dataUtils.getDate(); 83 | notice.setCreatTime(date); 84 | 85 | noticeService.addNotice(notice); 86 | return "redirect:/admin/viewNotice"; 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/example/controller/admin/UpdateUserController.java: -------------------------------------------------------------------------------- 1 | package com.example.controller.admin; 2 | 3 | import com.example.pojo.User; 4 | import com.example.service.Impl.UserServiceImpl; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.ui.Model; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | 12 | import java.util.List; 13 | @Controller 14 | public class UpdateUserController { 15 | @Autowired 16 | UserServiceImpl userService; 17 | 18 | /** 19 | * 查看用户 20 | */ 21 | @RequestMapping("/admin/viewUser") 22 | public String viewUser(Model model) { 23 | List user = userService.queryAllUser(); 24 | model.addAttribute("user", user); 25 | return "admin/User-View"; 26 | } 27 | 28 | 29 | /** 30 | * 修改用户 31 | */ 32 | //去修改页面 33 | @RequestMapping("/admin/toUpdateUser/{userId}") 34 | public String toUpdateUser(@PathVariable("userId") Integer userId, Model model) { 35 | 36 | User user = userService.queryUserById(userId); 37 | 38 | model.addAttribute("user", user); 39 | return "admin/User-Update"; 40 | } 41 | 42 | //进行修改提交,回到view页面 43 | @RequestMapping("/admin/updateUser/{userId}") 44 | public String updateUser(@PathVariable("userId") Integer userId, User user) { 45 | userService.updateUser(user); 46 | 47 | return "redirect:/admin/viewUser"; 48 | } 49 | 50 | /** 51 | * 删除用户 52 | */ 53 | 54 | @RequestMapping("/admin/deleteUser/{userId}") 55 | public String deleteUser(@PathVariable("userId") Integer userId) { 56 | 57 | userService.deleteUser(userId); 58 | 59 | 60 | return "redirect:/admin/viewUser"; 61 | } 62 | 63 | /** 64 | * 增加用户 65 | */ 66 | // 67 | @RequestMapping("/admin/toAddUser") 68 | public String toAddUser() { 69 | return "admin/User-Add"; 70 | } 71 | 72 | @PostMapping("/admin/addUser") 73 | public String addUser(User user) { 74 | userService.addUser(user); 75 | 76 | return "redirect:/admin/viewUser"; 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/example/controller/admin/UpdateWordController.java: -------------------------------------------------------------------------------- 1 | package com.example.controller.admin; 2 | 3 | import com.example.pojo.Word; 4 | import com.example.service.Impl.WordServiceImpl; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.ui.Model; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | 12 | import java.util.List; 13 | 14 | @Controller 15 | public class UpdateWordController { 16 | @Autowired 17 | WordServiceImpl wordService; 18 | 19 | /** 20 | * 查看单词 21 | */ 22 | @RequestMapping("/admin/viewWord") 23 | public String viewWord(Model model) { 24 | List word = wordService.queryAllWord(); 25 | model.addAttribute("word", word); 26 | return "admin/Word-View"; 27 | } 28 | 29 | 30 | /** 31 | * 修改单词 32 | */ 33 | //去修改页面 34 | @RequestMapping("/admin/toUpdateWord/{wordId}") 35 | public String toUpdateWord(@PathVariable("wordId") Integer wordId, Model model) { 36 | 37 | 38 | Word word = wordService.queryWordById(wordId); 39 | model.addAttribute("word", word); 40 | return "admin/Word-Update"; 41 | } 42 | 43 | //进行修改提交,回到view页面 44 | @RequestMapping("/admin/updateWord/{wordId}") 45 | public String updateNotice(@PathVariable("wordId")Integer wordId,Word word){ 46 | 47 | wordService.updateWord(word); 48 | return "redirect:/admin/viewWord"; 49 | } 50 | /** 51 | * 52 | * 删除单词 53 | */ 54 | 55 | @RequestMapping("/admin/deleteWord/{wordId}") 56 | public String deleteNotice(@PathVariable("wordId") Integer wordId){ 57 | 58 | wordService.deleteWord(wordId); 59 | 60 | 61 | return "redirect:/admin/viewWord"; 62 | } 63 | 64 | /** 65 | * 66 | * 增加单词 67 | */ 68 | // 69 | @RequestMapping("/admin/toAddWord") 70 | public String toAddWord(){ 71 | return "admin/Word-Add"; 72 | } 73 | @PostMapping("/admin/addWord") 74 | public String addWord(Word word) { 75 | wordService.addWord(word); 76 | return "redirect:/admin/viewWord"; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/example/dto/LetterDTO.java: -------------------------------------------------------------------------------- 1 | package com.example.dto; 2 | 3 | import com.example.pojo.Word; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author 言曌 10 | * @date 2020/12/12 12:18 下午 11 | */ 12 | @Data 13 | public class LetterDTO { 14 | private String letter; 15 | 16 | private List wordList; 17 | 18 | public LetterDTO(String letter) { 19 | this.letter = letter; 20 | } 21 | 22 | public LetterDTO() { 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/example/mapper/BookMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.mapper; 2 | 3 | import com.example.pojo.Book; 4 | import com.example.pojo.Grade; 5 | import com.example.pojo.Word; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | @Mapper 11 | @Repository 12 | public interface BookMapper { 13 | //根据ID查询一条书的信息 14 | Book queryBookById(Integer bookId); 15 | //增加书 16 | int addBook(Book book); 17 | //删除书 18 | int deleteBook(Integer bookId); 19 | //修改书 20 | int updateBook(Book book); 21 | //查看书所有信息 22 | List queryAllBook(); 23 | 24 | int countByGrade(Integer grade); 25 | 26 | 27 | /** 28 | * 查询下一个 29 | * @return 30 | */ 31 | Book getNext(Integer taskId); 32 | 33 | List getAllGrade(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/example/mapper/GradeMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.mapper; 2 | 3 | import com.example.pojo.Grade; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | @Mapper 9 | @Repository 10 | public interface GradeMapper { 11 | //根据ID查询一等级的信息 12 | Grade queryGradeById(Integer gradeId); 13 | //增加等级 14 | int addGrade(Grade grade); 15 | //删除等级 16 | int deleteGrade(Integer gradeId); 17 | //修改等级 18 | int updateGrade(Grade grade); 19 | //查看等级所有信息 20 | List queryAllGrade(); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/example/mapper/ListenMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.mapper; 2 | 3 | import com.example.pojo.Book; 4 | import com.example.pojo.Grade; 5 | import com.example.pojo.Listen; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | @Mapper 12 | @Repository 13 | public interface ListenMapper { 14 | //根据ID查询一条听力的信息 15 | Listen queryListenById(Integer listenId); 16 | //增加一条听力 17 | int addListen(Listen listen); 18 | //删除一条听力 19 | int deleteListen(Integer listenId); 20 | //修改一条听力 21 | int updateListen(Listen listen); 22 | //查看所有听力所有信息 23 | List queryAllListen(); 24 | 25 | int countByGrade(Integer grade); 26 | 27 | 28 | /** 29 | * 查询下一个 30 | * @return 31 | */ 32 | Listen getNext(Integer taskId); 33 | 34 | List getAllGrade(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/example/mapper/NoticeMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.mapper; 2 | 3 | import com.example.pojo.Notice; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | @Mapper 9 | @Repository 10 | public interface NoticeMapper { 11 | //根据ID查询一条公告 12 | Notice queryNoticeById(Integer noticeId); 13 | //增加公告 14 | int addNotice(Notice notice); 15 | //删除公告 16 | int deleteNotice(Integer noticeId); 17 | //修改公告 18 | int updateNotice(Notice notice); 19 | //查看公告所有信息 20 | List queryAllNotice(); 21 | //查看最新公告的内容 22 | Notice queryNewNoticeById(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/example/mapper/SentenceMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.mapper; 2 | 3 | import com.example.pojo.Sentence; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | @Mapper 9 | @Repository 10 | public interface SentenceMapper { 11 | //根据ID查询一条句子的信息 12 | Sentence querySentenceById(Integer sentenceId); 13 | //增加一条句子 14 | int addSentence(Sentence sentence); 15 | //删除一条句子 16 | int deleteSentence(Integer sentenceId); 17 | //修改一条句子 18 | int updateSentence(Sentence sentence); 19 | //查看所有句子所有信息 20 | List queryAllSentence(); 21 | //随机取一条句子 22 | Sentence queryRandomSentence(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/example/mapper/TaskDetailMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.mapper; 2 | 3 | import com.example.pojo.Task; 4 | import com.example.pojo.TaskDetail; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | @Mapper 12 | @Repository 13 | public interface TaskDetailMapper { 14 | //根据ID查询一条进度详情的信息 15 | TaskDetail queryTaskDetailById(Integer taskDetailId); 16 | 17 | //增加进度详情 18 | int addTaskDetail(TaskDetail taskDetail); 19 | 20 | //删除进度详情 21 | int deleteTaskDetail(Integer taskDetailId); 22 | 23 | //修改进度详情 24 | int updateTaskDetail(TaskDetail taskDetail); 25 | 26 | //查看进度详情所有信息 27 | List queryAllTaskDetail(); 28 | 29 | Integer countByTask(Task task); 30 | 31 | 32 | 33 | /** 34 | * 删除 35 | * @param taskId 36 | * @param businessId 37 | */ 38 | void deleteTaskDetailByTaskIdAndBusinessId(@Param("taskId") Integer taskId, 39 | @Param("businessId") Integer businessId); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/example/mapper/TaskMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.mapper; 2 | 3 | import com.example.pojo.Task; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | @Repository 11 | public interface TaskMapper { 12 | //根据ID查询一条进度的信息 13 | Task queryTaskById(Integer taskId); 14 | //增加进度 15 | int addTask(Task task); 16 | //删除进度 17 | int deleteTask(Integer taskId); 18 | //修改进度 19 | int updateTask(Task task); 20 | //查看进度所有信息 21 | List queryAllTask(); 22 | 23 | List findByUserId(Integer userId); 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/example/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.mapper; 2 | 3 | import com.example.pojo.User; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | @Repository 11 | public interface UserMapper { 12 | 13 | 14 | /** 15 | * 注册用户 16 | * 与登录用户 17 | */ 18 | //增加用户--注册用户 19 | int addUser(User user); 20 | //根据激活码查询用户 21 | User queryUserByActiveCode(String activeCode); 22 | 23 | //根据账号密码和状态码(1)登录 24 | User loginByUserNameAndPasswordAndActiveStatus(User user); 25 | //根据账号密码和role=1登录 26 | User AdminLogin(User user); 27 | /** 28 | * 操作用户 29 | * 30 | */ 31 | 32 | //删除用户 33 | int deleteUser(Integer userId); 34 | //修改用户 35 | int updateUser(User user); 36 | 37 | 38 | //查询所有用户信息 39 | List queryAllUser(); 40 | //根据Id查询用户 41 | User queryUserById(int userId); 42 | 43 | 44 | User findByUserName(String userName); 45 | User findByEmail(String email); 46 | 47 | User findByUserNameAndEmail(User user); 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/example/mapper/WordMapper.java: -------------------------------------------------------------------------------- 1 | package com.example.mapper; 2 | 3 | import com.example.pojo.Grade; 4 | import com.example.pojo.Word; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | @Mapper 12 | @Repository 13 | public interface WordMapper { 14 | 15 | 16 | //增加一个单词 17 | int addWord(Word word); 18 | 19 | 20 | //删除一个单词 21 | int deleteWord(Integer wordId); 22 | 23 | 24 | //修改一个单词 25 | int updateWord(Word word); 26 | 27 | 28 | //查询所有单词信息 29 | List queryAllWord(); 30 | 31 | //根据ID查询一个单词的信息 32 | Word queryWordById(Integer wordId); 33 | 34 | //根据grade查询单词数量 35 | int queryAllWordNumberByGrade(Integer grade); 36 | 37 | 38 | List queryByGradeId(@Param("gradeId") Integer gradeId, 39 | @Param("limit") Integer limit); 40 | 41 | 42 | /** 43 | * 首字母查询 44 | * 45 | * @param initWord 46 | * @param limit 47 | * @return 48 | */ 49 | List findByInitWord(@Param("initWord") String initWord, 50 | @Param("limit") Integer limit); 51 | 52 | /** 53 | * 查询下一个单词 54 | * 55 | * @return 56 | */ 57 | Word getNext(Integer taskId); 58 | 59 | List getAllGrade(); 60 | 61 | 62 | List queryWordByName(String name); 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/example/pojo/Book.java: -------------------------------------------------------------------------------- 1 | package com.example.pojo; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Book { 7 | private int bookId; 8 | private String bookName; 9 | private String bookUser; 10 | private String description; 11 | private String content; 12 | private Integer grade; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/example/pojo/Grade.java: -------------------------------------------------------------------------------- 1 | package com.example.pojo; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class Grade { 9 | private Integer gradeId; 10 | private String gradeName; 11 | 12 | /** 13 | * 单词列表 14 | */ 15 | private List wordList; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/example/pojo/Listen.java: -------------------------------------------------------------------------------- 1 | package com.example.pojo; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Listen { 7 | private Integer listenId; 8 | private String listenName; 9 | private Integer grade; 10 | private String path; 11 | private String content; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/example/pojo/Notice.java: -------------------------------------------------------------------------------- 1 | package com.example.pojo; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | import org.springframework.format.annotation.DateTimeFormat; 6 | 7 | import java.text.Format; 8 | import java.util.Date; 9 | 10 | @Data 11 | public class Notice { 12 | private Integer noticeId; 13 | private String title; 14 | private String content; 15 | @DateTimeFormat(pattern="yyyy-MM-dd",iso=DateTimeFormat.ISO.DATE) 16 | @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8") 17 | private Date creatTime; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/example/pojo/Sentence.java: -------------------------------------------------------------------------------- 1 | package com.example.pojo; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Sentence { 7 | private Integer sentenceId; 8 | private String sentenceName; 9 | private String explain; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/example/pojo/Task.java: -------------------------------------------------------------------------------- 1 | package com.example.pojo; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Task { 7 | private Integer id; 8 | private String type; 9 | private Integer grade; 10 | private Integer userId; 11 | private String name; 12 | 13 | /** 14 | * 完成百分比 15 | */ 16 | private String percent; 17 | private Integer total; 18 | private Integer finish; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/example/pojo/TaskDetail.java: -------------------------------------------------------------------------------- 1 | package com.example.pojo; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class TaskDetail { 7 | private Integer id; 8 | private Integer businessId; 9 | private Integer taskId; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/example/pojo/User.java: -------------------------------------------------------------------------------- 1 | package com.example.pojo; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class User { 7 | private Integer userId; 8 | private String userName; 9 | private String password; 10 | private String email; 11 | private String activeCode; 12 | private int activeStatus; 13 | private int role; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/example/pojo/Word.java: -------------------------------------------------------------------------------- 1 | package com.example.pojo; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Word { 7 | private Integer wordId; 8 | private String wordName; 9 | private String audio; 10 | private String explanation; 11 | private String example; 12 | private Integer grade; 13 | private Integer study; 14 | private Integer remember; 15 | private Integer collection; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/BookService.java: -------------------------------------------------------------------------------- 1 | package com.example.service; 2 | 3 | import com.example.pojo.Book; 4 | import com.example.pojo.Grade; 5 | import com.example.pojo.Word; 6 | 7 | import java.util.List; 8 | 9 | public interface BookService { 10 | //根据ID查询一条书的信息 11 | Book queryBookById(Integer bookId); 12 | //增加书 13 | int addBook(Book book); 14 | //删除书 15 | int deleteBook(Integer bookId); 16 | //修改书 17 | int updateBook(Book book); 18 | //查看书所有信息 19 | List queryAllBook(); 20 | 21 | int countByGrade(Integer grade); 22 | 23 | Book getNext(Integer taskId); 24 | 25 | List getAllGrade(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/GradeService.java: -------------------------------------------------------------------------------- 1 | package com.example.service; 2 | 3 | import com.example.pojo.Grade; 4 | 5 | import java.util.List; 6 | 7 | public interface GradeService { 8 | //根据ID查询一等级的信息 9 | Grade queryGradeById(Integer gradeId); 10 | 11 | //增加等级 12 | int addGrade(Grade grade); 13 | 14 | //删除等级 15 | int deleteGrade(Integer gradeId); 16 | 17 | //修改等级 18 | int updateGrade(Grade grade); 19 | 20 | //查看等级所有信息 21 | List queryAllGrade(); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/Impl/BookServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.service.Impl; 2 | 3 | import com.example.mapper.BookMapper; 4 | import com.example.pojo.Book; 5 | import com.example.pojo.Grade; 6 | import com.example.service.BookService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.List; 11 | 12 | @Service 13 | public class BookServiceImpl implements BookService { 14 | @Autowired 15 | BookMapper bookMapper; 16 | 17 | @Override 18 | public Book queryBookById(Integer bookId) { 19 | return bookMapper.queryBookById(bookId); 20 | } 21 | 22 | @Override 23 | public int addBook(Book book) { 24 | return bookMapper.addBook(book); 25 | } 26 | 27 | @Override 28 | public int deleteBook(Integer bookId) { 29 | return bookMapper.deleteBook(bookId); 30 | } 31 | 32 | @Override 33 | public int updateBook(Book book) { 34 | return bookMapper.updateBook(book); 35 | } 36 | 37 | @Override 38 | public List queryAllBook() { 39 | return bookMapper.queryAllBook(); 40 | } 41 | 42 | @Override 43 | public int countByGrade(Integer grade) { 44 | return bookMapper.countByGrade(grade); 45 | } 46 | 47 | @Override 48 | public Book getNext(Integer taskId) { 49 | return bookMapper.getNext(taskId); 50 | } 51 | 52 | @Override 53 | public List getAllGrade() { 54 | return bookMapper.getAllGrade(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/Impl/GradeServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.service.Impl; 2 | 3 | import com.example.mapper.GradeMapper; 4 | import com.example.pojo.Grade; 5 | import com.example.service.GradeService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | @Service 12 | public class GradeServiceImpl implements GradeService { 13 | @Autowired 14 | GradeMapper gradeMapper; 15 | 16 | @Override 17 | public Grade queryGradeById(Integer gradeId) { 18 | return gradeMapper.queryGradeById(gradeId); 19 | } 20 | 21 | @Override 22 | public int addGrade(Grade grade) { 23 | return gradeMapper.addGrade(grade); 24 | } 25 | 26 | @Override 27 | public int deleteGrade(Integer gradeId) { 28 | return gradeMapper.deleteGrade(gradeId); 29 | } 30 | 31 | @Override 32 | public int updateGrade(Grade grade) { 33 | return gradeMapper.updateGrade(grade); 34 | } 35 | 36 | @Override 37 | public List queryAllGrade() { 38 | return gradeMapper.queryAllGrade(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/Impl/ListenServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.service.Impl; 2 | 3 | import com.example.mapper.ListenMapper; 4 | import com.example.pojo.Grade; 5 | import com.example.pojo.Listen; 6 | import com.example.service.ListenService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.List; 11 | @Service 12 | public class ListenServiceImpl implements ListenService { 13 | @Autowired 14 | ListenMapper listenMapper; 15 | 16 | @Override 17 | public Listen queryListenById(Integer listenId) { 18 | return listenMapper.queryListenById(listenId); 19 | } 20 | 21 | @Override 22 | public int addListen(Listen listen) { 23 | return listenMapper.addListen(listen); 24 | } 25 | 26 | @Override 27 | public int deleteListen(Integer listenId) { 28 | return listenMapper.deleteListen(listenId); 29 | } 30 | 31 | @Override 32 | public int updateListen(Listen listen) { 33 | return listenMapper.updateListen(listen); 34 | } 35 | 36 | @Override 37 | public List queryAllListen() { 38 | return listenMapper.queryAllListen(); 39 | } 40 | 41 | @Override 42 | public Integer countByGrade(Integer grade) { 43 | return listenMapper.countByGrade(grade); 44 | } 45 | 46 | @Override 47 | public Listen getNext(Integer taskId) { 48 | return listenMapper.getNext(taskId); 49 | } 50 | 51 | @Override 52 | public List getAllGrade() { 53 | return listenMapper.getAllGrade(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/Impl/NoticeServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.service.Impl; 2 | 3 | import com.example.mapper.NoticeMapper; 4 | import com.example.pojo.Notice; 5 | import com.example.service.NoticeService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | @Service 11 | public class NoticeServiceImpl implements NoticeService { 12 | @Autowired 13 | private NoticeMapper noticeMapper; 14 | 15 | @Override 16 | public Notice queryNoticeById(Integer noticeId) { 17 | return noticeMapper.queryNoticeById(noticeId); 18 | } 19 | 20 | @Override 21 | public int addNotice(Notice notice) { 22 | return noticeMapper.addNotice(notice); 23 | } 24 | 25 | @Override 26 | public int deleteNotice(Integer noticeId) { 27 | return noticeMapper.deleteNotice(noticeId); 28 | } 29 | 30 | @Override 31 | public int updateNotice(Notice notice) { 32 | return noticeMapper.updateNotice(notice); 33 | } 34 | 35 | @Override 36 | public List queryAllNotice() { 37 | return noticeMapper.queryAllNotice(); 38 | } 39 | 40 | @Override 41 | public Notice queryNewNoticeById() { 42 | return noticeMapper.queryNewNoticeById(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/Impl/SendEmailImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.service.Impl; 2 | 3 | import com.example.service.SendEmail; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.mail.javamail.JavaMailSenderImpl; 9 | import org.springframework.mail.javamail.MimeMessageHelper; 10 | import org.springframework.stereotype.Service; 11 | 12 | import javax.mail.MessagingException; 13 | import javax.mail.internet.MimeMessage; 14 | 15 | 16 | @Service 17 | public class SendEmailImpl implements SendEmail { 18 | 19 | private final Logger logger = LoggerFactory.getLogger(this.getClass()); 20 | 21 | @Autowired 22 | JavaMailSenderImpl mailSender; 23 | 24 | @Value("${spring.mail.username}") 25 | private String from; 26 | 27 | @Override 28 | public void SendEmail(String to, String subject, String content) { 29 | MimeMessage message = mailSender.createMimeMessage(); 30 | MimeMessageHelper helper = null; 31 | try { 32 | helper = new MimeMessageHelper(message, true); 33 | helper.setFrom(from); 34 | helper.setSubject(subject); 35 | helper.setTo(to); 36 | helper.setText(content, true); 37 | mailSender.send(message); 38 | //日志信息 39 | logger.info("邮件已经发送。"); 40 | } catch (MessagingException e) { 41 | logger.error("发送邮件时发生异常!", e); 42 | } 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/Impl/SentenceServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.service.Impl; 2 | 3 | import com.example.mapper.SentenceMapper; 4 | import com.example.pojo.Sentence; 5 | import com.example.service.SentenceService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | @Service 11 | public class SentenceServiceImpl implements SentenceService { 12 | @Autowired 13 | SentenceMapper sentenceMapper; 14 | 15 | @Override 16 | public Sentence querySentenceById(Integer sentenceId) { 17 | return sentenceMapper.querySentenceById(sentenceId); 18 | } 19 | 20 | @Override 21 | public int addSentence(Sentence sentence) { 22 | return sentenceMapper.addSentence(sentence); 23 | } 24 | 25 | @Override 26 | public int deleteSentence(Integer sentenceId) { 27 | return sentenceMapper.deleteSentence(sentenceId); 28 | } 29 | 30 | @Override 31 | public int updateSentence(Sentence sentence) { 32 | return sentenceMapper.updateSentence(sentence); 33 | } 34 | 35 | @Override 36 | public List queryAllSentence() { 37 | return sentenceMapper.queryAllSentence(); 38 | } 39 | 40 | @Override 41 | public Sentence queryRandomSentence() { 42 | return sentenceMapper.queryRandomSentence(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/Impl/TaskServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.service.Impl; 2 | 3 | import com.example.mapper.TaskDetailMapper; 4 | import com.example.mapper.TaskMapper; 5 | import com.example.pojo.Task; 6 | import com.example.pojo.TaskDetail; 7 | import com.example.service.TaskService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.List; 12 | 13 | @Service 14 | public class TaskServiceImpl implements TaskService { 15 | @Autowired 16 | private TaskMapper taskMapper; 17 | 18 | @Autowired 19 | private TaskDetailMapper taskDetailMapper; 20 | 21 | @Override 22 | public Task queryTaskById(Integer taskId) { 23 | return taskMapper.queryTaskById(taskId); 24 | } 25 | 26 | @Override 27 | public int addTask(Task task) { 28 | return taskMapper.addTask(task); 29 | } 30 | 31 | @Override 32 | public int deleteTask(Integer taskId) { 33 | return taskMapper.deleteTask(taskId); 34 | } 35 | 36 | @Override 37 | public int updateTask(Task task) { 38 | return taskMapper.updateTask(task); 39 | } 40 | 41 | @Override 42 | public List queryAllTask() { 43 | return taskMapper.queryAllTask(); 44 | } 45 | 46 | @Override 47 | public List findByUserId(Integer userId) { 48 | return taskMapper.findByUserId(userId); 49 | } 50 | 51 | 52 | @Override 53 | public Integer countByTask(Task task) { 54 | return taskDetailMapper.countByTask(task); 55 | } 56 | 57 | @Override 58 | public void addTaskDetail(TaskDetail taskDetail) { 59 | try { 60 | taskDetailMapper.addTaskDetail(taskDetail); 61 | } catch (Exception e) { 62 | 63 | } 64 | } 65 | 66 | @Override 67 | public void deleteTaskDetail(Integer taskId, Integer businessId) { 68 | taskDetailMapper.deleteTaskDetailByTaskIdAndBusinessId(taskId, businessId); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/Impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.service.Impl; 2 | 3 | import com.example.mapper.UserMapper; 4 | import com.example.pojo.User; 5 | import com.example.service.UserService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | @Service 12 | public class UserServiceImpl implements UserService { 13 | @Autowired 14 | UserMapper userMapper; 15 | 16 | 17 | @Override 18 | public User queryUserById(int userId) { 19 | return userMapper.queryUserById(userId); 20 | } 21 | 22 | @Override 23 | public User queryUserByActiveCode(String activeCode) { 24 | return userMapper.queryUserByActiveCode(activeCode); 25 | } 26 | 27 | @Override 28 | public User loginByUserNameAndPasswordAndActiveStatus(User user) { 29 | return userMapper.loginByUserNameAndPasswordAndActiveStatus(user); 30 | } 31 | 32 | @Override 33 | public User AdminLogin(User user) { 34 | return userMapper.AdminLogin(user); 35 | } 36 | 37 | @Override 38 | public int addUser(User user) { 39 | return userMapper.addUser(user); 40 | } 41 | 42 | @Override 43 | public int deleteUser(Integer userId) { 44 | return userMapper.deleteUser(userId); 45 | } 46 | 47 | @Override 48 | public int updateUser(User user) { 49 | return userMapper.updateUser(user); 50 | } 51 | 52 | @Override 53 | public List queryAllUser() { 54 | return userMapper.queryAllUser(); 55 | } 56 | 57 | @Override 58 | public User findByUserName(String userName) { 59 | return userMapper.findByUserName(userName); 60 | } 61 | 62 | @Override 63 | public User findByUserNameAndEmail(User user) { 64 | return userMapper.findByUserNameAndEmail(user); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/Impl/WordServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.example.service.Impl; 2 | 3 | import com.example.mapper.WordMapper; 4 | import com.example.pojo.Grade; 5 | import com.example.pojo.Word; 6 | import com.example.service.WordService; 7 | import com.github.pagehelper.PageHelper; 8 | import com.github.pagehelper.PageInfo; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.List; 13 | 14 | @Service 15 | public class WordServiceImpl implements WordService { 16 | @Autowired 17 | private WordMapper wordMapper; 18 | 19 | @Override 20 | public int addWord(Word word) { 21 | return wordMapper.addWord(word); 22 | } 23 | 24 | @Override 25 | public int deleteWord(Integer wordId) { 26 | return wordMapper.deleteWord(wordId); 27 | } 28 | 29 | @Override 30 | public int updateWord(Word word) { 31 | return wordMapper.updateWord(word); 32 | } 33 | 34 | 35 | @Override 36 | public List queryAllWord() { 37 | return wordMapper.queryAllWord(); 38 | } 39 | 40 | @Override 41 | public Word queryWordById(Integer wordId) { 42 | return wordMapper.queryWordById(wordId); 43 | } 44 | 45 | @Override 46 | public List queryWordByName(String name) { 47 | return wordMapper.queryWordByName(name); 48 | } 49 | 50 | @Override 51 | public int queryAllWordNumberByGrade(Integer grade) { 52 | return wordMapper.queryAllWordNumberByGrade(grade); 53 | } 54 | 55 | @Override 56 | public List queryByGradeId(Integer gradeId, Integer limit) { 57 | return wordMapper.queryByGradeId(gradeId, limit); 58 | } 59 | 60 | @Override 61 | public List findByInitWord(String initWord, Integer limit) { 62 | return wordMapper.findByInitWord(initWord, limit); 63 | } 64 | 65 | @Override 66 | public Word getNext(Integer taskId) { 67 | return wordMapper.getNext(taskId); 68 | } 69 | 70 | @Override 71 | public List getAllGrade() { 72 | return wordMapper.getAllGrade(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/ListenService.java: -------------------------------------------------------------------------------- 1 | package com.example.service; 2 | 3 | import com.example.pojo.Grade; 4 | import com.example.pojo.Listen; 5 | import com.example.pojo.Word; 6 | 7 | import java.util.List; 8 | 9 | public interface ListenService { 10 | //根据ID查询一条听力的信息 11 | Listen queryListenById(Integer listenId); 12 | //增加一条听力 13 | int addListen(Listen listen); 14 | //删除一条听力 15 | int deleteListen(Integer listenId); 16 | //修改一条听力 17 | int updateListen(Listen listen); 18 | //查看所有听力所有信息 19 | List queryAllListen(); 20 | 21 | Integer countByGrade(Integer grade); 22 | 23 | Listen getNext(Integer taskId); 24 | 25 | List getAllGrade(); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/NoticeService.java: -------------------------------------------------------------------------------- 1 | package com.example.service; 2 | 3 | import com.example.pojo.Notice; 4 | 5 | import java.util.List; 6 | 7 | public interface NoticeService { 8 | //查询公告 9 | Notice queryNoticeById(Integer noticeId); 10 | //增加公告 11 | int addNotice(Notice notice); 12 | //删除公告 13 | int deleteNotice(Integer noticeId); 14 | //修改公告 15 | int updateNotice(Notice notice); 16 | //查看公告所有信息 17 | List queryAllNotice(); 18 | //查看最新公告的内容 19 | Notice queryNewNoticeById(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/SendEmail.java: -------------------------------------------------------------------------------- 1 | package com.example.service; 2 | 3 | public interface SendEmail { 4 | 5 | void SendEmail(String to, String subject, String content); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/SentenceService.java: -------------------------------------------------------------------------------- 1 | package com.example.service; 2 | 3 | import com.example.pojo.Sentence; 4 | 5 | import java.util.List; 6 | 7 | public interface SentenceService { 8 | //根据ID查询一条句子的信息 9 | Sentence querySentenceById(Integer sentenceId); 10 | //增加一条句子 11 | int addSentence(Sentence sentence); 12 | //删除一条句子 13 | int deleteSentence(Integer sentenceId); 14 | //修改一条句子 15 | int updateSentence(Sentence sentence); 16 | //查看所有句子所有信息 17 | List queryAllSentence(); 18 | //随机取一条句子 19 | Sentence queryRandomSentence(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/TaskService.java: -------------------------------------------------------------------------------- 1 | package com.example.service; 2 | 3 | import com.example.pojo.Task; 4 | import com.example.pojo.TaskDetail; 5 | 6 | import java.util.List; 7 | 8 | public interface TaskService { 9 | //根据ID查询一条进度的信息 10 | Task queryTaskById(Integer taskId); 11 | 12 | //增加进度 13 | int addTask(Task task); 14 | 15 | //删除进度 16 | int deleteTask(Integer taskId); 17 | 18 | //修改进度 19 | int updateTask(Task task); 20 | 21 | //查看进度所有信息 22 | List queryAllTask(); 23 | 24 | List findByUserId(Integer userId); 25 | 26 | Integer countByTask(Task task); 27 | 28 | /** 29 | * 添加 30 | * @param taskDetail 31 | */ 32 | void addTaskDetail(TaskDetail taskDetail); 33 | 34 | 35 | /** 36 | * 删除 37 | * @param taskId 38 | * @param businessId 39 | */ 40 | void deleteTaskDetail(Integer taskId, Integer businessId); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.example.service; 2 | 3 | import com.example.pojo.User; 4 | 5 | import java.util.List; 6 | 7 | public interface UserService { 8 | //根据Id查询用户 9 | User queryUserById(int userId); 10 | 11 | //根据激活码查询用户 12 | User queryUserByActiveCode(String activeCode); 13 | 14 | //根据邮箱密码与状态码登录 15 | User loginByUserNameAndPasswordAndActiveStatus(User user); 16 | 17 | //根据邮箱密码与Role=1登录 18 | User AdminLogin(User user); 19 | 20 | //增加用户 21 | int addUser(User user); 22 | 23 | //删除用户 24 | int deleteUser(Integer userId); 25 | 26 | // 修改用户 27 | int updateUser(User user); 28 | 29 | //查询用户 30 | List queryAllUser(); 31 | 32 | User findByUserName(String userName); 33 | 34 | User findByUserNameAndEmail(User user); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/example/service/WordService.java: -------------------------------------------------------------------------------- 1 | package com.example.service; 2 | 3 | import com.example.pojo.Grade; 4 | import com.example.pojo.Word; 5 | import com.github.pagehelper.PageInfo; 6 | 7 | import java.util.List; 8 | 9 | public interface WordService { 10 | 11 | 12 | //增加一个单词 13 | int addWord(Word word); 14 | 15 | //删除一个单词 16 | int deleteWord(Integer wordId); 17 | 18 | //修改一个单词 19 | int updateWord(Word word); 20 | 21 | //查询所有单词信息 22 | List queryAllWord(); 23 | 24 | //根据ID查询一个单词的信息 25 | Word queryWordById(Integer wordId); 26 | 27 | /** 28 | * 单词搜索 29 | * 30 | * @param name 31 | * @return 32 | */ 33 | List queryWordByName(String name); 34 | 35 | 36 | //根据grade查询单词数量 37 | int queryAllWordNumberByGrade(Integer grade); 38 | 39 | List queryByGradeId(Integer gradeId, Integer limit); 40 | 41 | /** 42 | * 首字母查询 43 | * 44 | * @param initWord 45 | * @return 46 | */ 47 | List findByInitWord(String initWord, Integer limit); 48 | 49 | Word getNext(Integer taskId); 50 | 51 | List getAllGrade(); 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/example/util/DataUtils.java: -------------------------------------------------------------------------------- 1 | package com.example.util; 2 | 3 | import org.springframework.stereotype.Controller; 4 | 5 | import java.text.NumberFormat; 6 | import java.text.ParseException; 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | 10 | @Controller 11 | public class DataUtils { 12 | 13 | //得到百分比数字 14 | public String percent(float remember,float number){ 15 | // 创建一个数值格式化对象 16 | NumberFormat numberFormat = NumberFormat.getInstance(); 17 | // 设置精确到整数位 18 | numberFormat.setMaximumFractionDigits(1); 19 | String format = numberFormat.format(remember / number/ 0.01)+"%"; 20 | return format; 21 | } 22 | //得到1-百分比数字 23 | public String unpercent(float remember,float number){ 24 | // 创建一个数值格式化对象 25 | NumberFormat numberFormat = NumberFormat.getInstance(); 26 | // 设置精确到整数位 27 | numberFormat.setMaximumFractionDigits(1); 28 | String format = numberFormat.format((1-remember / number)/0.01)+"%"; 29 | return format; 30 | } 31 | 32 | /** 33 | * 得到格式化日期 34 | */ 35 | public Date getDate() throws ParseException { 36 | //得到当前日期- 目前是英文的Date 37 | Date date = new Date(); 38 | 39 | //设置日期格式 40 | SimpleDateFormat format =new SimpleDateFormat("yyyy-MM-dd" ); 41 | //现在日期为yyyy-MM-dd,是String类型的 42 | String formatDate = format.format(date); 43 | //把String类型转为Date类型 44 | Date parse = format.parse(formatDate); 45 | 46 | return parse; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/example/util/IDUtils.java: -------------------------------------------------------------------------------- 1 | package com.example.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.util.UUID; 7 | 8 | public class IDUtils { 9 | public static final Logger logger = LoggerFactory.getLogger(IDUtils.class); 10 | 11 | public static String getUUID() { 12 | return UUID.randomUUID().toString().replace("-", ""); 13 | } 14 | 15 | public static void main(String[] args) { 16 | 17 | System.out.println(getUUID()); 18 | logger.debug("test"); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/example/util/JsonResult.java: -------------------------------------------------------------------------------- 1 | package com.example.util; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | *
 7 |  *     Json格式
 8 |  * 
9 | * 10 | * @author : saysky 11 | * @date : 2018/5/24 12 | */ 13 | @Data 14 | public class JsonResult { 15 | 16 | /** 17 | * 返回的状态码,0:失败,1:成功 18 | */ 19 | private Integer code; 20 | 21 | /** 22 | * 返回信息 23 | */ 24 | private String msg; 25 | 26 | /** 27 | * 返回的数据 28 | */ 29 | private Object result; 30 | 31 | /** 32 | * 不返回数据的构造方法 33 | * 34 | * @param code 状态码 35 | * @param msg 信息 36 | */ 37 | public JsonResult(Integer code, String msg) { 38 | this.code = code; 39 | this.msg = msg; 40 | } 41 | 42 | /** 43 | * 返回数据的构造方法 44 | * 45 | * @param code 状态码 46 | * @param msg 信息 47 | * @param result 数据 48 | */ 49 | public JsonResult(Integer code, String msg, Object result) { 50 | this.code = code; 51 | this.msg = msg; 52 | this.result = result; 53 | } 54 | 55 | /** 56 | * 返回状态码和数据 57 | * 58 | * @param code 状态码 59 | * @param result 数据 60 | */ 61 | public JsonResult(Integer code, Object result) { 62 | this.code = code; 63 | this.result = result; 64 | } 65 | 66 | public static JsonResult error(String msg) { 67 | return new JsonResult(0, msg); 68 | } 69 | public static JsonResult error(String msg, Object data) { 70 | return new JsonResult(0, msg, data); 71 | } 72 | public static JsonResult success() { 73 | return new JsonResult(1, "操作成功"); 74 | } 75 | 76 | public static JsonResult success(String msg) { 77 | return new JsonResult(1, msg); 78 | } 79 | 80 | public static JsonResult success(String msg, Object result) { 81 | return new JsonResult(1, msg, result); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/example/util/MathUtil.java: -------------------------------------------------------------------------------- 1 | package com.example.util; 2 | 3 | public class MathUtil { 4 | 5 | 6 | //a/b转百分数字符串 (double)Math.round( a/(double)b*1000)/1000:保留3位小数四舍五入 7 | public static String toPercent(int a,int b) { 8 | if (a%b==0) { 9 | return a/b*100+"%"; 10 | }else { 11 | return (double)Math.round( a/(double)b*1000)/10+"%"; 12 | } 13 | } 14 | 15 | //Object转整数(失败返回null) 16 | private Integer toInt(Object o) { 17 | if (o!=null && !"".equals(o.toString())) { 18 | try { 19 | int parseInt = Integer.parseInt(o.toString()); 20 | return parseInt; 21 | } catch (NumberFormatException e) { 22 | e.printStackTrace(); 23 | return null; 24 | } 25 | } 26 | return null; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | url: jdbc:mysql://localhost:3306/study_english?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8 4 | username: root 5 | password: 123456 6 | type: com.alibaba.druid.pool.DruidDataSource 7 | 8 | 9 | mvc: 10 | #配置它以后移动html页面就不用改路径了! 11 | static-path-pattern: /static/** #静态资源的请求方式 12 | resources: 13 | static-locations: classpath:/static/ # 静态资源的配置位置,可以写成一个数组配置多个目录 14 | 15 | mail: 16 | host: smtp.qq.com 17 | username: 847064370@qq.com # 邮箱地址 18 | password: XXXXX # 授权码 19 | properties: 20 | mail: 21 | smtp: 22 | ssl: 23 | enable: true 24 | 25 | thymeleaf: 26 | cache: false 27 | check-template-location: on 28 | prefix: classpath:/templates/ 29 | suffix: .html 30 | servlet: 31 | content-type: text/html 32 | 33 | devtools: 34 | restart: 35 | enabled: true 36 | 37 | mybatis: 38 | mapper-locations: classpath:mybatis/mapper/*.xml 39 | type-aliases-package: com.example.pojo 40 | configuration: 41 | map-underscore-to-camel-case: on #采用驼峰标识 42 | 43 | 44 | # pagehelper分页 45 | pagehelper: 46 | helperDialect: mysql 47 | reasonable: true 48 | supportMethodsArguments: true 49 | params: count=countSql 50 | 51 | server: 52 | port: 8080 53 | -------------------------------------------------------------------------------- /src/main/resources/mybatis/mapper/BookMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 16 | 19 | 20 | 21 | insert into book(bookName, bookUser,description,content,grade) values (#{bookName},#{bookUser},#{description},#{content},#{grade}); 22 | 23 | 24 | 25 | delete from book where bookId=#{bookId} 26 | 27 | 28 | 29 | update book set bookName=#{bookName},bookUser=#{bookUser},description=#{description},content=#{content},grade=#{grade} 30 | where bookId=#{bookId} 31 | 32 | 33 | 40 | 41 | 44 | -------------------------------------------------------------------------------- /src/main/resources/mybatis/mapper/GradeMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 16 | 17 | 18 | insert into grade(gradeId, gradeName) values (#{gradeId},#{gradeName}); 19 | 20 | 21 | 22 | delete from grade where gradeId=#{gradeId} 23 | 24 | 25 | 26 | update grade set gradeName=#{gradeName} 27 | where gradeId=#{gradeId} 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/main/resources/mybatis/mapper/ListenMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 16 | 19 | 20 | 21 | insert into listen(listenName,grade) values (#{listenName},#{grade},#{content}); 22 | 23 | 24 | 25 | delete from listen where listenId=#{listenId} 26 | 27 | 28 | 29 | update listen set listenName=#{listenName},grade=#{grade},content=#{content} 30 | where listenId=#{listenId} 31 | 32 | 33 | 34 | 41 | 42 | 43 | 46 | -------------------------------------------------------------------------------- /src/main/resources/mybatis/mapper/NoticeMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 16 | 17 | 18 | insert into notice(title, content,creatTime) values (#{title},#{content},#{creatTime}); 19 | 20 | 21 | 22 | delete from notice where noticeId=#{noticeId} 23 | 24 | 25 | 26 | update notice set title=#{title},content=#{content},creatTime=#{creatTime} 27 | where noticeId=#{noticeId} 28 | 29 | 30 | 31 | 34 | 35 | -------------------------------------------------------------------------------- /src/main/resources/mybatis/mapper/SentenceMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 16 | 17 | 18 | insert into sentence(sentenceName, explain) values (#{sentenceName},#{explain}); 19 | 20 | 21 | 22 | delete from sentence where sentenceId=#{sentenceId} 23 | 24 | 25 | 26 | update sentence set sentenceName=#{sentenceName},explain=#{explain} 27 | where sentenceId=#{sentenceId} 28 | 29 | 30 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/main/resources/mybatis/mapper/TaskDetailMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 16 | 17 | 35 | 36 | 37 | 38 | insert into task_detail(businessId, taskId) values (#{businessId},#{taskId}); 39 | 40 | 41 | 42 | delete from task_detail where id=#{id} 43 | 44 | 45 | delete from task_detail where businessId=#{businessId} AND taskId=#{taskId} 46 | 47 | 48 | 49 | update task_detail set businessId=#{businessId},taskId=#{taskId} 50 | where id=#{id} 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/main/resources/mybatis/mapper/TaskMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 16 | 19 | 20 | 21 | 22 | 23 | insert into task(name,type, grade, userId) values (#{name},#{type},#{grade},#{userId}); 24 | 25 | 26 | 27 | delete from task where id=#{id} 28 | 29 | 30 | 31 | update task set name=#{name},userId=#{userId},grade=#{grade},type=#{type} 32 | where id=#{id} 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/main/resources/mybatis/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | insert into user (userName, password, email, activeCode,activeStatus,role) values (#{userName},#{password},#{email},#{activeCode},#{activeStatus},#{role}); 10 | 11 | 12 | 13 | delete from user where userId=#{userId} 14 | 15 | 16 | 17 | update user set userName=#{userName}, activeStatus=#{activeStatus}, email=#{email},password=#{password},role=#{role} where userId=#{userId} ; 18 | 19 | 20 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 34 | 35 | 38 | 39 | 40 | 43 | 44 | 47 | 50 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/main/resources/mybatis/mapper/WordMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 13 | 14 | 15 | insert into word(wordName, audio, explanation, example, grade) values (#{wordName},#{audio},#{explanation},#{example},#{grade}); 16 | 17 | 18 | 23 | 24 | 25 | delete from word where wordId=#{wordId} 26 | 27 | 28 | 33 | 34 | 35 | update word set 36 | wordName=#{wordName},audio=#{audio},explanation=#{explanation},example=#{example},grade=#{grade} 37 | where wordId=#{wordId}; 38 | 39 | 40 | 45 | 46 | 49 | 50 | 51 | 54 | 55 | 56 | 59 | 60 | 61 | 67 | 73 | 80 | 81 | 84 | 87 | 88 | -------------------------------------------------------------------------------- /src/test/java/com/example/MyspringbootApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class MyspringbootApplicationTests { 8 | 9 | @Test 10 | void contextLoads() throws InterruptedException { 11 | 12 | 13 | 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /src/test/java/com/example/TestController.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | @Controller 7 | public class TestController { 8 | //测试MarkDown编辑器! 9 | @RequestMapping("/test") 10 | public String Test(){ 11 | System.out.println("进入TEST!!"); 12 | return "Test/ToHTMLTest"; 13 | } 14 | } 15 | --------------------------------------------------------------------------------