基于Spring MVC + Spring + MyBatis的医院就诊挂号系统

Posted 明金同学

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于Spring MVC + Spring + MyBatis的医院就诊挂号系统相关的知识,希望对你有一定的参考价值。

资源下载:https://download.csdn.net/download/weixin_44893902/21727306

一、语言和环境

1.实现语言: JAVA语言。
2.环境要求: MyEclipse/Eclipse + Tomcat + mysql
3.使用技术: Spring MVC + Spring + MyBatis 或 JSP + Servlet + JavaBean + JDBC。

二、实现效果


实现能够对患者姓名,医师类别、科室的模糊查询,用户点击核销以后状态变为已就诊。

点击挂号实现基本信息的添加

三、实现代码

数据库:

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for tb_patient
-- ----------------------------
DROP TABLE IF EXISTS `tb_patient`;
CREATE TABLE `tb_patient` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) DEFAULT NULL,
  `sex` varchar(10) DEFAULT NULL,
  `age` int(11) DEFAULT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `department` varchar(50) DEFAULT NULL,
  `type` varchar(50) DEFAULT NULL,
  `price` decimal(9,2) DEFAULT NULL,
  `state` int(11) DEFAULT NULL,
  `register_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of tb_patient
-- ----------------------------
INSERT INTO `tb_patient` VALUES ('1', '张蕾', '女', '12', '13895463212', '儿科', '专家医师', '25.00', '1', '2021-07-18 12:23:00');
INSERT INTO `tb_patient` VALUES ('2', '刘德明', '男', '28', '13345623215', '骨科', '普通医师', '8.00', '0', '2021-07-18 12:23:00');
INSERT INTO `tb_patient` VALUES ('3', '李将军', '男', '38', '13578064788', '内科', '专家医师', '25.00', '1', '2021-07-17 12:23:00');
INSERT INTO `tb_patient` VALUES ('4', '张佩佩', '女', '44', '18214217246', '外科', '副主任医师', '17.00', '0', '2021-07-16 12:23:00');
INSERT INTO `tb_patient` VALUES ('5', '程聪明', '男', '29', '13652645964', '骨科', '副主任医师', '17.00', '0', '2021-08-08 16:21:52');

项目Java代码:

目录结构

JAR包:

代码:

=src
> com.mhys.crm.controller
HospitalContrller.java
package com.mhys.crm.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mhys.crm.dao.TbPatientMapper;
import com.mhys.crm.entity.TbPatient;

@Controller
public class HospitalContrller {
	@Resource
	private TbPatientMapper tbPatientMapper;

	@RequestMapping("/select")
	public String getList(Model model) {
		List<TbPatient> selctAll = tbPatientMapper.selectAlls();
		System.out.println(selctAll);
		model.addAttribute("selctAll", selctAll);
		return "info";
	}

	@RequestMapping("/list")
	public String getAll(Model model, String name, String type, String dep) {
		List<TbPatient> selctAll = tbPatientMapper.selectAll(name, type, dep);
		System.out.println(name+"==="+type+"==="+dep);
		model.addAttribute("selctAll", selctAll);
		return "info";
	}

	@RequestMapping("/upd")
	public String upDev(Model model,int id) {
		int update = tbPatientMapper.update(id);
		return "redirect:/select.do";
	}
	
	@RequestMapping("/adds")
	public String adds(Model model) {
		return "addInfo";
	}
	
	@RequestMapping("/insert")
	public String toaddDev(Model model,TbPatient tb) {
		tbPatientMapper.insert(tb);
	    return "redirect:/select.do";
	}

}

> com.mhys.crm.dao
TbPatientMapper.java
package com.mhys.crm.dao;

import com.mhys.crm.entity.TbPatient;
import java.util.List;

import org.apache.ibatis.annotations.Param;

public interface TbPatientMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(TbPatient record);

    TbPatient selectByPrimaryKey(Integer id);

    List<TbPatient> selectAlls();

    int updateByPrimaryKey(TbPatient record);
    
    int update(Integer id);
    
    List<TbPatient> selectAll(@Param("name")String name,@Param("type")String type,@Param("dep")String dap);
}
TbPatientMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.mhys.crm.dao.TbPatientMapper" >
  <resultMap id="BaseResultMap" type="com.mhys.crm.entity.TbPatient" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="sex" property="sex" jdbcType="VARCHAR" />
    <result column="age" property="age" jdbcType="INTEGER" />
    <result column="phone" property="phone" jdbcType="VARCHAR" />
    <result column="department" property="department" jdbcType="VARCHAR" />
    <result column="type" property="type" jdbcType="VARCHAR" />
    <result column="price" property="price" jdbcType="DECIMAL" />
    <result column="state" property="state" jdbcType="INTEGER" />
    <result column="register_time" property="registerTime" jdbcType="TIMESTAMP" />
  </resultMap>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from tb_patient
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.mhys.crm.entity.TbPatient" >
    insert into tb_patient (id, name, sex, 
      age, phone, department, 
      type, price, state, 
      register_time)
    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{sex,jdbcType=VARCHAR}, 
      #{age,jdbcType=INTEGER}, #{phone,jdbcType=VARCHAR}, #{department,jdbcType=VARCHAR}, 
      #{type,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, #{state,jdbcType=INTEGER}, 
      #{registerTime,jdbcType=TIMESTAMP})
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.mhys.crm.entity.TbPatient" >
    update tb_patient
    set name = #{name,jdbcType=VARCHAR},
      sex = #{sex,jdbcType=VARCHAR},
      age = #{age,jdbcType=INTEGER},
      phone = #{phone,jdbcType=VARCHAR},
      department = #{department,jdbcType=VARCHAR},
      type = #{type,jdbcType=VARCHAR},
      price = #{price,jdbcType=DECIMAL},
      state = #{state,jdbcType=INTEGER},
      register_time = #{registerTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="selectAlls" resultMap="BaseResultMap" >
    select id, name, sex, age, phone, department, type, price, state, register_time
    from tb_patient
  </select>
  
  <select id="selectAll" resultMap="BaseResultMap" >
    select id, name, sex, age, phone, department, type, price, state, register_time
    from tb_patient
    <where>
    <if test="name!=null and name!=''">
    	and name = #{name}
    </if>
	<if test="type!=null and type!=''">
    	and type = #{type}
    </if>
    <if test="dep!=null and dep!=''">
    	and department = #{dep}
    </if>
    </where>
  </select>
  
  <update id="update" parameterType="com.mhys.crm.entity.TbPatient" >
    update tb_patient set state=1 where id = #{id,jdbcType=INTEGER}
  </update>
  
</mapper>
> com.mhys.crm.entity
TbPatient.java
package com.mhys.crm.entity;

import java.math.BigDecimal;
import java.util.Date;

public class TbPatient {
    private Integer id;

    private String name;

    private String sex;

    private Integer age;

    private String phone;

    private String department;

    private String type;

    private BigDecimal price;

    private Integer state;

    private Date registerTime;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex == null ? null : sex.trim();
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone == null ? null : phone.trim();
    }

    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department == null ? null : department.trim();
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type == null ? null : type.trim();
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Date getRegisterTime() {
        return registerTime;
    }

    public void setRegisterTime(Date registerTime) {
        this.registerTime = registerTime;
    }

	@Override
	public String toString() {
		return "TbPatient [id=" + id + ", name=" + name + ", sex=" + sex + ", age=" + age + ", phone=" + phone
				+ ", department=" + department + ", type=" + type + ", price=" + price + ", state=" + state
				+ ", registerTime=" + registerTime + "]";
	}
    
    
}
> com.mhys.crm.service.impl
HospitalService.java
package com.mhys.crm.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.ui.Model;
import Spring+Spring mvc+Mybatis整合教程(基于Maven)

Spring : 基于注解的 Spring MVC( 上 )

基于Spring MVC + Spring + MyBatis的医院就诊挂号系统

基于Spring MVC + Spring + MyBatis的医院就诊挂号系统

基于Spring MVC + Spring + MyBatis的网上购物系统

基于Spring MVC + Spring + MyBatis的银行卡系统