当前位置: 首页 > article >正文

患者根据医生编号完成绑定和解绑接口

医疗系统接口文档

一、Controller 层

1. InstitutionDoctorController

医疗机构和医生相关的控制器,提供机构查询、医生查询、绑定解绑医生等功能。

@RestController
@RequestMapping("/institution-doctor")
public class InstitutionDoctorController {@Autowiredprivate InstitutionService institutionService;@Autowiredprivate DoctorService doctorService;@Autowiredprivate ClientService clientService;@GetMapping("/listInstitution/{institutionCategoryId}")public Result<List<Institution>> getInstitutionList(@PathVariable Long institutionCategoryId) {List<Institution> institutionList = institutionService.getInstitutionByInstitutionCategoryId(institutionCategoryId);return Result.success(institutionList);}@GetMapping("/listDoctor")public Result<List<User>> getDoctorList(@RequestParam String institution) {List<User> doctorList = doctorService.getDoctorByInstitutionName(institution);return Result.success(doctorList);}@PatchMapping("/bindDoctorByDoctorNumber")public Result<Boolean> bindDoctorByDoctorNumber(@PathVariable BindDoctorDto bindDoctorDto){boolean result = clientService.bindDoctorByDoctorNumber(bindDoctorDto);return Result.success(result);}@PatchMapping("/unbindDoctorByDoctorNumber")public Result<Boolean> unbindDoctorByDoctorNumber(@PathVariable BindDoctorDto bindDoctorDto){boolean result = clientService.unbindDoctorByDoctorNumber(bindDoctorDto);return Result.success(result);}@GetMapping("/getDoctorMsg/{doctorNumber}")public Result<UserVO> getDoctorMsg(@RequestParam int doctorNumber){UserVO doctorMsg = doctorService.getDoctorMsg(doctorNumber);return Result.success(doctorMsg);}
}

二、Service 接口

1. DoctorService

医生服务接口,提供获取医生信息的方法。

public interface DoctorService extends IService<User> {List<User> getDoctorByInstitutionName(String institution);UserVO getDoctorMsg(int doctorNumber);
}

2. ClientService

客户服务接口,提供客户与医生绑定和解绑的功能。

public interface ClientService extends IService<Client> {boolean bindDoctorByDoctorNumber(BindDoctorDto bindDoctorDto);boolean unbindDoctorByDoctorNumber(BindDoctorDto bindDoctorDto);
}

3. InstitutionService

医疗机构服务接口,提供获取机构列表的功能。

public interface InstitutionService extends IService<Institution>{List<Institution> getInstitutionByInstitutionCategoryId(Long institutionCategoryId);
}

三、Service 实现类

1. DoctorServiceImpl

