如何使用ssm实现医学生在线学习交流平台+vue

216 篇文章 0 订阅
23 篇文章 0 订阅

@TOC

ssm100医学生在线学习交流平台+vue

JAVA简介

Java主要采用CORBA技术和安全模型,可以在互联网应用的数据保护。它还提供了对EJB(Enterprise JavaBeans)的全面支持,java servlet API,JSP(java server pages),和XML技术。JAVA语言是一种面向对象的语言,它通过提供最基本的方法来完成指定的任务,开发者只需要知道一些概念就能够编写出一些应用程序。Java程序相对较小,其代码能够在小机器上运行。Java是一种计算机编程语言,具有封装、继承和多态性三个主要特性,广泛应用于企业Web应用程序开发和移动应用程序开发。

Java语言和一般编译器以及直译的区别在于,Java首先将源代码转换为字节码,然后将其转换为JVM的可执行文件,JVM可以在各种不同的JVM上运行。因此,实现了它的跨平台特性。虽然这使得Java在早期非常缓慢,但是随着Java的开发,它已经得到了改进。

2.3 Tomcat服务器

Tomcat属于一种轻型的服务器,当程序员需要开发或调试JSP 程序时,则通常会将该服务器作为首选。对于一个仅具有计算机基础知识的人来说,计算机系统具有一个好的Apache服务器,可以很好的对HTML 页面进行访问。Tomcat 虽然是Apache的扩展,但是它们都是可以独立运行的,二者是不互相干扰的。当配置正确的时候,Apache服务器为HTML 页面的运行提供技术支持,Tomcat 的任务则是运行Servle和JSP 页面。Tomca也具有一定的HTML页面处理功能。

2.4 MySQL数据库

数据库是系统开发过程中不可或缺的一部分。 在WEB应用方面,MySQL AB开发了一个具有很大优势的MySQL关系数据库管理系统。 MySQL可以将数据存储在不同的表中,这非常灵活,并且还可以提高系统在实际应用中的速度。 数据库访问最常用于标准SQL语言,MySQL用于SQL语言,因此它具有高度兼容性。数据库的操作是必不可少的,包括对数据库表的增加、删除、修改、查询等功能。现如今,数据库可以分为关系型数据库和非关系型数据库,Mysql属于关系性数据库,Mysql数据库是一款小型的关系型数据库,它以其自身特点:体积小、速度快、成本低等,Mysql数据库是目前最受欢迎的开源数据库。

在WEB应用技术中, Mysql数据库支持不同的操作系统平台,虽然在不同平台下的安装和配置都不相同,但是差别也不是很大,Mysql在Windows平台下两种安装方式,二进制版和免安装版。安装完Mysql数据库之后,需要启动服务进程,相应的客户端就可以连接数据库,客户端可通过命令行或者图形界面工具登录数据库。

2.5 SSM框架

当今流行的“SSM组合框架”是Spring + SpringMVC + MyBatis的缩写,受到很多的追捧,“组合SSM框架”是强强联手、各司其职、协调互补的团队精神。web项目的框架,通常更简单的数据源。Spring属于一个轻量级的反转控制框架(IoC),但它也是一个面向表面的容器(AOP)。SpringMVC常常用于控制器的分类工作模式,与模型对象分开,程序对象的作用与自动取款机进行处理。这种解耦治疗使整个系统的个性化变得更加容易。MyBatis是一个良好的可持续性框架,支持普通SQL查询,同时允许对存储过程的高级映射进行数据的优化处理。大型Java Web应用程序的由于开发成本太高,开发后难以维护和开发过程中一些难以解决的问题,而采用“SSM组合框架”,它允许建立业务层次结构,并为这个问题提供良好的解决方案。

3 系统分析

3.1 可行性分析

3.1.1 技术可行性

技术可行性主要取决于系统设计和开发中使用的软硬件配置是否能满足应用要求,相关技术是否能保证系统设计完成后的正常运行。本网站在Windows操作系统中进行开发,并且目前PC机的性能已经可以胜任普通系统的web服务器。系统开发所使用的技术也都是自身所具有的,也是当下广泛应用的技术之一。

