# 互联网医院后端 **Repository Path**: x_msdn/hospital-web ## Basic Information - **Project Name**: 互联网医院后端 - **Description**: 互联网医院后端 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 6 - **Created**: 2022-12-16 - **Last Updated**: 2022-12-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 互联网医院项目开发说明 ## 简介 介绍奈特瑞互联网医院项目,服务端现阶段代码组织结构、相关技术栈,及开发环境快速搭建说明 ## 代码结构 ``` lua ehp └──┐ehp-common -- 工具类及通用代码模块 ├── ehp-bo -- 服务间调用BO定义模块 ├── ehp-constants -- 业务服务常量定义模块 ├── ehp-domain -- DB实体类定义模块(历史逻辑) ├── ehp-support -- 框架通用代码模块 ├── ehp-utils -- 框架通用工具类模块 ├── ehp-jinshuju -- 金数据API接入模块 ├── ehp-redis -- 框架Redis统一接入模块 ├── ehp-repository -- 框架JPA统一接入模块(包含历史原生hibernate逻辑) ├── ehp-repository-jpa -- 框架JPA统一接入模块 ├── ehp-repository-mongo -- 框架MongoDB统一接入模块 ├── ehp-security-jwt -- 框架后台鉴权JWT公共模块 ┌──┘ └──┐ehp-server -- 业务Web服务模块 ├── ehp-gateway -- API网关服务 ├── ehp-admin-api -- 后台管理系统相关服务 └──┐ ├── ehp-cms-api -- CMS管理后台API服务 ├── ehp-ds-api -- DS商家后台API服务 ├── ehp-pc-api -- 医生PC端API服务(视频问诊) ┌──┘ ├── ehp-im -- IM聊天基础API服务 ├── ehp-pay -- 支付基础API服务 ├── ehp-file -- 敏感文件资源访问API服务 ├── ehp-video-consult -- 视频问诊API服务 ├── ehp-weixin -- 微信小程序API服务 ├── ehp-basic -- 基础功能API服务 └──┐ ├── src/main/java/.../push -- 推送基础API ├── src/main/java/.../schedule -- 任务基础API ├── src/main/java/.../sms -- 短信基础API ┌──┘ ├── ehp-medical -- 医疗业务API服务 └──┐ ├── src/main/java/.../b2c -- 药品电商API ├── src/main/java/.../emr -- 电子病历API ├── src/main/java/.../esign -- CA签名API ├── src/main/java/.../search -- 搜索API ├── src/main/java/.../recommend -- 电子处方API ┌──┘ ├── ehp-user -- 用户业务API服务 └──┐ ├── src/main/java/.../wechat -- 患者公众号API ├── src/main/java/.../doctor -- 医生用户API ├── src/main/java/.../patient -- 患者用户API ├── src/main/java/.../pharmacist -- 药师用户API ┌──┘ ``` ## 技术选型 ### 后端技术栈 | 技术 | 说明 | 官网 | | -------------------- | ------------------- | ---------------------------------------- | | SpringBoot | 容器+MVC框架 | https://spring.io/projects/spring-boot | | SpringSecurity | 认证和授权框架 | https://spring.io/projects/spring-security | | MyBatis | cms-api/ds-api持久层框架 | http://www.mybatis.org/mybatis-3/zh/index.html | | JPA | cms-api/ds-api持久层框架 | https://spring.io/projects/spring-data | | Elasticsearch | 搜索引擎 | https://github.com/elastic/elasticsearch | | EMQ Broker | IM消息中间件后 | https://www.emqx.cn | | Redis | 分布式缓存 | https://redis.io/ | | MongoDB | NoSql数据库 | https://www.mongodb.com | | Nginx | 静态资源服务器 | https://www.nginx.com/ | | Docker | 应用容器引擎 | https://www.docker.com | | Jenkins | 自动化部署工具 | https://github.com/jenkinsci/jenkins | | HikariCP | 数据库连接池 | https://github.com/brettwooldridge/HikariCP | | JWT | cms-api/ds-api JWT登录支持 | https://github.com/jwtk/jjwt | | Lombok | 简化对象封装工具 | https://github.com/rzwitserloot/lombok | | Hutool | Java工具类库 | https://github.com/looly/hutool | | Swagger-UI | 文档生成工具 | https://github.com/swagger-api/swagger-ui | | Hibernator-Validator | 验证框架 | http://hibernate.org/validator | | Nacos | 配置中心 | https://nacos.io/zh-cn | | Spring Cloud Gateway | API接口网关 | https://spring.io/projects/spring-cloud-gateway | | OpenFeign & RestTemplate| 业务Restful框架 | https://github.com/openfeign | ## 快速启动 ### 基础组件 | 工具 | 版本号 | 下载 | |---------------| ------ | ------------------------------------------------------------ | | JDK | 1.8 | https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html | | Mysql | 5.7 | https://www.mysql.com/ | | Redis | 5.0 | https://redis.io/download | | MongoDB | 4.1.2 | https://www.mongodb.com/download-center | | EMQ Broker | 2.2.0+ | http://www.rabbitmq.com/download.html | | Elasticsearch | 7.10.1 | https://www.elastic.co/downloads/elasticsearch | | Nacos | 7.10.1 | https://www.elastic.co/downloads/elasticsearch | | Sentinel | 7.10.1 | https://www.elastic.co/downloads/elasticsearch | ### 环境搭建 - MySQL`必要` - 搭建并启动5.7版本mysql服务 - 创建ehp、cms、ds、basic数据库 - 根据提供数据库sql初始化各数据库 - Redis`必要` - 搭建并启动5.0版本redis服务 - 无初始化数据 - MongoDB`必要` - 搭建并启动4.1.2版本服务 - 无初始化数据 - Emq Broker`ehp-im项目涉及` - 搭建并启动2.2.0+版本emq-broker - 官网文档:[emq broker2.x安装文档](https://docs.emqx.cn/broker/v2.0/install.html#emq-2-0-程序包下载) - ElasticSearch`ehp-search项目涉及` - 搭建并启动7.10.1版本elasticSearch服务 - 官网文档:[elasticSearch安装文档](https://www.elastic.co/cn/downloads/elasticsearch) - 必要配置:参考源码`ehp-server/ehp-medical/ehp-search/doc`目录文档 - Nacos`必要` - 搭建并启动Nacos - 创建nacos对应环境namespace,根据运维交付文档导入Nacos初始化配置 - 修改源码聚合项目,根pom.xml中的对应环境nacos相关基础配置(ip、port、namespace、group等) - IDEA`必要` - 导入后端项目源码 - 安装并启用插件lombok - 更新maven依赖 - 根据需要启动对应web项目 ### 环境启动 - 配置文件 - `/pom.xml`文件`profiles`-`profile`-local环境`properties`修改对应nacos配置中心连接参数 ```xml dev hnzzj-develop service-nacos.hnzzj-develop:8848 c308e7aa-b0bf-49c0-80da-76dcf6387469 DEFAULT_GROUP service-nacos.netrainpro-develop:8848 8719 service-sentinel.netrainpro-develop:8280 /tmp ``` - 服务启动 - 代码结构介绍中,所有标描述为API服务的子模块,即为模块的服务API对应web项目,直接运行对应模块的项目`xxx-combine/src/main/java/com/naiterui/ehp/bs/xxxServer.java` 的main方法即可启动改对应项目 - 不同开发工具,启动方式不一致,需要便捷启动或者批量启动,可根据对应开发工具自行配置 - 例如:Idea工具,可开启项目Spring的Service组件支持,批量启动、停止需要的具体项目 - ![](assets/16484516562804.jpg) - Swagger文档 - 单个服务默认文档地址:http://ip:port/doc.html - 根据运维部署文档,完整部署的环境,可通过ehp-gateway项目,访问聚合接口文档。地址:http://gateway_host:gateway_port/doc.html ### 环境配置说明 - nacos多环境配置 - 在nacos中新建命名空间 - 修改pom文件中的config.namespace配置,设置为新建命名空间ID - 在nacos的配置管理 -> 配置列表中选择新建的命名空间,导入[nacos配置](doc/nacos_config.zip) - 修改netrain.yaml中的配置信息,重启各个服务 - nacos文件说明 [位置](doc/nacos_config) ``` lua nacos └──┐ ├── ehp-agent.properties -- 经纪人服务properties文件 ├── ehp-agent.yaml -- 经纪人服务yaml文件 ├── ehp-basic.properties -- 基础服务properties文件 ├── ehp-basic.yaml -- 基础服务yaml文件 ├── ehp-cms-api.yaml -- cms服务yaml文件 ├── ehp-cms-api-dict.properties -- cms服务字典properties文件 ├── ehp-cms-api-dict.yaml -- cms服务字典yaml文件 ├── ehp-ds-api.yaml -- ds服务yaml文件 ├── ehp-gateway-route.yaml -- gateway路由yaml文件 ├── ehp-im.yaml -- IM聊天服务yaml文件 ├── ehp-medical.properties -- 医疗服务properties文件 ├── ehp-medical.yaml -- 医疗服务yaml文件 ├── ehp-pay.yaml -- 支付服务yaml文件 ├── ehp-user.properties -- 用户服务properties文件 ├── ehp-user.yaml -- 用户服务yaml文件 ├── ehp-video-consult.properties -- 视频问诊服务properties文件 ├── ehp-video-consult.yaml -- 视频问诊服务yaml文件 ├── ehp-weixin.properties -- 微信服务properties文件 ├── ehp-weixin.yaml -- 微信服务yaml文件 ├── miniapp-subscribe.yaml -- 小程序订阅模板yaml文件 ├── netrain.yaml -- 基础配置信息yaml文件 ├── weixin-menu.json -- 微信公众号菜单文件 ├── weixin-subscribe.yaml -- 微信服务号订阅模板yaml文件 ├── weixin-template.yaml -- 微信服务号消息模板yaml文件 ┌──┘ ``` - maven多环境配置 - 根据运维注入的profile切换指定的环境 ### 客户端相关配置 - Android客户端 - 环境切换 - Gradle配置`build.gradle(:app)` ``` //0开发环境 1线上环境 def ENVIRONMENT = 1 ``` - 具体路径 `AppConfig.java`->`initConfig()`方法下 - H5配置 `NativeHtml5.java` ``` jsonObj.put("urlType", "1"); // h5当前环境 0 https ; 1 http ``` - 友盟配置 `EXPApplication.java`->`initUmeng()`方法下 ``` // 参数一:当前上下文context; // 参数二:应用申请的Appkey(需替换); // 参数三:渠道名称; // 参数四:设备类型,必须参数,传参数为UMConfigure.DEVICE_TYPE_PHONE则表示手机;传参数为 UMConfigure.DEVICE_TYPE_BOX则表示盒子;默认为手机; // 参数五:Push推送业务的secret 填充Umeng Message Secret对应信息 (需替换) UMConfigure.init(this, "5ff2ea5b066c8042257762d1", "Umeng", UMConfigure.DEVICE_TYPE_PHONE, "0fc1268186cbc29e4eff86a374ad978a"); ``` - IOS客户端 - 项目结构说明 - 本项目采用h5 和原生混合开发,可以在本地工程目录放置一个h5包,放置目录如图 - ![](assets/16484516523495.png) - 本地也可以删除h5包,直接⾛在线升级下载,具体升级逻辑代码如下 ``` //检测h5升级 2 [QLKFileManage copyFolder:@"Crow5" intoDocumentsSubfolder:@"Crow5"]; ``` - ⽬前源码⾥本地是有⼀个H5包的,不⽤动就⾏,如果涉及h5⽅⾯修改,再⾛接⼝更新就⾏ - 环境配置 - 配置文件 `QLKEnvironmentModel` ``` if (useSSL) { 2 //如果是https,设置urlType 3 [[NSUserDefaults standardUserDefaults] setObject:@"0" forKey:u_h5_urlType]; 4 } 5 self.data_KHostURL =productEnvironmentType; 6 self.data_VHOST = @"xxxxxx/vc";//视频服务 self.data_kHost = @"xxxxxx/ad";//线上服务器地址 self.data_kSwaggerHOST = @"xxxxxx/emr" ;//swagger线上服务器 self.data_MHOST = @"xxxxxx/recommend";//推荐服务 self.data_kH5Path =[NSString stringWithFormat:@"%@%@",useSSL? @"https":@"http",@"://xxxxxx"]; 11 self.data_ChatPath =[NSString stringWithFormat:@"%@%@",useSSL? @"https":@"http",@"://xxxxxx"]; 12 self.data_HHOST = @"xxxxxx/im";//咨询上行地址 self.data_THOST = @"xxxxxx/push";//push地址 self.data_H5UpdatedVersion = [NSString stringWithFormat:@"1.0"];//更新H5版本号 self.data_kAPI_H5_Zip = @"xxxxxx"; // H5zip 16 self.data_KAPI_H5_Environmental = @"1"; 17 self.xg_AppId=2200346190; 18 self.xg_Secret=@"ISD24ZG8S55K"; 19 self.bjcaSign_ClientId=@"2020042014053373"; 20 self.bjcaSign_Secret=@"2020042014053394"; ``` - ⽬前⽤到两个环境 `productEnvironmentType`->⽣产环境 `devEnvironmentType`->开发环境 - https配置 - `useSSL`->`YES`为https,`NO`为http - h5环境配置 - `data_KAPI_H5_Environmental`->`0`为⽣产环境,`⾮0`为开发环境 - 三⽅配置 - 友盟 `#define UMengAppKey` - E签宝Schema `xxxDoctor`