SpringBoot+Vue医院预约挂号系统 附带详细运行指导视频

文章目录

一、项目演示

项目演示地址: 视频地址

二、项目介绍

项目描述:这是一个基于SpringBoot+Vue框架 开发的医院预约挂号系统。首先,这是一个前后端分离的项目,代码简洁规范,注释说明详细,易于理解和学习。其次,这项目功能丰富,具有一个医院预约挂号系统该有的所有功能。

项目功能:此项目分为三个 角色:患者医生管理员患者 有登录注册、查看医生和科室信息、预约挂号、查看预约信息、查看就诊信息和医嘱、缴费就诊信息、查看个人病历、查看个人住院信息、缴费住院信息、查看个人检查报告信息、缴费检查报告信息、查看公告信息、修改个人信息等等功能。医生 有登录、查看个人数据统计信息、查看患者信息、查看医生信息、修改个人信息、查看管理员信息、查看科室信息、查看排班信息、管理本人收到的预约挂号信息、管理本人的就诊信息、管理本人创建的住院登记信息、管理本人负责的检查报告信息、查看公告信息等等功能。管理员有查看所有数据统计、管理所有患者信息、管理所有医生信息、管理所有管理员信息、管理所有科室信息、管理所有排班信息、管理所有预约挂号信息、管理所有就诊信息、管理所有住院信息、管理所有检查报告信息、管理所有公告信息等等功能。

应用技术:SpringBoot + Vue3.0 + MySQL + MyBatis + Redis + ElementUI-Plus + Vite

运行环境:IntelliJ IDEA2019.3.5 + MySQL5.7 + Redis5.0.5 + JDK1.8 + Maven3.6.3 + Node14.16.1 + Visual Studio Code(以上工具在项目压缩包中都自带)

三、运行截图

























四、主要代码

1.保存预约挂号代码

java 复制代码
 /**
   * 保存预约挂号信息
   * @param appointDTO
   * @return
   */
  @Override
  public ResponseDTO<Boolean> saveAppoint(AppointDTO appointDTO) {
      // 进行统一表单验证
      CodeMsg validate = ValidateEntityUtil.validate(appointDTO);
      if (!validate.getCode().equals(CodeMsg.SUCCESS.getCode())) {
          return ResponseDTO.errorByMsg(validate);
      }
      Appoint appoint = CopyUtil.copy(appointDTO, Appoint.class);
      if(CommonUtil.isEmpty(appoint.getId())) {
          // 添加操作
          // 判断是否已经预约
          AppointExample appointExample = new AppointExample();
          appointExample.createCriteria()
                  .andScheduleIdEqualTo(appoint.getScheduleId())
                  .andUserIdEqualTo(appoint.getUserId());
          if(appointMapper.countByExample(appointExample) > 0) {
              return ResponseDTO.errorByMsg(CodeMsg.APPOINT_EXIST);
          }
          // 判断预约挂号人数是否已满
          Schedule schedule = scheduleMapper.selectByPrimaryKey(appoint.getScheduleId());
          if(schedule.getNowNum() + 1 > schedule.getMaxNum()) {
              return ResponseDTO.errorByMsg(CodeMsg.APPOINT_NUM_NOT_ENOUGH);
          }
          appoint.setId(UuidUtil.getShortUuid());
          appoint.setCreateTime(new Date());
          if(appointMapper.insertSelective(appoint) == 0) {
              return ResponseDTO.errorByMsg(CodeMsg.APPOINT_ADD_ERROR);
          }
          schedule.setNowNum(schedule.getNowNum() + 1);
          scheduleMapper.updateByPrimaryKeySelective(schedule);
      } else {
          // 修改操作
          Appoint appointDB = appointMapper.selectByPrimaryKey(appoint.getId());
          if(appointDB == null) {
              return ResponseDTO.errorByMsg(CodeMsg.APPOINT_NOT_EXIST);
          }
          DoctorExample doctorExample = new DoctorExample();
          doctorExample.createCriteria().andUserIdEqualTo(appointDB.getDoctorId());
          List<Doctor> doctorList = doctorMapper.selectByExample(doctorExample);
          if(doctorList.size() == 0) {
              return ResponseDTO.errorByMsg(CodeMsg.APPOINT_DOCTOR_NOT_EXIST);
          }
          if(AppointStateEnum.CANCEL.getCode().equals(appointDB.getState())) {
              return ResponseDTO.errorByMsg(CodeMsg.APPOINT_CANCEL);
          }
          if(AppointStateEnum.YES.getCode().equals(appointDB.getState())) {
              return ResponseDTO.errorByMsg(CodeMsg.APPOINT_CALL);
          }
          if(appointMapper.updateByPrimaryKeySelective(appoint) == 0) {
              return ResponseDTO.errorByMsg(CodeMsg.APPOINT_EDIT_ERROR);
          }
          // 如果是取消,减少已预约数量
          if(AppointStateEnum.CANCEL.getCode().equals(appoint.getState())) {
              Schedule schedule = scheduleMapper.selectByPrimaryKey(appoint.getScheduleId());
              if(schedule != null) {
                  schedule.setNowNum(schedule.getNowNum() - 1);
                  scheduleMapper.updateByPrimaryKeySelective(schedule);
              }
          }
          // 如果是叫号,添加对应就诊信息
          if(AppointStateEnum.YES.getCode().equals(appoint.getState())) {
              Record record = new Record();
              record.setId(UuidUtil.getShortUuid());
              record.setCreateTime(new Date());
              record.setPrice(doctorList.get(0).getPrice());
              record.setPriceInfo("挂号费:" + doctorList.get(0).getPrice() + "元");
              record.setDoctorId(appointDB.getDoctorId());
              record.setUserId(appointDB.getUserId());
              recordMapper.insertSelective(record);
          }
      }
      return ResponseDTO.success(true);
  }