系统的开发环境和配置都是可以自行安装的,使用比较成熟的Mysql数据库进行对系统用户之间的数据交互,根据技术语言对数据库管理,结合需求进行修改维护,可以使得系统运行更具有稳定性和安全性,从而完成实现系统的开发。该系统目前采用比较成熟的JAVA技术,并利用其创建的脚本与结合创建动态网页。它可以在普通文本编辑器上编辑而无需编译,它可以直接在服务器上执行。它易于学习和操作,系统开发的基础是高度兼容和灵活的,从技术可行性上来分析系统开发时完全可行的。

3.1.2 经济可行性

医学生在线学习交流平台的开发之前所做的市场调研及其他管理相关的系统,是没有任何费用的,都是通过开发者自己的努力,所有的工作的都是自己亲力亲为,在碰到自己比较难以解决的问题,大多是通过同学和指导老师的帮助进行相关信息的解决,所以对于系统的开发在经济上是完全可行的,没有任何费用支出的。

使用比较成熟的技术,系统是基于Java的开发,采用Mysql数据库。所以系统在开发人力、财力要求不高,具有经济可行性。

3.1.3 操作可行性

可操作性主要是对系统设计完成后,用户的使用体验度,通过界面导航菜单可以简单明了地进行查看所需的信息内容。对于系统的操作,不需要专业人员都可以直接进行功能模块的操作管理,所以在系统的可操作性是完全可以的。本系统的操作使用的也是界面窗口进行登录,所以操作人员只要会简单的电脑操作就完全可以的。

3.2 项目设计目标与原则

1、关于医学生在线学习交流平台的基本要求

(1)功能要求:个人中心、用户管理、在线学习管理、试题管理、交流吧、试卷管理、系统管理等功能模块。

(2)性能:在不同操作系统上均能无差错实现在不同类型的用户登入相应界面后能不出差错、方便地进行预期操作。

(3)安全与保密要求:用户都必须通过身份验证才能进入系统,并且用户的权限也需要根据用户的类型进行限定。

(4)环境要求:支持多种平台,可在Windows系列、Vista系统等多种操作系统下使用。

2、设计原则

系统架构设计应反映用户与整个系统接口模块之间的有效交互,以确保系统中实时数据的可扩展性和安全性。只有系统设计才能实现这一目标。可以扩展功能模块以适应系统的未来发展。

在系统的所有功能模块中,必须要保证系统的数据安全性、易用性、柔软性和扩展性,下面分别对四个性能进行详细分析。

(1)数据的安全性

对于用户进行医学生在线学习交流平台所牵扯到的数据信息,必须保证系统数据的安全性,因此在系统设计过程中必须要有多方面的考虑到系统的安全问题并进行解决处理。

(2)易用性

对于易用性主要是对于系统实现完成交付给用户,用户是否可以不用培训就能够进行系统管理操作,也就是常说的傻瓜操作,一定简单明了,任何人都可以上手对数据信息进行操作管理。

(3)柔软性

对于任何一个系统的实现都会涉及的服务种类繁多,所以在设计时一定确保系统可以随时更改并且可以随时处理。

(4)扩展性

互联网的不断发展,对于系统实现的所有的功能随着用户需求的不断提高,功能模块也将要不断扩展。

由于这是一个医学生在线学习交流平台,系统的设计是为了更好地节省人员成本和各种成本,因此需要考虑系统开发成本和效益。

3.3 系统流程分析

3.3.1 操作流程

对于系统的安全性的第一关,就是用户想要进入系统,必须通过登录窗口,输入自己的登录信息才可以进行登录,用户输入的信息准确无误后才可以进入到操作系统界面,进行功能模块的相对应操作,如果用户输入的信息不正确,则窗口出现提示框,用户登录失败,返回到第一步进行重新输入,如图3-1所示。

图3-1注册流程图

3.3.2 添加信息流程