@Service
public class DoctorServiceImpl extends ServiceImpl<UserMapper, User> implements DoctorService {@Autowiredprivate UserMapper userMapper;private static final String Institution = "institution";@Overridepublic List<User> getDoctorByInstitutionName(String institution) {QueryWrapper<User> queryWrapper = new QueryWrapper<>();queryWrapper.eq(Institution,institution);return userMapper.selectList(queryWrapper);}@Overridepublic UserVO getDoctorMsg(int doctorNumber) {LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();queryWrapper.eq(User::getNumber, doctorNumber);// 查询数据库User doctor = userMapper.selectOne(queryWrapper);if (doctor == null) {throw new BusinessException(InstitutionDoctorEnum.DOCTOR_NOT_EXIST.getCode(),InstitutionDoctorEnum.DOCTOR_NOT_EXIST.getMessage());}UserVO userVO = new UserVO();BeanUtils.copyProperties(doctor, userVO);return userVO;}
}

2. ClientServiceImpl

@Service
public class ClientServiceImpl extends ServiceImpl<ClientMapper, Client> implements ClientService {@Autowiredprivate ClientMapper clientMapper;@Autowiredprivate UserMapper userMapper;@Autowiredprivate PatientMapper patientMapper;private static final String NUMBER = "number";private static final String UUID = "uuid";private static final int DEFAULT_DOCTOR_NUMBER = 887375;// 绑定医生@Overridepublic boolean bindDoctorByDoctorNumber(BindDoctorDto bindDoctorDto){String clientUuid = bindDoctorDto.getUuid();int doctorNumber = bindDoctorDto.getDoctorNumber();// 1. 查询医生User doctor = userMapper.selectOne(new QueryWrapper<User>().eq(NUMBER, doctorNumber));if (doctor == null) {throw new BusinessException(InstitutionDoctorEnum.DOCTOR_NOT_EXIST.getCode(),InstitutionDoctorEnum.DOCTOR_NOT_EXIST.getMessage());}// 2. 查询 clientClient client = clientMapper.selectOne(new QueryWrapper<Client>().eq(UUID, clientUuid));if (client == null) {throw new BusinessException(InstitutionDoctorEnum.CLIENT_NOT_EXIST.getCode(),InstitutionDoctorEnum.CLIENT_NOT_EXIST.getMessage());}// 3. 查询 patientPatient patient = patientMapper.selectOne(new QueryWrapper<Patient>().eq(UUID, clientUuid));if (patient == null) {throw new BusinessException(InstitutionDoctorEnum.Patient_NOT_EXIST.getCode(),InstitutionDoctorEnum.Patient_NOT_EXIST.getMessage());}// 4. 校验当前医生是否可覆盖Integer currentDoctorNumber = patient.getDoctorNumber();if (currentDoctorNumber != null) {User currentDoctor = userMapper.selectOne(new QueryWrapper<User>().eq(NUMBER, currentDoctorNumber));if (currentDoctor != null && currentDoctor.getRole() != 1) {throw new BusinessException(InstitutionDoctorEnum.DOCTOR_ALREADY_BOUND.getCode(),InstitutionDoctorEnum.DOCTOR_ALREADY_BOUND.getMessage());}}// 5. 更新绑定patient.setDoctorNumber(doctorNumber);int update = patientMapper.update(patient,new UpdateWrapper<Patient>().eq(UUID, patient.getUuid()));if (update <= 0) {throw new BusinessException(InstitutionDoctorEnum.BIND_UPDATE_FAILED.getCode(),InstitutionDoctorEnum.BIND_UPDATE_FAILED.getMessage());}return true;}@Overridepublic boolean unbindDoctorByDoctorNumber(BindDoctorDto bindDoctorDto) {String clientUuid = bindDoctorDto.getUuid();Patient patient = patientMapper.selectOne(new QueryWrapper<Patient>().eq(UUID, clientUuid));if (patient == null) {throw new BusinessException(InstitutionDoctorEnum.Patient_NOT_EXIST.getCode(),InstitutionDoctorEnum.Patient_NOT_EXIST.getMessage());}patient.setDoctorNumber(DEFAULT_DOCTOR_NUMBER);int update = patientMapper.update(patient,new UpdateWrapper<Patient>().eq(UUID, clientUuid));if (update <= 0) {throw new BusinessException(InstitutionDoctorEnum.BIND_UPDATE_FAILED.getCode(),InstitutionDoctorEnum.BIND_UPDATE_FAILED.getMessage());}return true;}
}

3. InstitutionServiceImpl

@Service
public class InstitutionServiceImpl extends ServiceImpl<InstitutionMapper, Institution> implements InstitutionService {@Autowiredprivate InstitutionMapper institutionMapper;@Autowiredprivate UserMapper userMapper;public static final String CATEGORY_ID = "category_id";@Overridepublic List<Institution> getInstitutionByInstitutionCategoryId(Long institutionCategoryId) {// 使用QueryWrapper构建查询条件QueryWrapper<Institution> queryWrapper = new QueryWrapper<>();queryWrapper.eq(CATEGORY_ID, institutionCategoryId);// 查询符合条件的所有机构return institutionMapper.selectList(queryWrapper);}
}

四、枚举类

InstitutionDoctorEnum

定义了医生和机构相关的业务异常枚举。

public enum InstitutionDoctorEnum {DOCTOR_NOT_EXIST(4031,"医生不存在"),CLIENT_NOT_EXIST(4032,"患者不存在"),Patient_NOT_EXIST(4033,"患者未绑定,请前往绑定"),DOCTOR_ALREADY_BOUND(4034,"用户已绑定医生"),BIND_UPDATE_FAILED(4035,"其它绑定错误");private Integer code;private String message;InstitutionDoctorEnum(Integer code, String message) {this.code = code;this.message = message;}
}

五、接口功能说明