2.后台用户登录代码

java 复制代码
/**
 * 后台用户登录操作
 * @param userDTO
 * @return
 */
@Override
public ResponseDTO<UserDTO> adminLogin(UserDTO userDTO) {
    // 进行是否为空判断
    if(CommonUtil.isEmpty(userDTO.getPhone())){
        return ResponseDTO.errorByMsg(CodeMsg.PHONE_EMPTY);
    }
    if(CommonUtil.isEmpty(userDTO.getPassword())){
        return ResponseDTO.errorByMsg(CodeMsg.PASSWORD_EMPTY);
    }
    // 对比姓名和密码是否正确
    UserExample userExample = new UserExample();
    userExample.createCriteria()
            .andPhoneEqualTo(userDTO.getPhone())
            .andPasswordEqualTo(userDTO.getPassword())
            .andRoleIdEqualTo(userDTO.getRoleId());
    List<User> userList = userMapper.selectByExample(userExample);
    if(userList == null || userList.size() != 1){
        return ResponseDTO.errorByMsg(CodeMsg.PHONE_PASSWORD_ERROR);
    }
    // 生成登录token并存入Redis中
    UserDTO selectedUserDTO = CopyUtil.copy(userList.get(0), UserDTO.class);
    if(RoleEnum.DOCTOR.getCode().equals(selectedUserDTO.getRoleId())) {
        DoctorExample doctorExample = new DoctorExample();
        doctorExample.createCriteria().andUserIdEqualTo(selectedUserDTO.getId());
        List<Doctor> doctorList = doctorMapper.selectByExample(doctorExample);
        if(doctorList.size() > 0) {
            DoctorDTO doctorDTO = CopyUtil.copy(doctorList.get(0), DoctorDTO.class);
            Department department = departmentMapper.selectByPrimaryKey(doctorDTO.getDepartmentId());
            doctorDTO.setDepartmentDTO(CopyUtil.copy(department, DepartmentDTO.class));
            selectedUserDTO.setDoctorDTO(doctorDTO);
        }
    }
    String token = UuidUtil.getShortUuid();
    selectedUserDTO.setToken(token);
    //把token存入redis中 有效期1小时
    stringRedisTemplate.opsForValue().set("USER_" + token, JSON.toJSONString(selectedUserDTO), 3600, TimeUnit.SECONDS);
    return ResponseDTO.successByMsg(selectedUserDTO, "登录成功!");
}