对于医学生在线学习交流平台,需要随时添加所需要的数据信息,对于用户添加信息,需要根据添加界面,根据选框的内容进行填写所要添加的数据信息,信息输入完成后判断数据信息是否符合要求,符合要求则添加完成,用户所添加的信息不符合要求,则需要返回到第一步,重新输入数据信息,再进行判断操作,如图3-2所示。

图3-2 添加信息流程图

3.4 系统功能需求分析

任意一个新网站的开发都需要完整的任务需求分析,需求分析的质量好坏决定了一个网站开发的意义,俗话说好的开头是成功的一半,对于医学生在线学习交流平台平台的设计与实现来说前期的分析更加显得尤为重要,任务分析决定了之后任务的开展和设计,只有完美的需求分析才能做出更好的让民众更为满意的网站,否则将会导致无法进行,更无法完成任务。

任务需求分析在整个系统开发的过程中是相当重要的一环,直接决定了开发过程中的软件质量,分析得是否完善,是否考虑到了每一步可能会出现的问题,这些都决定了软件能否正常运行,网站结构是否稳定,是否能让客户满意,需求分析决定了整个系统的框架、功能和要求。

4 系统设计

4.1系统结构设计

架构设计的目的是反映一个结构和其他元素之间的关系,抽象,通常用于指导大型软件系统。将一个巨大的任务细分为多个小任务的过程是系统架构的总体设计。完成小任务后,整个任务就可以完成了。具体的实现过程是分解系统,分析各部分的功能、接口和逻辑关系。页面是一个一个模块组建而成的,层次结构分明,思想运用的是面向对象,一个实体对应一个数据类型,还要对每个数据类添加一个实施类。

医学生在线学习交流平台的实现主要包括用户、和管理员两个用户角色,由于系统用户角色不同所使用的功能模块相应不同,管理员根据需求对系统功能模块进行维护管理操作。

根据我们对医学生在线学习交流平台的功能要求进行分析,我们将本系统划分为以下几各主要的模块,如图4-1所示。

图4-1 系统结构图

4.2数据库设计

4.2.1 数据库E-R图设计

学习编程,我们都知道数据库设计是基于需要设计的系统功能,我们需要建立一个数据库关系模型,用于存储数据信息,这样当我们在程序中时,就没有必要为程序页面添加数据,从而提高系统的效率。数据库存储了很多信息,可以说是信息管理系统的核心和基础,数据库还提供了添加、删除、修改和检查,使系统能够快速找到自己想要的信息,而不是在程序代码中找到。数据库中信息表的每个部分根据一定的关系精确地组合,排列和组合成数据表。

通过医学生在线学习交流平台的功能进行规划分成几个实体信息,实体信息将通过ER图进行说明,本系统的主要实体图如下:

(1)管理员数据E-R图,如图4-2所示:

图4-2 管理员信息实体属性图

(2)在线学习信息数据E-R图如图4-3所示:

图4-3在线学习信息实体属性图

