预约挂号医院管理项目----Service-cmn模块—数据字典
Service-cmn模块
- Service-cmn模块
- 一. 配置文件
- ①. 分页配置文件
- ②. application.properties配置文件
- ③. logback日志配置文件
- 二. 数据字典的接口 DictController
- ①. 导入数据字典
- ②. 导出数据字典接口
- ③. 根据数据id查询子数据列表
- ④. 根据dictcode和value查询
- 三. SpringCache 缓冲的使用
Service-cmn模块
一. 配置文件
①. 分页配置文件
分页配置文件
@Configuration
@MapperScan("com.xizi.cmn.mapper")
public class CmnConfig {/*mp分页插件*/@Beanpublic PaginationInterceptor PaginationInnerInterceptor(){return new PaginationInterceptor();}
}
②. application.properties配置文件
application.properties配置文件
# 服务端口
server.port=8202
# 服务名
spring.application.name=service-cmn# 环境设置:dev、test、prod
spring.profiles.active=dev# mysql数据库连接
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/yygh_cmn?characterEncoding=utf-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=1234#返回json的全局时间格式
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8spring.redis.host=112.74.164.23
spring.redis.password=123456
spring.redis.port=6379
spring.redis.database= 0
spring.redis.timeout=1800000msspring.redis.lettuce.pool.max-active=20
spring.redis.lettuce.pool.max-wait=-1ms
#最大阻塞等待时间(负数表示没限制)
spring.redis.lettuce.pool.max-idle=5
spring.redis.lettuce.pool.min-idle=0# nacos服务地址
spring.cloud.nacos.discovery.server-addr=112.74.164.23:8848
③. logback日志配置文件
logback日志配置文件
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="10 seconds"><!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 --><!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true --><!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 --><!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 --><contextName>logback</contextName><!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 --><property name="log.path" value="D:/Hospital_log/edu" /><!-- 彩色日志 --><!-- 配置格式变量:CONSOLE_LOG_PATTERN 彩色日志格式 --><!-- magenta:洋红 --><!-- boldMagenta:粗红--><!-- cyan:青色 --><!-- white:白色 --><!-- magenta:洋红 --><property name="CONSOLE_LOG_PATTERN"value="%yellow(%date{yyyy-MM-dd HH:mm:ss}) |%highlight(%-5level) |%blue(%thread) |%blue(%file:%line) |%green(%logger) |%cyan(%msg%n)"/><!--输出到控制台--><appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"><!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息--><!-- 例如:如果此处配置了INFO级别,则后面其他位置即使配置了DEBUG级别的日志,也不会被输出 --><filter class="ch.qos.logback.classic.filter.ThresholdFilter"><level>INFO</level></filter><encoder><Pattern>${CONSOLE_LOG_PATTERN}</Pattern><!-- 设置字符集 --><charset>UTF-8</charset></encoder></appender><!--输出到文件--><!-- 时间滚动输出 level为 INFO 日志 --><appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"><!-- 正在记录的日志文件的路径及文件名 --><file>${log.path}/log_info.log</file><!--日志文件输出格式--><encoder><pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern><charset>UTF-8</charset></encoder><!-- 日志记录器的滚动策略,按日期,按大小记录 --><rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><!-- 每天日志归档路径以及格式 --><fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern><timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><maxFileSize>100MB</maxFileSize></timeBasedFileNamingAndTriggeringPolicy><!--日志文件保留天数--><maxHistory>15</maxHistory></rollingPolicy><!-- 此日志文件只记录info级别的 --><filter class="ch.qos.logback.classic.filter.LevelFilter"><level>INFO</level><onMatch>ACCEPT</onMatch><onMismatch>DENY</onMismatch></filter></appender><!-- 时间滚动输出 level为 WARN 日志 --><appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"><!-- 正在记录的日志文件的路径及文件名 --><file>${log.path}/log_warn.log</file><!--日志文件输出格式--><encoder><pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern><charset>UTF-8</charset> <!-- 此处设置字符集 --></encoder><!-- 日志记录器的滚动策略,按日期,按大小记录 --><rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><fileNamePattern>${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern><timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><maxFileSize>100MB</maxFileSize></timeBasedFileNamingAndTriggeringPolicy><!--日志文件保留天数--><maxHistory>15</maxHistory></rollingPolicy><!-- 此日志文件只记录warn级别的 --><filter class="ch.qos.logback.classic.filter.LevelFilter"><level>warn</level><onMatch>ACCEPT</onMatch><onMismatch>DENY</onMismatch></filter></appender><!-- 时间滚动输出 level为 ERROR 日志 --><appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"><!-- 正在记录的日志文件的路径及文件名 --><file>${log.path}/log_error.log</file><!--日志文件输出格式--><encoder><pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern><charset>UTF-8</charset> <!-- 此处设置字符集 --></encoder><!-- 日志记录器的滚动策略,按日期,按大小记录 --><rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern><timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><maxFileSize>100MB</maxFileSize></timeBasedFileNamingAndTriggeringPolicy><!--日志文件保留天数--><maxHistory>15</maxHistory></rollingPolicy><!-- 此日志文件只记录ERROR级别的 --><filter class="ch.qos.logback.classic.filter.LevelFilter"><level>ERROR</level><onMatch>ACCEPT</onMatch><onMismatch>DENY</onMismatch></filter></appender><!--<logger>用来设置某一个包或者具体的某一个类的日志打印级别、以及指定<appender>。<logger>仅有一个name属性,一个可选的level和一个可选的addtivity属性。name:用来指定受此logger约束的某一个包或者具体的某一个类。level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,如果未设置此属性,那么当前logger将会继承上级的级别。--><!--使用mybatis的时候,sql语句是debug下才会打印,而这里我们只配置了info,所以想要查看sql语句的话,有以下两种操作:第一种把<root level="INFO">改成<root level="DEBUG">这样就会打印sql,不过这样日志那边会出现很多其他消息第二种就是单独给mapper下目录配置DEBUG模式,代码如下,这样配置sql语句会打印,其他还是正常DEBUG级别:--><!--开发环境:打印控制台--><springProfile name="dev"><!--可以输出项目中的debug日志,包括mybatis的sql日志--><logger name="com.guli" level="INFO" /><!--root节点是必选节点,用来指定最基础的日志输出级别,只有一个level属性level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,默认是DEBUG可以包含零个或多个appender元素。--><root level="INFO"><appender-ref ref="CONSOLE" /><appender-ref ref="INFO_FILE" /><appender-ref ref="WARN_FILE" /><appender-ref ref="ERROR_FILE" /></root></springProfile><!--生产环境:输出到文件--><springProfile name="pro"><root level="INFO"><appender-ref ref="CONSOLE" /><appender-ref ref="DEBUG_FILE" /><appender-ref ref="INFO_FILE" /><appender-ref ref="ERROR_FILE" /><appender-ref ref="WARN_FILE" /></root></springProfile>
</configuration>
二. 数据字典的接口 DictController
①. 导入数据字典
//导入数据字典 controller层@PostMapping("importData")public Result importDict(MultipartFile file) {dictService.importDictData(file);return Result.ok();}//导入数据字典 serviceimpl实现类层@Override @CacheEvict(value = "dict", allEntries=true)public void importDictData(MultipartFile file) {try {EasyExcel.read(file.getInputStream(),DictEeVo.class,new DictListener(baseMapper)).sheet().doRead();} catch (IOException e) {e.printStackTrace();}}
②. 导出数据字典接口
//导出数据字典接口 controller层@GetMapping("exportData")public void exportDict(HttpServletResponse response) {dictService.exportDictData(response);}//导出数据字典接口 serviceimpl实现类层@Overridepublic void exportDictData(HttpServletResponse response) {//设置下载信息response.setContentType("application/vnd.ms-excel");response.setCharacterEncoding("utf-8");String fileName = "dict";response.setHeader("Content-disposition", "attachment;filename="+ fileName + ".xlsx");//查询数据库List<Dict> dictList = baseMapper.selectList(null);//Dict -- DictEeVoList<DictEeVo> dictVoList = new ArrayList<>();for(Dict dict:dictList) {DictEeVo dictEeVo = new DictEeVo();// dictEeVo.setId(dict.getId());BeanUtils.copyProperties(dict,dictEeVo);dictVoList.add(dictEeVo);}//调用方法进行写操作try {EasyExcel.write(response.getOutputStream(), DictEeVo.class).sheet("dict").doWrite(dictVoList);} catch (IOException e) {e.printStackTrace();}}
③. 根据数据id查询子数据列表
//根据数据id查询子数据列表 controller层@ApiOperation(value = "根据数据id查询子数据列表")@GetMapping("findChildData/{id}")public Result findChildData(@PathVariable Long id) {List<Dict> list = dictService.findChlidData(id);return Result.ok(list);}//根据数据id查询子数据列表 serviceimpl实现类层@Override@Cacheable(value = "dict",keyGenerator = "keyGenerator")public List<Dict> findChlidData(Long id) {//使用mp中的queryWrapper查询包装器QueryWrapper<Dict> wrapper = new QueryWrapper<>();//条件添加wrapper.eq("parent_id",id);//查询Dict的集合带上wrapper这个条件List<Dict> dictList = baseMapper.selectList(wrapper);//向list集合每个dict对象中设置hasChildrenfor (Dict dict:dictList) {Long dictId = dict.getId();boolean isChild = this.isChildren(dictId);dict.setHasChildren(isChild);}//返回dict集合return dictList;}
④. 根据dictcode和value查询
//根据dictcode和value查询@GetMapping("getName/{dictCode}/{value}")public String getName(@PathVariable String dictCode,@PathVariable String value) {String dictName = dictService.getDictName(dictCode,value);return dictName;}//根据dictcode和value查询@Overridepublic String getDictName(String dictCode, String value) {//如果dictCode为空,直接根据value查询if(StringUtils.isEmpty(dictCode)) {//直接根据value查询QueryWrapper<Dict> wrapper = new QueryWrapper<>();wrapper.eq("value",value);Dict dict = baseMapper.selectOne(wrapper);return dict.getName();} else {//如果dictCode不为空,根据dictCode和value查询//根据dictcode查询dict对象,得到dict的id值Dict codeDict = this.getDictByDictCode(dictCode);Long parent_id = codeDict.getId();//根据parent_id和value进行查询Dict finalDict = baseMapper.selectOne(new QueryWrapper<Dict>().eq("parent_id", parent_id).eq("value", value));return finalDict.getName();}}
三. SpringCache 缓冲的使用
@Cacheable
- 根据方法对其返回结果进行缓存,下次请求时,如果缓存存在,则直接读取缓存数据返回;如果缓存不存在,则执行方法,并把返回的结果存入缓存中。一般用在查询方法上。
@CacheEvict
- 使用该注解标志的方法,会清空指定的缓存。一般用在更新或者删除方法上
@CachePut
- 使用该注解标志的方法,每次都会执行,并将结果存入指定的缓存中。其他方法可以直接从响应的缓存中读取缓存数据,而不需要再去查询数据库。一般用在新增方法上。
预约挂号医院管理项目----Service-cmn模块—数据字典相关推荐
- 预约挂号医院管理项目----service_hosp模块—医院管理
service_hosp模块 一. 配置和配置文件 ①. Nacos服务地址/ MySQL数据库连接/ Redis数据库连接/ MongoDB连接/ Rabbitmq连接 ②. mp分页插件配置 ③. ...
- 预约挂号医院门诊挂号系统设计与实现
项目背景和意义 目的:本课题主要目标是设计并能够实现一个基于web网页的医院预约挂号系统,整个网站项目使用了B/S架构,基于java的springboot框架下开发:通过后台设置医院信息.录入医院科室 ...
- 客户关系管理项目——用户登录模块设计
一 模块需求细化 登录的用户,默认情况有三个不同角色,分别为:系统管理员,前台客服,信息管理员. 用户登录后能够根据其角色来进行相关工作,进行完工作需要能够注销. 细化需求如下: 用户登录之后按角色分 ...
- 医院预约挂号小程序 代码+论文
医院预约挂号系统小程序 摘 要 随着信息化时代的到来,管理系统都趋向于智能化.系统化,xxxx小程序也不例外,但目前国内的市场仍都使用人工管理,市场规模越来越大,同时信息量也越来越庞大,人工管理显然已 ...
- 【计算机毕业设计】医院预约挂号系统
一.系统截图(需要演示视频可以私聊) 摘 要 随着科学技术的飞速发展,社会的方方面面.各行各业都在努力与现代的先进技术接轨,通过科技手段来提高自身的优势,医院预约挂号系统当然也不能排除在外.医院预约 ...
- PHP的医院预约挂号系统
PHP的医院预约挂号系统 一 项目介绍 用PHP开发的医院预约挂号系统源码 数据库mysql 可搭建在宝塔面板,小皮面板phpstudy等集成环境下,1分钟完成快速部署 二 主要功能 1 咨询师和导医 ...
- 重庆北大青鸟解放碑校区J12班 小米步枪队【在线预约挂号系统】
项目组名:小米加步枪(小米步枪队) 项目名称:在线预约挂号系统 组内成员:重庆北大青鸟解放碑校区J12班陈举.李颖.徐平.鞠军 项目背景:为解决"看病难,挂号难"的问题,重庆北大青 ...
- 美国医院管理职业化之路
从20世纪20年代开始,由于美国政府对公立医院的投资加大.管理式医疗的兴起以及经济萧条等综合因素的影响,使得私立医院需要更有效的运营才能在激烈的竞争中生存下去.职业化的医院管理者在这种环境下纷纷涌现. ...
- 医院项目-预约挂号-第五部分
目录 一.注册中心与服务调用: 1.Nacos概述 2.注册服务 二.医院管理实现 1.医院列表 1.1 医院列表api接口 1.2 service-cmn模块提供接口 1.3封装Feign服务调用 ...
最新文章
- 【剑指Offer】23、二叉搜索树的后序遍历序列
- 深入理解分布式技术 - BASE 理论
- 朋友圈有趣的灵魂都去哪了?这几个优质公号给你答案
- VS2010中使用gtest简单案例
- 微信公众平台开发(150)——从新浪云SAE上传图片到图文消息
- location.host与location.hostname和跨浏览器的兼容性?
- HTTP1.1之后的长连接和WebSocket的长连接之间的区别
- rocketmq消费
- 最大连续子序列和的问题
- 01 Python基础
- UG NX机床搭建仿真三四五轴CSE视频教程
- plsql链接oracle64位报错,PLSQL developer 连接不上64位Oracle 的解决方法
- 自适应滤波器 | 时域ALE算法
- 网页游戏的项目设计方案分享
- 数学--数论--欧几里得定理和拓展欧几里得定理
- 街舞中的rolling机器人_这,就是街舞中的那些“Swag”十足的舞蹈类型,你了解吗?...
- 阿里云服务器搭建JAVA环境详解(jdk+mysql+tomcat)
- 使用 LDAP Browser 登入ad域控提示 Root error: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903C5, commen
- 农村商业银行服务器未收到证书,不及时更新“证书” 当心网银U盾失效
- pip更换源,换成国内镜像