3.前台医生页面代码

html 复制代码
<template>
  <div class="channel-container">
    <div
      v-for="(item, index) in departmentList"
      :key="index"
      @click="changeDepartment(item.id)"
      :class="
        'channel' +
        (item.id === searchParam.doctorDTO?.departmentId ? ' active' : '')
      "
      v-text="item.name"
    ></div>
  </div>
  <el-empty v-if="doctorList.length === 0" description="暂无数据🌻" />
  <div class="doctor-list">
    <div v-for="(item, index) in doctorList" class="card" :key="index">
      <img class="image" :src="filterPhoto(item.headPic)" />
      <div class="info">
        <div class="username" v-text="item.username"></div>
        <el-tag effect="dark" round type="primary">
          {{ item.doctorDTO.job }}
        </el-tag>
      </div>
      <div
        class="description"
        :title="item.doctorDTO.info"
        v-text="item.doctorDTO.info"
      ></div>
      <div class="price">
        <div class="label">挂号费:</div>
        <div class="value" v-text="'¥' + item.doctorDTO.price"></div>
      </div>
      <el-button type="primary" @click="openAppointDialog(item.id)"
        >挂号</el-button
      >
    </div>
    <Dialog
      ref="appointDialogRef"
      width="30%"
      title="预约挂号"
      @onConfirm="saveAppoint"
    >
      <template #content>
        <el-form :model="appointForm" v-loading="loading" label-width="100px">
          <el-form-item label="预约日期">
            <el-date-picker
              @change="changeAppointDate"
              :clearable="false"
              v-model="appointForm.appointDate"
              :disabled-date="disableBeforeToday"
              value-format="YYYY-MM-DD"
            />
          </el-form-item>
          <el-form-item label="预约时间">
            <el-select
              style="width: 220px"
              v-model="appointForm.appointTime"
              placeholder="请选择预约时间"
            >
              <template v-for="(item, index) in scheduleList" :key="index">
                <el-option v-if="item.workTime === 1" label="上午" :value="1" />
                <el-option v-if="item.workTime === 2" label="下午" :value="2" />
              </template>
            </el-select>
          </el-form-item>
          <el-form-item label="剩余数量">
            <div v-text="getRemainNum(appointForm.appointTime)"></div>
          </el-form-item>
        </el-form>
      </template>
    </Dialog>
  </div>
</template>
相关推荐
光影少年4 小时前
vue打包优化方案都有哪些?
前端·javascript·vue.js
似水流年,是谁苍白了等待5 小时前
Spring Boot + MyBatis plus + MySQL 实现位置直线距离实时计算
spring boot·mysql·mybatis
老华带你飞7 小时前
学生信息管理系统|基于Springboot的学生信息管理系统设计与实现(源码+数据库+文档)
java·数据库·spring boot·后端·论文·毕设·学生信息管理系统
FrankYoou8 小时前
Spring Boot 自动配置之 Spring transaction
java·spring boot·spring
木易 士心8 小时前
Ref 和 Reactive 响应式原理剖析与代码实现
前端·javascript·vue.js
被巨款砸中8 小时前
一篇文章讲清Prompt、Agent、MCP、Function Calling
前端·vue.js·人工智能·web
卷Java8 小时前
饼状图修复总结
java·spring boot·uni-app·echarts
散一世繁华,颠半世琉璃10 小时前
Prometheus+Grafana轻松实现SpringBoot应用监控
spring boot·grafana·prometheus
rggrgerj11 小时前
Vue3 组件完全指南代码
前端·javascript·vue.js