(3试题信息数据E-R图如图4-4所示:

图4-4 试题信息实体属性图

(4)用户信息数据E-R图如图4-5所示:

图4-5 用户信息实体图

4.2.2 数据库表设计

将数据库概念设计的E-R图转换为关系数据库。在关系数据库中,数据关系由数据表组成,但是表的结构表现在表的字段上。

表4.1 config信息表

列名数据类型长度约束
IDbigint20PRIMARY KEY
namevarchar100DEFAULT NULL
biaotivarchar100DEFAULT NULL
valuevarchar200DEFAULT NULL

表4.2 discusszaixianxuexi信息表

列名数据类型长度约束
IDbigint20PRIMARY KEY
refidbigint20DEFAULT NULL
useridbigint20DEFAULT NULL
nicknamevarchar200DEFAULT NULL

表4.3 exampaper信息表

列名数据类型长度约束
IDbigint20PRIMARY KEY
namevarchar200DEFAULT NULL
timeint11DEFAULT NULL
status`int11DEFAULT NULL

表4.4 `examquestion信息表

列名数据类型长度约束
IDbigint20PRIMARY KEY
paperidbigint20DEFAULT NULL
papernamevarchar200DEFAULT NULL
questionnamevarchar200DEFAULT NULL
scorebigint20DEFAULT NULL
answervarchar200DEFAULT NULL
typebigint20DEFAULT NULL

表4.5 examrecord信息表

列名数据类型长度约束
IDbigint20PRIMARY KEY
useridbigint20DEFAULT NULL
usernamevarchar200DEFAULT NULL
paperidbigint20DEFAULT NULL
papernamevarchar200DEFAULT NULL
questionidbigint20DEFAULT NULL
questionnamevarchar200DEFAULT NULL
scorebigint20DEFAULT NULL
answervarchar200DEFAULT NULL
myscorebigint20DEFAULT NULL
myanswervarchar200DEFAULT NULL

表4.6 forum信息表

列名数据类型长度约束
IDbigint20PRIMARY KEY
titlevarchar200DEFAULT NULL
parentidbigint20DEFAULT NULL
useridbigint20DEFAULT NULL
usernamevarchar200DEFAULT NULL
isdonevarchar200DEFAULT NULL

表4.7 storeup信息表

列名数据类型长度约束
IDbigint20PRIMARY KEY
useridbigint20DEFAULT NULL
refidbigint20DEFAULT NULL
tablenamevarchar200DEFAULT NULL
namevarchar200DEFAULT NULL
picturevarchar200DEFAULT NULL

表4.8 token信息表

列名数据类型长度约束
IDbigint20PRIMARY KEY
useridvarchar100DEFAULT NULL
usernamevarchar100DEFAULT NULL
tablenamevarchar100DEFAULT NULL
rolevarchar100DEFAULT NULL
tokenvarchar200DEFAULT NULL

5 系统的实现

5.1登录界面设计

通过登录页面界面,通过登录页面进行输入用户名、密码、选择用户权限进行登录操作,如图5.1所示。

图5.1 系统首页界面

5.2前台功能模块

用户进入医学生在线学习交流平台可以查看网站首页、在线学习、交流吧、试卷列表、个人中心、后台管理等操作,系统前台主界面如图5-2所示。

图5-2 系统前台主界面

在线学习:通过列表可以获取课程名称、图片、课程类别、点击次数、视频、介绍、评论等信息,进行在线查看或点赞、收藏或在线评论操作,如图5-3所示。

图5-3在线学习界面

交流吧:通过页面可以在线帖子标题、发布时间等信息,进行在线查看或发布帖子操作,如图5-4所示。用户通过点击发布帖子进行输入标题、类型、内容等信息,进行在线发布帖子操作,如图5-5所示。

图5-4交流吧界面

图5-5发布帖子界面

试卷列表:通过列表可以获取试卷名称、考试时长、创建时间等信息,进行在线查看或考试操作,如图5-6所示。

图5-6试卷列表界面

个人中心:可以进行获取个人中心、我的发布、考试记录、错题本、我的收藏等功能模块,进行相对应操作,个人中心:通过列表可以获取在线输入账号、密码、姓名、性别、手机、邮箱、身份证等信息,进行在线修改更新个人信息操作,如图5-7所示。

图5-7个人信息界面

我的发布:可以进行获取标题、发布时间等信息,进行在线修改或删除操作,如图5-8所示。

图5-8我的发布界面

错题本:可以进行获取试卷名称、试题、分值、正常答案、考生答案、考试得分等信息,进行在线修改或删除操作,如图5-9所示。

图5-9我的错题界面

5.3用户后台功能模块

用户通过后台系统可以进行查看个人中心、在线学习管理、考试管理等功能模块,进行相对应操作。

个人信息:通过列表可以在线输入账号、姓名、头像、性别、联系电话等信息,进行在线修改操作,如图5-10所示。

图5-10个人信息界面

在线学习管理:通过列表可以获取课程名称、课程编号、课程类别、课程封面、课程详情等信息,进行在线查看详细信息、新增或修改、查看评论或删除操作,如图5-11所示。

图5-11在线学习管理界面

错题本:通过列表可以获取用户ID、试卷、试题名称、分值、正确答案、考生答案、试题分析、考试时间等信息,进行在线查看详细信息或在线支付操作,如图5-12所示。

图5-12错题本管理界面

5.4管理员功能模块

管理员通过登录窗口进行输入自己的账号信息进行在线登录,登录完成后可以对个人中心、用户管理、在线学习管理、试题管理、交流吧、试卷管理、系统管理等功能模块进行在线编辑或者删除等操作。

用户管理,管理员根据需求可以在线查看系统已有的账号、姓名、性别、头像、联系电话、联系邮箱等信息,并结合需求进行在线查看详情、修改或者删除等操作,并通过输入姓名、性别进行查询,如图5-13所示。

图5-13用户管理界面

在线学习管理:通过列表可以获取课程名称、课程编号、课程类别、课程封面、课程详情等信息,进行在线查看详细信息、新增或修改、修改或删除操作,如图5-14所示。

图5-14在线学习管理界面

试题管理:通过列表可以获取试卷、试题名称、分值、答案、类型等信息,进行在线查看详细信息、新增修改、删除操作。如图5-15所示。

图5-15试题管理界面

试卷管理:通过列表可以获取试卷名称、考试时长、试卷状态等信息,进行在线查看、新增、修改、删除操作,并通过输入试卷名称进行查询。如图5-16所示。

图5-16试卷管理界面

轮播图管理:通过列表可以获取名称、值等信息,进行查看详情、新增、修改、删除操作。并通过输入名称进行查询,如图5-17所示。

图5-17轮播图管理界面

6 系统测试

系统测

ExamquestionController.java
package com.controller;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;

import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;

import com.entity.ExamquestionEntity;
import com.entity.view.ExamquestionView;

import com.service.ExamquestionService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;


/**
 * 试题表
 * 后端接口
 * @author 
 * @email 
 * @date 2021-03-22 15:27:19
 */
@RestController
@RequestMapping("/examquestion")
public class ExamquestionController {
    @Autowired
    private ExamquestionService examquestionService;
    


    /**
     * 后端列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,ExamquestionEntity examquestion, 
		HttpServletRequest request){

        EntityWrapper<ExamquestionEntity> ew = new EntityWrapper<ExamquestionEntity>();
		PageUtils page = examquestionService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, examquestion), params), params));
        return R.ok().put("data", page);
    }
    
    /**
     * 前端列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params,ExamquestionEntity examquestion, HttpServletRequest request){
        EntityWrapper<ExamquestionEntity> ew = new EntityWrapper<ExamquestionEntity>();
		PageUtils page = examquestionService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, examquestion), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/lists")
    public R list( ExamquestionEntity examquestion){
       	EntityWrapper<ExamquestionEntity> ew = new EntityWrapper<ExamquestionEntity>();
      	ew.allEq(MPUtil.allEQMapPre( examquestion, "examquestion")); 
        return R.ok().put("data", examquestionService.selectListView(ew));
    }

	 /**
     * 查询
     */
    @RequestMapping("/query")
    public R query(ExamquestionEntity examquestion){
        EntityWrapper< ExamquestionEntity> ew = new EntityWrapper< ExamquestionEntity>();
 		ew.allEq(MPUtil.allEQMapPre( examquestion, "examquestion")); 
		ExamquestionView examquestionView =  examquestionService.selectView(ew);
		return R.ok("查询试题表成功").put("data", examquestionView);
    }
	
    /**
     * 后端详情
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        ExamquestionEntity examquestion = examquestionService.selectById(id);
        return R.ok().put("data", examquestion);
    }

    /**
     * 前端详情
     */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id){
        ExamquestionEntity examquestion = examquestionService.selectById(id);
        return R.ok().put("data", examquestion);
    }
    



    /**
     * 后端保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody ExamquestionEntity examquestion, HttpServletRequest request){
    	examquestion.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(examquestion);

        examquestionService.insert(examquestion);
        return R.ok();
    }
    
    /**
     * 前端保存
     */
    @RequestMapping("/add")
    public R add(@RequestBody ExamquestionEntity examquestion, HttpServletRequest request){
    	examquestion.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(examquestion);

        examquestionService.insert(examquestion);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody ExamquestionEntity examquestion, HttpServletRequest request){
        //ValidatorUtils.validateEntity(examquestion);
        examquestionService.updateById(examquestion);//全部更新
        return R.ok();
    }
    

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        examquestionService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
    
    /**
     * 提醒接口
     */
	@RequestMapping("/remind/{columnName}/{type}")
	public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, 
						 @PathVariable("type") String type,@RequestParam Map<String, Object> map) {
		map.put("column", columnName);
		map.put("type", type);
		
		if(type.equals("2")) {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			Calendar c = Calendar.getInstance();
			Date remindStartDate = null;
			Date remindEndDate = null;
			if(map.get("remindstart")!=null) {
				Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
				c.setTime(new Date()); 
				c.add(Calendar.DAY_OF_MONTH,remindStart);
				remindStartDate = c.getTime();
				map.put("remindstart", sdf.format(remindStartDate));
			}
			if(map.get("remindend")!=null) {
				Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
				c.setTime(new Date());
				c.add(Calendar.DAY_OF_MONTH,remindEnd);
				remindEndDate = c.getTime();
				map.put("remindend", sdf.format(remindEndDate));
			}
		}
		
		Wrapper<ExamquestionEntity> wrapper = new EntityWrapper<ExamquestionEntity>();
		if(map.get("remindstart")!=null) {
			wrapper.ge(columnName, map.get("remindstart"));
		}
		if(map.get("remindend")!=null) {
			wrapper.le(columnName, map.get("remindend"));
		}


		int count = examquestionService.selectCount(wrapper);
		return R.ok().put("count", count);
	}
	


}