  1. getInstitutionList:根据机构分类ID获取机构列表
  2. getDoctorList:根据机构名称获取该机构的医生列表
  3. bindDoctorByDoctorNumber:通过医生编号为用户绑定医生
  4. unbindDoctorByDoctorNumber:解除用户与医生的绑定关系
  5. getDoctorMsg:根据医生编号获取医生详细信息

六、接口调用示例

1. 获取机构列表

GET /institution-doctor/listInstitution/1

2. 获取医生列表

GET /institution-doctor/listDoctor?institution=某医院

3. 绑定医生

PATCH /institution-doctor/bindDoctorByDoctorNumber
请求体: {"uuid": "用户UUID", "doctorNumber": 12345}

4. 解绑医生

PATCH /institution-doctor/unbindDoctorByDoctorNumber
请求体: {"uuid": "用户UUID", "doctorNumber": 12345}

5. 获取医生信息

GET /institution-doctor/getDoctorMsg/12345

其它问题思考:

  1. pathVariable和requestparam的使用场景
  2. 唯一标识在用户量不大的情况下使用INT和String哪个效率高
  3. 用uuid完全代替id是否合理

相关文章:

患者根据医生编号完成绑定和解绑接口

医疗系统接口文档 一、Controller 层 1. InstitutionDoctorController 医疗机构和医生相关的控制器&#xff0c;提供机构查询、医生查询、绑定解绑医生等功能。 RestController RequestMapping("/institution-doctor") public class InstitutionDoctorController…...

Navicat 17 for Mac 数据库管理

Navicat 17 for Mac 数据库管理 一、介绍 Navicat Premium 17 for Mac是一款专业的数据库管理工具&#xff0c;适用于开发人员、数据库管理员和分析师等用户。它提供了强大的数据管理功能和丰富的工具&#xff0c;使用户能够轻松地管理和维护数据库&#xff0c;提高数据处理效…...

面试如何应用大模型

在面试中,如果被问及如何应用大模型,尤其是面向政务、国有企业或大型传统企业的数字化转型场景,你可以从以下几个角度进行思考和回答: 1. 确定应用大模型的目标与痛点 首先,明确应用大模型的业务目标,并结合企业的实际需求分析可能面临的痛点。这些企业通常会关注如何提…...

grok 驱动级键盘按键记录器分析

grok是一个驱动模块&#xff0c;其主要功能就行进行键盘按键及剪切板数据的记录&#xff0c;也就是一个键盘记录器。实现原理是通过对shadow-ssdt的相关函数进行hook,和r3对GetUserMessage进行hook的原理差不多。 关键部分如下&#xff1a; 查找csrss.exe进程是否已经启动&…...

MyBatis中特殊符号处理总结

前言 MyBatis 是一款流行的Java持久层框架&#xff0c;广泛应用于各种类型的项目中。因为我们在日常代码 MyBatis 动态拼接语句时&#xff0c;会经常使用到 大于(>,>)、小于(<,<)、不等于(<>、!)操作符号。由于此符号包含了尖括号&#xff0c;而 MyBatis 使用…...

【学Rust写CAD】37 premultiply 函数(argb.rs补充方法)

源码 fn premultiply(self) -> Argb {//预乘// This could be optimized by using SWARlet a self.alpha32();if a < 255 {Argb::new32(a, div255(self.red32() * a), div255(self.green32() * a),div255(self.blue32() * a))}else{self}源码分析 这个函数实现了颜色预…...

MYSQL——SQL语句到底怎么执行

查询语句执行流程 MySQL 查询语句执行流程 查询缓存&#xff08;Query Cache&#xff09; MySQL内部自带了一个缓存模块&#xff0c;默认是关闭的。主要是因为MySQL自带的缓存应用场景有限。 它要求SQL语句必须一摸一样表里面的任何一条数据发生变化时&#xff0c;该表所有缓…...

智能血压计WT2801芯片方案-BLE 5.0无线传输、高保真语音交互、LED显示驱动、低功耗待机四大技术赋能

在智能健康设备飞速发展的今天&#xff0c;血压计早已不再是简单的“测量工具”&#xff0c;而是家庭健康的“智能管家”。然而&#xff0c;一台真正可靠、易用、功能全面的血压计&#xff0c;离不开一颗强大的“核心芯片”。 今天&#xff0c;我们揭秘医疗级芯片WT2801的硬核实…...

基于51单片机的智能火灾报警系统—温度烟雾检测、数码管显示、手动报警

基于51单片机的火灾报警系统 &#xff08;仿真&#xff0b;程序&#xff0b;原理图&#xff0b;设计报告&#xff09; 功能介绍 具体功能&#xff1a; 由51单片机MQ-2烟雾传感ADC0832模数转换芯片DS18B20温度传感器数码管显示按键模块声光报警模块构成 具体功能&#xff1a;…...

【Java】Java 中不同类型的类详解

目录 Java 中不同类型的类详解一、基础类类型1. 普通类&#xff08;Concrete Class&#xff09;2. 抽象类&#xff08;Abstract Class&#xff09;3. 接口&#xff08;Interface&#xff09;4. 枚举类&#xff08;Enum Class&#xff09; 二、嵌套类与特殊类5. 内部类&#xff…...

指定运行级别

linux系统下有7种运行级别,我们需要来了解一下常用的运行级别,方便我们熟悉以后的部署环境,话不多说,来看. 开机流程&#xff1a; 指定数级别 基本介绍 运行级别说明: 0:关机 相当于shutdown -h now ⭐️默认参数不能设置为0,否则系统无法正常启动 1:单用户(用于找回丢…...

解决playwright操作网页下拉菜单问题

一个通俗易懂的 Playwright Python 教程&#xff0c;教你如何操作网页的下拉菜单。我们会从基础开始&#xff0c;一步步讲解&#xff0c;并配上实际例子。 Playwright 操作网页下拉菜单教程&#xff08;Python版&#xff09; 什么是 Playwright&#xff1f; Playwright 是一个…...

Python标准库:sys模块深入解析

sys模块是Python标准库中一个非常重要的内置模块&#xff0c;它提供了与Python解释器及其环境交互的多种功能。本文将深入探讨sys模块的各个方面&#xff0c;帮助开发者更好地理解和利用这个强大的工具。 1. sys模块概述 sys模块提供了对由解释器使用或维护的变量的访问&…...

HOW - 实现 useClickOutside 或者 useClickAway

场景 在开发过程中经常遇到需要点击除某div范围之外的区域触发回调&#xff1a;比如点击 dialog 外部区域关闭。 手动实现 import { useEffect } from "react"/*** A custom hook to detect clicks outside a specified element.* param ref - A React ref object…...

加油站小程序实战教程10开通会员

目录 1 修改用户登录逻辑2 创建变量3 调用API总结 我们上一篇搭建了开通会员的界面&#xff0c;有了界面的时候就需要加入一些逻辑来控制界面显示。我们的逻辑是当用户打开我的页面的时候&#xff0c;在页面加载完毕后调用API看用户是否已经开通会员了&#xff0c;如果未开通就…...

TorchServe部署模型-index_to_name.json

在TorchServe部署模型时&#xff0c;若要将模型输出结果映射到指定标签&#xff08;如分类任务的类别名称&#xff09;&#xff0c;需通过index_to_name.json文件定义索引与标签的映射关系&#xff0c;并在打包模型时将其作为额外文件包含。以下是完整流程和命令示例&#xff1…...

Python 3.x cxfreeze打包exe教程

Python 3.x cxfreeze打包exe教程 https://blog.csdn.net/qq_33704787/article/details/123926953 去官网 下载安装 pip install cx-Freeze7.2.9 https://pypi.org/project/cx-Freeze/7.2.9/ 安装到 你的 python 的 script文件夹下面 &#xff08;全局或是 虚拟环境都行&#x…...

Vue/React组件/指令/Hooks封装的基本原则以及示例

一、组件封装原则与示例 Vue组件封装 核心原则 • 单一职责:每个组件只解决一个功能(如分页、过滤表单) • Props控制输入:通过定义明确的Props接口接收外部数据(类型校验、默认值) • Emit事件通信:子组件通过$emit向父组件传递动作(如分页切换) • 插槽扩展性:使用…...

【蓝桥杯】15届JAVA研究生组F回文字符串

一、思路 1.这题去年考的时候想的是使用全排列进行尝试&#xff0c;实际不用这么麻烦&#xff0c;只用找到第一个和最后一个非特殊字符串的位置&#xff0c;然后分别向内检查是否对称&#xff0c;向外检查是否对称直到左指针小于0(可以通过添加使其对称) 2.至于如何找到第一个…...

SDL显示YUV视频

文章目录 1. **宏定义和初始化**2. **全局变量**3. **`refresh_video_timer` 函数**4. **`WinMain` 函数**主要功能及工作流程:总结:1. 宏定义和初始化 #define REFRESH_EVENT (SDL_USEREVENT + 1) // 请求画面刷新事件 #define QUIT_EVENT...

没有他的“变换”,就没有今天的人工智能

从ChatGPT发布以来&#xff0c;大语言模型&#xff08;LLM&#xff09;是所有人追逐的方向&#xff0c;无论是将其看作“万能神”或是人工智能应用的基础构件&#xff0c;其重要性毋庸置疑。而随着大语言模型扩展到多模态领域&#xff0c;就需要更多的工具来帮助其进行处理。 例…...

el-input 中 select 方法使用报错:属性“select”在类型“HTMLElement”上不存在

要解决该错误&#xff0c;需明确指定元素类型为 HTMLInputElement&#xff0c;因为 select() 方法属于输入元素。 步骤解释&#xff1a; 类型断言&#xff1a;使用 as HTMLInputElement 将元素类型断言为输入元素。 可选链操作符&#xff1a;保持 ?. 避免元素为 null 时出错…...

MCP 实战:实现server端,并在cline调用

本文动手实现一个简单的MCP服务端的编写&#xff0c;并通过MCP Server 实现成绩查询的调用。 一、配置环境 安装mcp和uv, mcp要求python版本 Python >3.10; pip install mcppip install uv 二、编写并启用服务端 # get_score.py from mcp.server.fastmcp import…...

关于C++日志库spdlog

关于C日志库spdlog spdlog是一个高性能、易于使用的C日志库&#xff0c;广泛应用于现代C项目中。它支持多线程、异步日志记录、多种日志格式、以及灵活的输出方式&#xff08;如控制台、文件、甚至自定义输出&#xff09;。下面将就常用功能方面介绍spdlog的安装、配置和使用方…...

回归预测 | Matlab实现RIME-CNN-GRU-Attention霜冰优化卷积门控循环单元注意力机制多变量回归预测

回归预测 | Matlab实现RIME-CNN-GRU-Attention霜冰优化卷积门控循环单元注意力机制多变量回归预测 目录 回归预测 | Matlab实现RIME-CNN-GRU-Attention霜冰优化卷积门控循环单元注意力机制多变量回归预测预测效果基本介绍程序设计参考资料 预测效果 基本介绍 1.Matlab实现RIME…...

ruby self

在 Ruby 中&#xff0c;self 是一个指向当前对象的特殊变量&#xff0c;它的值根据代码的上下文动态变化。理解 self 的指向是掌握 Ruby 面向对象编程的关键。以下是详细解析&#xff1a; 一、self 的核心规则 self 始终指向当前方法的执行者&#xff08;即调用方法的对象&…...

液氮恒温器是做什么的

‌液氮恒温器‌是一种利用液氮作为冷源的恒温装置&#xff0c;主要用于提供低温、恒温或变温环境&#xff0c;广泛应用于科研、工业和医疗等领域。液氮恒温器通过液氮的低温特性来实现降温效果&#xff0c;具有效率高、降温速度快、振动小、成本低等优点。 液氮恒温器应用场景和…...

突破,未观测地区罕见极端降雨的估计

文章中文总结&#xff08;重点为方法细节&#xff09; 一、研究背景与目的 在无测站或短观测记录地区&#xff0c;传统极值理论&#xff08;如GEV&#xff09;难以估计稀有极端降雨事件&#xff1b;本文提出一种新的区域化极值估计方法&#xff1a;区域化 Metastatistical Ex…...

`mpi4py` 是什么; ModuleNotFoundError: No module named ‘mpi4py

mpi4py 是什么 目录 `mpi4py` 是什么ModuleNotFoundError: No module named mpi4pyModuleNotFoundError: No module named mpi4py mpi4py 是一个 Python 模块,它提供了对 MPI(Message Passing Interface)标准的接口,使得 Python 程序能够利用 MPI 进行并行计算。其作用主要…...

大数据 - 1. 概述

早期的计算机&#xff08;上世纪70年代前&#xff09; 是相互独立的&#xff0c;各自处理各自的数据上世纪70年代后&#xff0c;出现了基于TCP/IP协议的小规模的计算机互联互通。上世纪90年代后&#xff0c;全球互联的互联网出现。当全球互联网逐步建成&#xff08;2000年左右&…...