javaweb实现记单词网站

记单词网站设计文档

1.背景

下学期就要考四级了,就想自己设计一个可以记单词的程序,帮助提升自己的英语能力和编程能力。

2.系统功能的设计

2.1功能需求

  1. 类似词达人,可以根据中文意思,在四个英文单词中选择最佳答案,也可以根据英文选择中文
  2. 单词可以进行收藏,可以查看收藏夹和取消收藏
  3. 可以进行单词翻译,也可以通过中文模糊查找英文单词
  4. 能进行登录注册,修改密码功能(能进行注销账号)

2.2数据库表设计

  1. word单词表

    字段类型注释
    idint NOT NULLid 唯一且自增
    wordvarchar(20) NULL单词
    meaningvarchar(200) NULL中文翻译

    单词表的单词主要是四级词汇

  2. user用户表

    字段类型注释
    idint NOT NULLid 唯一且自增
    userNamevarchar(20) NULL用户名
    passwordvarchar(20) NULL密码
    newtableint NULL收藏表的序号
  3. 收藏表 ( 名称:newtable_? ,?为user表的newtable)

    表的属性一 word表一致。

    当用户注册时,会自动生成收藏表,可以通过用户的newtable查到该表

2.3实体类的设计

实体类与数据表一一对应,通过get,set方法进行访问内部数据

  1. User类,与数据表user对应
  2. Word类,与数据表Word对应
  3. NewTable类,与数据表newtable对应

2.4实现各个模块流程图

  1. 登录模块

    js判断注册密码是否符合规范

    登录时将用户的User类储存在Session中。

  2. 四选一模块

  3. 搜索查询模块

  4. 收藏夹模块

3.实现

3.1技术栈

前端:html,css,JavaScript,Bootstrap5(美化界面),jqurey。

后端:javaweb,Tomcat,maven

数据库:mysql

开发环境:java8,Tomcat9,maven3.8.5,mysql8.0

3.2项目结构

maven依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.example</groupId>
  <artifactId>loveword</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>

  <name>loveword Maven Webapp</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.5</version>
    </dependency>

    <dependency>
      <groupId>javax.servlet.jsp</groupId>
      <artifactId>javax.servlet.jsp-api</artifactId>
      <version>2.3.3</version>
    </dependency>

    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>8.0.28</version>
    </dependency>

    <dependency>
      <groupId>javax.servlet.jsp.jstl</groupId>
      <artifactId>jstl-api</artifactId>
      <version>1.2</version>
    </dependency>

    <dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>1.1.2</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>fastjson</artifactId>
      <version>1.2.75</version>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>5.8.2</version>
    </dependency>
  </dependencies>

</project>

3.3接口设计

  1. dao

    • UserDao

      public interface UserDao {
      
          //通过用户名获得用户信息
           User getUser(Connection connection, String userName) throws SQLException;
      
           //注册用户
          int registerUser(Connection connection ,String userName,String password,int num);
      
          //获得用户总数
          int getCount(Connection connection) throws SQLException;
      
          //更新密码
          int updatePwd(Connection connection ,int id,String newPwd);
      
          //用户注销
          int deleteUser(Connection connection,int id);
      
      }
      
    • WordDao

    public interface WordDao {
        //根据id返回查询单词
        Words getWord(Connection connection,int id) throws SQLException;
    
        //得到搜索的总单词数
        int getWordCount(Connection connection,String searchWord,String searchType) throws SQLException;
    
        //得到搜索的单词链表
        List<Words> getWordList(Connection connection,String searchWord,String searchType,int currentPageNo,int pageSize) throws SQLException;
    
    }
    
    
    • NewTableDao

      public interface NewTableDao {
          //创建新表
          int createTable(Connection connection,int num);
      
          //添加单词,收藏单词
          int addWords(Connection connection, int tableId, Words word);
      
          //取消收藏
          int deleteWords(Connection connection, int tableId, String word);
      
          //查询单词
          Words selectWord(Connection connection,int tableId , String word) throws SQLException;
      
          //得到收藏夹链表
          List<Words> getList(Connection connection,int tableId,int currentPageNo,int pageSize) throws SQLException;
      
          //得到单词总数
          int getWordsCount(Connection connection,int tableId) throws SQLException;
      
          //删除收藏表
          int deleteTable(Connection connection,int tableId);
      
      }
      
      
  2. service

    • UserService

      public interface UserService {
          //通过用户名获取用户数据
          User getUser(String userName);
      
          //用户注册
          boolean registerUser(String userName,String password,int num);
      
          //获取用户总数
          int getCount();
      
          //密码修改
          boolean updatePwd(int id,String newPwd);
      
          //注销用户
          boolean deleteUer(int id,int tableId);
      }
      
    • WordService

      public interface WordService {
          //根据id得到单词
          Words getWord(int id);
      
          //得到要查询单词的总数
      
          /**
           *
           * @param searchWord 要模糊搜索的单词,或中文意思
           * @param searchType 要搜索的单词类型,中译英,或者英译中
           * @return 总数
           */
          int getWordCount(String searchWord,String searchType);
      
          /**
           * 分页查询
           * @param currentPageNo 当前页数
           * @param pageSize 一页的长度
           * @return 查询的单词链表
           */
          List<Words> getWordList(String searchWord, String searchType, int currentPageNo, int pageSize);
      
      }
      
      
    • NewTableService

      public interface NewTableService {
          //创建收藏表
          boolean createTable(int num);
      
          //收藏单词
          boolean addWords(int tableId,int wordId);
      
          //取消收藏单词
          boolean deleteWord(int tableId,int wordId);
      
          //判断单词是否被收藏
          boolean judgeWord(int tableId,String word);
      
          //得到单词链表
          List<Words> getWordList(int tableId,int currentPageNo,int pageSize);
      
          //得到单词总数
          int getWordsCount(int tableId);
      
          //收藏表移除单词
          boolean removeWord(int tableId,String word);
      }
      

      4.效果

      在这里插入图片描述

      在这里插入图片描述
      在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值