YonghuController.java
package com.controller;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;

import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;

import com.entity.YonghuEntity;
import com.entity.view.YonghuView;

import com.service.YonghuService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;


/**
 * 用户
 * 后端接口
 * @author 
 * @email 
 * @date 2021-03-22 15:27:19
 */
@RestController
@RequestMapping("/yonghu")
public class YonghuController {
    @Autowired
    private YonghuService yonghuService;
    
	@Autowired
	private TokenService tokenService;
	
	/**
	 * 登录
	 */
	@IgnoreAuth
	@RequestMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", username));
		if(user==null || !user.getMima().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(), username,"yonghu",  "用户" );
		return R.ok().put("token", token);
	}
	
	/**
     * 注册
     */
	@IgnoreAuth
    @RequestMapping("/register")
    public R register(@RequestBody YonghuEntity yonghu){
    	//ValidatorUtils.validateEntity(yonghu);
    	YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", yonghu.getZhanghao()));
		if(user!=null) {
			return R.error("注册用户已存在");
		}
		Long uId = new Date().getTime();
		yonghu.setId(uId);
        yonghuService.insert(yonghu);
        return R.ok();
    }
	
	/**
	 * 退出
	 */
	@RequestMapping("/logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        YonghuEntity user = yonghuService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setMima("123456");
        yonghuService.updateById(user);
        return R.ok("密码已重置为:123456");
    }


    /**
     * 后端列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,YonghuEntity yonghu, 
		HttpServletRequest request){

        EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
		PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params));
        return R.ok().put("data", page);
    }
    
    /**
     * 前端列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params,YonghuEntity yonghu, HttpServletRequest request){
        EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
		PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/lists")
    public R list( YonghuEntity yonghu){
       	EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
      	ew.allEq(MPUtil.allEQMapPre( yonghu, "yonghu")); 
        return R.ok().put("data", yonghuService.selectListView(ew));
    }

	 /**
     * 查询
     */
    @RequestMapping("/query")
    public R query(YonghuEntity yonghu){
        EntityWrapper< YonghuEntity> ew = new EntityWrapper< YonghuEntity>();
 		ew.allEq(MPUtil.allEQMapPre( yonghu, "yonghu")); 
		YonghuView yonghuView =  yonghuService.selectView(ew);
		return R.ok("查询用户成功").put("data", yonghuView);
    }
	
    /**
     * 后端详情
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        YonghuEntity yonghu = yonghuService.selectById(id);
        return R.ok().put("data", yonghu);
    }

    /**
     * 前端详情
     */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id){
        YonghuEntity yonghu = yonghuService.selectById(id);
        return R.ok().put("data", yonghu);
    }
    



    /**
     * 后端保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
    	yonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(yonghu);
    	YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", yonghu.getZhanghao()));
		if(user!=null) {
			return R.error("用户已存在");
		}

		yonghu.setId(new Date().getTime());
        yonghuService.insert(yonghu);
        return R.ok();
    }
    
    /**
     * 前端保存
     */
    @RequestMapping("/add")
    public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
    	yonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(yonghu);
    	YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", yonghu.getZhanghao()));
		if(user!=null) {
			return R.error("用户已存在");
		}

		yonghu.setId(new Date().getTime());
        yonghuService.insert(yonghu);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
        //ValidatorUtils.validateEntity(yonghu);
        yonghuService.updateById(yonghu);//全部更新
        return R.ok();
    }
    

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        yonghuService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
    
    /**
     * 提醒接口
     */
	@RequestMapping("/remind/{columnName}/{type}")
	public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, 
						 @PathVariable("type") String type,@RequestParam Map<String, Object> map) {
		map.put("column", columnName);
		map.put("type", type);
		
		if(type.equals("2")) {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			Calendar c = Calendar.getInstance();
			Date remindStartDate = null;
			Date remindEndDate = null;
			if(map.get("remindstart")!=null) {
				Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
				c.setTime(new Date()); 
				c.add(Calendar.DAY_OF_MONTH,remindStart);
				remindStartDate = c.getTime();
				map.put("remindstart", sdf.format(remindStartDate));
			}
			if(map.get("remindend")!=null) {
				Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
				c.setTime(new Date());
				c.add(Calendar.DAY_OF_MONTH,remindEnd);
				remindEndDate = c.getTime();
				map.put("remindend", sdf.format(remindEndDate));
			}
		}
		
		Wrapper<YonghuEntity> wrapper = new EntityWrapper<YonghuEntity>();
		if(map.get("remindstart")!=null) {
			wrapper.ge(columnName, map.get("remindstart"));
		}
		if(map.get("remindend")!=null) {
			wrapper.le(columnName, map.get("remindend"));
		}


		int count = yonghuService.selectCount(wrapper);
		return R.ok().put("count", count);
	}
	


}

DiscusszaixianxuexiController.java
package com.controller;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;

import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;

import com.entity.DiscusszaixianxuexiEntity;
import com.entity.view.DiscusszaixianxuexiView;

import com.service.DiscusszaixianxuexiService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;


/**
 * 在线学习评论表
 * 后端接口
 * @author 
 * @email 
 * @date 2021-03-22 15:27:19
 */
@RestController
@RequestMapping("/discusszaixianxuexi")
public class DiscusszaixianxuexiController {
    @Autowired
    private DiscusszaixianxuexiService discusszaixianxuexiService;
    


    /**
     * 后端列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,DiscusszaixianxuexiEntity discusszaixianxuexi, 
		HttpServletRequest request){

        EntityWrapper<DiscusszaixianxuexiEntity> ew = new EntityWrapper<DiscusszaixianxuexiEntity>();
		PageUtils page = discusszaixianxuexiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discusszaixianxuexi), params), params));
        return R.ok().put("data", page);
    }
    
    /**
     * 前端列表
     */
	@IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params,DiscusszaixianxuexiEntity discusszaixianxuexi, HttpServletRequest request){
        EntityWrapper<DiscusszaixianxuexiEntity> ew = new EntityWrapper<DiscusszaixianxuexiEntity>();
		PageUtils page = discusszaixianxuexiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discusszaixianxuexi), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/lists")
    public R list( DiscusszaixianxuexiEntity discusszaixianxuexi){
       	EntityWrapper<DiscusszaixianxuexiEntity> ew = new EntityWrapper<DiscusszaixianxuexiEntity>();
      	ew.allEq(MPUtil.allEQMapPre( discusszaixianxuexi, "discusszaixianxuexi")); 
        return R.ok().put("data", discusszaixianxuexiService.selectListView(ew));
    }

	 /**
     * 查询
     */
    @RequestMapping("/query")
    public R query(DiscusszaixianxuexiEntity discusszaixianxuexi){
        EntityWrapper< DiscusszaixianxuexiEntity> ew = new EntityWrapper< DiscusszaixianxuexiEntity>();
 		ew.allEq(MPUtil.allEQMapPre( discusszaixianxuexi, "discusszaixianxuexi")); 
		DiscusszaixianxuexiView discusszaixianxuexiView =  discusszaixianxuexiService.selectView(ew);
		return R.ok("查询在线学习评论表成功").put("data", discusszaixianxuexiView);
    }
	
    /**
     * 后端详情
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        DiscusszaixianxuexiEntity discusszaixianxuexi = discusszaixianxuexiService.selectById(id);
        return R.ok().put("data", discusszaixianxuexi);
    }

    /**
     * 前端详情
     */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id){
        DiscusszaixianxuexiEntity discusszaixianxuexi = discusszaixianxuexiService.selectById(id);
        return R.ok().put("data", discusszaixianxuexi);
    }
    



    /**
     * 后端保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DiscusszaixianxuexiEntity discusszaixianxuexi, HttpServletRequest request){
    	discusszaixianxuexi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(discusszaixianxuexi);

        discusszaixianxuexiService.insert(discusszaixianxuexi);
        return R.ok();
    }
    
    /**
     * 前端保存
     */
    @RequestMapping("/add")
    public R add(@RequestBody DiscusszaixianxuexiEntity discusszaixianxuexi, HttpServletRequest request){
    	discusszaixianxuexi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(discusszaixianxuexi);

        discusszaixianxuexiService.insert(discusszaixianxuexi);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DiscusszaixianxuexiEntity discusszaixianxuexi, HttpServletRequest request){
        //ValidatorUtils.validateEntity(discusszaixianxuexi);
        discusszaixianxuexiService.updateById(discusszaixianxuexi);//全部更新
        return R.ok();
    }
    

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        discusszaixianxuexiService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
    
    /**
     * 提醒接口
     */
	@RequestMapping("/remind/{columnName}/{type}")
	public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, 
						 @PathVariable("type") String type,@RequestParam Map<String, Object> map) {
		map.put("column", columnName);
		map.put("type", type);
		
		if(type.equals("2")) {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			Calendar c = Calendar.getInstance();
			Date remindStartDate = null;
			Date remindEndDate = null;
			if(map.get("remindstart")!=null) {
				Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
				c.setTime(new Date()); 
				c.add(Calendar.DAY_OF_MONTH,remindStart);
				remindStartDate = c.getTime();
				map.put("remindstart", sdf.format(remindStartDate));
			}
			if(map.get("remindend")!=null) {
				Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
				c.setTime(new Date());
				c.add(Calendar.DAY_OF_MONTH,remindEnd);
				remindEndDate = c.getTime();
				map.put("remindend", sdf.format(remindEndDate));
			}
		}
		
		Wrapper<DiscusszaixianxuexiEntity> wrapper = new EntityWrapper<DiscusszaixianxuexiEntity>();
		if(map.get("remindstart")!=null) {
			wrapper.ge(columnName, map.get("remindstart"));
		}
		if(map.get("remindend")!=null) {
			wrapper.le(columnName, map.get("remindend"));
		}


		int count = discusszaixianxuexiService.selectCount(wrapper);
		return R.ok().put("count", count);
	}
	


}

base.js
const base = {
    get() {
                return {
            url : "http://localhost:8080/ssm2236x/",
            name: "ssm2236x",
            // 退出到首页链接
            indexUrl: 'http://localhost:8080/ssm2236x/front/index.html'
        };
            },
    getProjectName(){
        return {
            projectName: "医学生在线学习交流平台"
        } 
    }
}
export default base

声明

本博客适用于广泛的学术和教育用途,包括但不限于个人学习、开发设计,产品设计。仅供学习参考,旨在为读者提供深入理解和学术研究的材料。

  • 6
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值