From 6638d124dcbe7a24710b973f6f6e4210cc8e4f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E6=9D=A8?= <563249574@qq.com> Date: Mon, 28 Apr 2025 23:00:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/controller/ChatController.java | 41 +- .../java/com/controller/CommonController.java | 677 ++++--------- .../java/com/controller/ConfigController.java | 97 +- .../com/controller/DictionaryController.java | 351 ++++--- .../java/com/controller/FileController.java | 428 +++++++-- .../java/com/controller/GuahaoController.java | 452 +++++---- .../controller/JiankangjiaoyuController.java | 417 +++++--- .../java/com/controller/NewsController.java | 384 +++++--- .../java/com/controller/UsersController.java | 284 +++--- .../com/controller/YishengController.java | 512 ++++------ .../java/com/controller/YonghuController.java | 630 +++++-------- src/main/java/com/entity/ChatEntity.java | 245 ++--- src/main/java/com/entity/ConfigEntity.java | 20 +- .../java/com/entity/DictionaryEntity.java | 215 +++-- src/main/java/com/entity/EIException.java | 36 +- src/main/java/com/entity/GuahaoEntity.java | 257 ++--- .../java/com/entity/JiankangjiaoyuEntity.java | 222 +++-- src/main/java/com/entity/NewsEntity.java | 205 ++-- src/main/java/com/entity/TokenEntity.java | 60 +- src/main/java/com/entity/UsersEntity.java | 39 +- src/main/java/com/entity/YishengEntity.java | 348 ++++--- src/main/java/com/entity/YonghuEntity.java | 288 +++--- src/main/java/com/entity/model/ChatModel.java | 145 +-- .../com/entity/model/DictionaryModel.java | 129 +-- .../java/com/entity/model/GuahaoModel.java | 160 ++-- .../com/entity/model/JiankangjiaoyuModel.java | 132 +-- src/main/java/com/entity/model/NewsModel.java | 119 ++- .../java/com/entity/model/YishengModel.java | 229 +++-- .../java/com/entity/model/YonghuModel.java | 189 ++-- src/main/java/com/entity/view/ChatView.java | 379 ++++---- .../java/com/entity/view/DictionaryView.java | 39 +- src/main/java/com/entity/view/GuahaoView.java | 891 ++++++++++-------- .../com/entity/view/JiankangjiaoyuView.java | 63 +- src/main/java/com/entity/view/NewsView.java | 68 +- .../interceptor/AuthorizationInterceptor.java | 71 +- src/main/java/com/model/enums/TypeEnum.java | 14 +- src/main/resources/front/front/js/validate.js | 66 +- 37 files changed, 4777 insertions(+), 4125 deletions(-) diff --git a/src/main/java/com/controller/ChatController.java b/src/main/java/com/controller/ChatController.java index 4de29d2..b51e251 100644 --- a/src/main/java/com/controller/ChatController.java +++ b/src/main/java/com/controller/ChatController.java @@ -1,35 +1,63 @@ +package com.controller; -ppackage com.controller; - +// 导入处理文件操作的类 import java.io.File; +// 导入用于高精度十进制计算的类 import java.math.BigDecimal; +// 导入处理 URL 的类 import java.net.URL; +// 导入用于格式化日期的类 import java.text.SimpleDateFormat; +// 导入阿里巴巴的 JSON 处理类 import com.alibaba.fastjson.JSONObject; +// 导入常用的集合类 import java.util.*; +// 导入 Spring 框架用于 Bean 属性复制的工具类 import org.springframework.beans.BeanUtils; +// 导入 Servlet 请求相关类 import javax.servlet.http.HttpServletRequest; +// 导入 Spring 上下文加载器类 import org.springframework.web.context.ContextLoader; +// 导入 Servlet 上下文类 import javax.servlet.ServletContext; +// 导入自定义的 Token 服务类 import com.service.TokenService; +// 导入自定义的工具类包 import com.utils.*; +// 导入反射调用异常类 import java.lang.reflect.InvocationTargetException; +// 导入自定义的字典服务类 import com.service.DictionaryService; +// 导入 Apache Commons 提供的字符串工具类 import org.apache.commons.lang3.StringUtils; +// 导入自定义的忽略权限注解类 import com.annotation.IgnoreAuth; +// 导入日志记录器接口 import org.slf4j.Logger; +// 导入日志记录器工厂类 import org.slf4j.LoggerFactory; +// 导入 Spring 的自动注入注解 import org.springframework.beans.factory.annotation.Autowired; +// 导入 Spring 的控制器注解 import org.springframework.stereotype.Controller; +// 导入 Spring 的请求映射注解 import org.springframework.web.bind.annotation.*; +// 导入 MyBatis-Plus 的实体包装器类 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入 MyBatis-Plus 的查询包装器接口 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入自定义的实体类包 import com.entity.*; +// 导入自定义的视图实体类包 import com.entity.view.*; +// 导入自定义的服务类包 import com.service.*; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的响应结果类 import com.utils.R; +// 导入阿里巴巴的 JSON 处理类 import com.alibaba.fastjson.*; /** @@ -173,8 +201,7 @@ public class ChatController { .eq("chat_issue", chat.getChatIssue()) .eq("chat_reply", chat.getChatReply()) .eq("zhuangtai_types", chat.getZhuangtaiTypes()) - .eq("chat_types", chat.getChatTypes()) - ; + .eq("chat_types", chat.getChatTypes()); // 记录查询条件的 SQL 片段日志 logger.info("sql语句:"+queryWrapper.getSqlSegment()); @@ -221,8 +248,7 @@ public class ChatController { .eq("chat_issue", chat.getChatIssue()) .eq("chat_reply", chat.getChatReply()) .eq("zhuangtai_types", chat.getZhuangtaiTypes()) - .eq("chat_types", chat.getChatTypes()) - ; + .eq("chat_types", chat.getChatTypes()); // 记录查询条件的 SQL 片段日志 logger.info("sql语句:"+queryWrapper.getSqlSegment()); @@ -389,5 +415,4 @@ public class ChatController { return R.error(511,"查不到数据"); } } - -/** \ No newline at end of file +} \ No newline at end of file diff --git a/src/main/java/com/controller/CommonController.java b/src/main/java/com/controller/CommonController.java index 569a58f..9592370 100644 --- a/src/main/java/com/controller/CommonController.java +++ b/src/main/java/com/controller/CommonController.java @@ -1,701 +1,364 @@ package com.controller; +// 导入处理文件操作的类 import java.io.File; +// 导入文件未找到异常类 import java.io.FileNotFoundException; +// 导入输入输出异常类 import java.io.IOException; +// 导入用于格式化日期的类 import java.text.SimpleDateFormat; +// 导入常用的集合类 import java.util.*; +// 导入Servlet请求相关类 import javax.servlet.http.HttpServletRequest; +// 导入阿里巴巴的JSON处理类 import com.alibaba.fastjson.JSON; +// 导入自定义的字符串工具类 import com.utils.StringUtil; +// 导入Apache Commons提供的字符串工具类 import org.apache.commons.lang3.StringUtils; +// 导入JSON对象类 import org.json.JSONObject; +// 导入日志记录器接口 import org.slf4j.Logger; +// 导入日志记录器工厂类 import org.slf4j.LoggerFactory; +// 导入Spring的自动注入注解 import org.springframework.beans.factory.annotation.Autowired; +// 导入Spring用于获取资源的工具类 import org.springframework.util.ResourceUtils; +// 导入Spring的路径变量注解 import org.springframework.web.bind.annotation.PathVariable; +// 导入Spring的请求体注解 import org.springframework.web.bind.annotation.RequestBody; +// 导入Spring的请求映射注解 import org.springframework.web.bind.annotation.RequestMapping; +// 导入Spring的请求参数注解 import org.springframework.web.bind.annotation.RequestParam; +// 导入Spring的RESTful控制器注解 import org.springframework.web.bind.annotation.RestController; +// 导入自定义的忽略权限注解类 import com.annotation.IgnoreAuth; +// 导入百度AI开放平台的人脸识别客户端类 import com.baidu.aip.face.AipFace; +// 导入百度AI开放平台的人脸比对请求类 import com.baidu.aip.face.MatchRequest; +// 导入百度AI开放平台的Base64编码工具类 import com.baidu.aip.util.Base64Util; +// 导入MyBatis-Plus的实体包装器类 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入MyBatis-Plus的查询包装器接口 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入自定义的配置实体类 import com.entity.ConfigEntity; +// 导入自定义的通用服务类 import com.service.CommonService; +// 导入自定义的配置服务类 import com.service.ConfigService; +// 导入自定义的百度工具类 import com.utils.BaiduUtil; +// 导入自定义的文件工具类 import com.utils.FileUtil; +// 导入自定义的响应结果类 import com.utils.R; - /** * 通用接口 */ @RestController -public class CommonController{ +public class CommonController { + // 日志记录器,用于记录当前控制器类的日志信息 private static final Logger logger = LoggerFactory.getLogger(CommonController.class); + // 自动注入通用服务类,用于处理通用业务逻辑 @Autowired private CommonService commonService; - + + // 自动注入配置服务类,用于处理配置相关业务逻辑 @Autowired private ConfigService configService; - + + // 静态变量,存储百度人脸识别客户端实例,初始化为null private static AipFace client = null; - + + // 静态变量,存储百度地图API的AK(应用密钥),初始化为null private static String BAIDU_DITU_AK = null; - + + // 处理获取位置信息的请求,根据经纬度获取城市信息 @RequestMapping("/location") - public R location(String lng,String lat) { - if(BAIDU_DITU_AK==null) { + public R location(String lng, String lat) { + // 如果BAIDU_DITU_AK尚未初始化 + if (BAIDU_DITU_AK == null) { + // 从配置表中查询名称为"baidu_ditu_ak"的配置项的值 BAIDU_DITU_AK = configService.selectOne(new EntityWrapper().eq("name", "baidu_ditu_ak")).getValue(); - if(BAIDU_DITU_AK==null) { + // 如果查询结果为空,返回错误响应 + if (BAIDU_DITU_AK == null) { return R.error("请在配置管理中正确配置baidu_ditu_ak"); } } + // 调用百度工具类的方法,根据AK、经度和纬度获取城市信息 Map map = BaiduUtil.getCityByLonLat(BAIDU_DITU_AK, lng, lat); + // 返回成功响应,并将获取到的城市信息封装在"data"属性中 return R.ok().put("data", map); } - + /** * 人脸比对 - * @param face1 人脸1 - * @param face2 人脸2 - * @return + * @param face1 人脸1的相关信息(可能是文件名等) + * @param face2 人脸2的相关信息(可能是文件名等) + * @return 响应结果对象,包含比对结果数据 */ @RequestMapping("/matchFace") public R matchFace(String face1, String face2, HttpServletRequest request) { - if(client==null) { + // 如果百度人脸识别客户端尚未初始化 + if (client == null) { /*String AppID = configService.selectOne(new EntityWrapper().eq("name", "AppID")).getValue();*/ + // 从配置表中查询名称为"APIKey"的配置项的值 String APIKey = configService.selectOne(new EntityWrapper().eq("name", "APIKey")).getValue(); + // 从配置表中查询名称为"SecretKey"的配置项的值 String SecretKey = configService.selectOne(new EntityWrapper().eq("name", "SecretKey")).getValue(); + // 使用APIKey和SecretKey获取访问令牌 String token = BaiduUtil.getAuth(APIKey, SecretKey); - if(token==null) { + // 如果获取令牌失败,返回错误响应 + if (token == null) { return R.error("请在配置管理中正确配置APIKey和SecretKey"); } + // 初始化百度人脸识别客户端 client = new AipFace(null, APIKey, SecretKey); + // 设置连接超时时间为2000毫秒 client.setConnectionTimeoutInMillis(2000); + // 设置套接字超时时间为60000毫秒 client.setSocketTimeoutInMillis(60000); } + // 用于存储人脸比对结果的JSONObject对象,初始化为null JSONObject res = null; try { - File file1 = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+face1); - File file2 = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+face2); + // 根据请求中的face1信息,构建人脸1的文件对象 + File file1 = new File(request.getSession().getServletContext().getRealPath("/upload") + "/" + face1); + // 根据请求中的face2信息,构建人脸2的文件对象 + File file2 = new File(request.getSession().getServletContext().getRealPath("/upload") + "/" + face2); + // 将人脸1的文件内容转换为Base64编码的字符串 String img1 = Base64Util.encode(FileUtil.FileToByte(file1)); + // 将人脸2的文件内容转换为Base64编码的字符串 String img2 = Base64Util.encode(FileUtil.FileToByte(file2)); + // 创建人脸1的比对请求对象 MatchRequest req1 = new MatchRequest(img1, "BASE64"); + // 创建人脸2的比对请求对象 MatchRequest req2 = new MatchRequest(img2, "BASE64"); + // 创建存储比对请求的ArrayList ArrayList requests = new ArrayList(); + // 将人脸1的请求添加到请求列表中 requests.add(req1); + // 将人脸2的请求添加到请求列表中 requests.add(req2); + // 调用百度人脸识别客户端的match方法进行人脸比对,并获取结果 res = client.match(requests); + // 打印比对结果中的"result"部分(可能是比对的详细信息) System.out.println(res.get("result")); } catch (FileNotFoundException e) { + // 捕获文件未找到异常,打印异常堆栈信息 e.printStackTrace(); + // 返回错误响应,提示文件不存在 return R.error("文件不存在"); } catch (IOException e) { + // 捕获输入输出异常,打印异常堆栈信息 e.printStackTrace(); - } + } + // 将比对结果中的"result"部分解析为JSON对象,并封装在响应结果中返回 return R.ok().put("data", com.alibaba.fastjson.JSONObject.parse(res.get("result").toString())); } - /** * 获取table表中的column列表(联动接口) - * @return + * @return 响应结果对象,包含获取到的列数据列表 */ @RequestMapping("/option/{tableName}/{columnName}") - @IgnoreAuth - public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,String level,String parent) { + @IgnoreAuth // 忽略权限验证的注解 + public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, String level, String parent) { + // 创建用于存储请求参数的Map对象 Map params = new HashMap(); + // 将表名添加到参数Map中 params.put("table", tableName); + // 将列名添加到参数Map中 params.put("column", columnName); - if(StringUtils.isNotBlank(level)) { + // 如果level参数不为空,将其添加到参数Map中 + if (StringUtils.isNotBlank(level)) { params.put("level", level); } - if(StringUtils.isNotBlank(parent)) { + // 如果parent参数不为空,将其添加到参数Map中 + if (StringUtils.isNotBlank(parent)) { params.put("parent", parent); } + // 调用通用服务类的方法,根据参数获取列数据列表 List data = commonService.getOption(params); + // 返回成功响应,并将获取到的列数据列表封装在"data"属性中 return R.ok().put("data", data); } - /** * 根据table中的column获取单条记录 - * @return + * @return 响应结果对象,包含获取到的单条记录数据 */ @RequestMapping("/follow/{tableName}/{columnName}") - @IgnoreAuth + @IgnoreAuth // 忽略权限验证的注解 public R getFollowByOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, @RequestParam String columnValue) { + // 创建用于存储请求参数的Map对象 Map params = new HashMap(); + // 将表名添加到参数Map中 params.put("table", tableName); + // 将列名添加到参数Map中 params.put("column", columnName); + // 将列值添加到参数Map中 params.put("columnValue", columnValue); + // 调用通用服务类的方法,根据参数获取单条记录数据 Map result = commonService.getFollowByOption(params); + // 返回成功响应,并将获取到的单条记录数据封装在"data"属性中 return R.ok().put("data", result); } - /** * 修改table表的sfsh状态 - * @param map - * @return + * @param map 包含表名和其他相关参数的Map对象 + * @return 响应结果对象,表示操作是否成功 */ @RequestMapping("/sh/{tableName}") public R sh(@PathVariable("tableName") String tableName, @RequestBody Map map) { + // 将表名添加到参数Map中 map.put("table", tableName); + // 调用通用服务类的方法,执行修改sfsh状态的操作 commonService.sh(map); + // 返回成功响应 return R.ok(); } - /** * 获取需要提醒的记录数 - * @param tableName - * @param columnName - * @param type 1:数字 2:日期 - * @param map - * @return + * @param tableName 表名 + * @param columnName 列名 + * @param type 类型(1:数字 2:日期) + * @param map 包含其他相关参数的Map对象 + * @return 响应结果对象,包含需要提醒的记录数 */ @RequestMapping("/remind/{tableName}/{columnName}/{type}") - @IgnoreAuth - public R remindCount(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, - @PathVariable("type") String type,@RequestParam Map map) { + @IgnoreAuth // 忽略权限验证的注解 + public R remindCount(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, + @PathVariable("type") String type, @RequestParam Map map) { + // 将表名添加到参数Map中 map.put("table", tableName); + // 将列名添加到参数Map中 map.put("column", columnName); + // 将类型添加到参数Map中 map.put("type", type); - - if(type.equals("2")) { + + // 如果类型为日期("2") + if (type.equals("2")) { + // 创建日期格式化对象,格式为"yyyy-MM-dd" SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + // 获取日历实例 Calendar c = Calendar.getInstance(); + // 用于存储提醒开始日期,初始化为null Date remindStartDate = null; + // 用于存储提醒结束日期,初始化为null Date remindEndDate = null; - if(map.get("remindstart")!=null) { + // 如果参数Map中包含"remindstart"(提醒开始时间间隔) + if (map.get("remindstart") != null) { + // 将"remindstart"转换为整数 Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); - c.setTime(new Date()); - c.add(Calendar.DAY_OF_MONTH,remindStart); + // 设置日历时间为当前日期 + c.setTime(new Date()); + // 根据提醒开始时间间隔,计算提醒开始日期 + c.add(Calendar.DAY_OF_MONTH, remindStart); + // 获取计算后的提醒开始日期 remindStartDate = c.getTime(); + // 将提醒开始日期格式化为字符串,并更新参数Map中的"remindstart"值 map.put("remindstart", sdf.format(remindStartDate)); } - if(map.get("remindend")!=null) { + // 如果参数Map中包含"remindend"(提醒结束时间间隔) + if (map.get("remindend") != null) { + // 将"remindend"转换为整数 Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); + // 设置日历时间为当前日期 c.setTime(new Date()); - c.add(Calendar.DAY_OF_MONTH,remindEnd); + // 根据提醒结束时间间隔,计算提醒结束日期 + c.add(Calendar.DAY_OF_MONTH, remindEnd); + // 获取计算后的提醒结束日期 remindEndDate = c.getTime(); + // 将提醒结束日期格式化为字符串,并更新参数Map中的"remindend"值 map.put("remindend", sdf.format(remindEndDate)); } } - + + // 调用通用服务类的方法,根据参数获取需要提醒的记录数 int count = commonService.remindCount(map); + // 返回成功响应,并将记录数封装在"count"属性中 return R.ok().put("count", count); } - /** - * 圖表统计 + * 图表统计 */ - @IgnoreAuth + @IgnoreAuth // 忽略权限验证的注解 @RequestMapping("/group/{tableName}") - public R group1(@PathVariable("tableName") String tableName, @RequestParam Map params) { + public R group1(@PathVariable("tableName") String tableName, @RequestParam Map params) { + // 将表名添加到参数Map中,键为"table1" params.put("table1", tableName); + // 调用通用服务类的方法,进行图表统计并获取结果 List> result = commonService.chartBoth(params); + // 返回成功响应,并将统计结果封装在"data"属性中 return R.ok().put("data", result); } - - /** * 单列求和 */ @RequestMapping("/cal/{tableName}/{columnName}") - @IgnoreAuth + @IgnoreAuth // 忽略权限验证的注解 public R cal(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) { + // 创建用于存储请求参数的Map对象 Map params = new HashMap(); + // 将表名添加到参数Map中 params.put("table", tableName); + //将列名添加到参数Map中 params.put("column", columnName); + // 调用通用服务类的方法,进行单列求和并获取结果 Map result = commonService.selectCal(params); + // 返回成功响应,并将求和结果封装在"data"属性中 return R.ok().put("data", result); } - /** * 分组统计 */ @RequestMapping("/group/{tableName}/{columnName}") - @IgnoreAuth + @IgnoreAuth // 忽略权限验证的注解 public R group(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) { + // 创建用于存储请求参数的Map对象 Map params = new HashMap(); + // 将表名添加到参数Map中 params.put("table", tableName); + // 将列名添加到参数Map中 params.put("column", columnName); + // 调用通用服务类的方法,进行分组统计并获取结果 List> result = commonService.selectGroup(params); + // 返回成功响应,并将统计结果封装在"data"属性中 return R.ok().put("data", result); } - /** * (按值统计) */ @RequestMapping("/value/{tableName}/{xColumnName}/{yColumnName}") - @IgnoreAuth + @IgnoreAuth // 忽略权限验证的注解 public R value(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName) { + // 创建用于存储请求参数的Map对象 Map params = new HashMap(); + // 将表名添加到参数Map中 params.put("table", tableName); + // 将x轴列名添加到参数Map中 params.put("xColumn", xColumnName); + //将y轴列名添加到参数Map中 params.put("yColumn", yColumnName); - List> result = commonService.selectValue(params); - return R.ok().put("data", result); - } - - - - - /** - * 查询字典表的分组求和 - * tableName 表名 - * groupColumn 分组字段 - * sumCloum 统计字段 - * @return - */ - @RequestMapping("/newSelectGroupSum") - public R newSelectGroupSum(@RequestParam Map params) { - logger.debug("newSelectGroupSum:,,Controller:{},,params:{}",this.getClass().getName(),params); - List> result = commonService.newSelectGroupSum(params); - return R.ok().put("data", result); - } - - - - /** - tableName 查询表 - condition1 条件1 - condition1Value 条件1值 - average 计算平均评分 - 取值 - 有值 Number(res.data.value.toFixed(1)) - 无值 if(res.data){} - * */ - @IgnoreAuth - @RequestMapping("/queryScore") - public R queryScore(@RequestParam Map params) { - logger.debug("queryScore:,,Controller:{},,params:{}",this.getClass().getName(),params); - Map queryScore = commonService.queryScore(params); - return R.ok().put("data", queryScore); - } - - - /** - * 查询字典表的分组统计总条数 - * tableName 表名 - * groupColumn 分组字段 - * @return - */ - @RequestMapping("/newSelectGroupCount") - public R newSelectGroupCount(@RequestParam Map params) { - logger.debug("newSelectGroupCount:,,Controller:{},,params:{}",this.getClass().getName(),params); - List> result = commonService.newSelectGroupCount(params); - return R.ok().put("data", result); - } - - /** - * 当前表的日期分组求和 - * tableName 表名 - * groupColumn 分组字段 - * sumCloum 统计字段 - * dateFormatType 日期格式化类型 1:年 2:月 3:日 - * @return - */ - @RequestMapping("/newSelectDateGroupSum") - public R newSelectDateGroupSum(@RequestParam Map params) { - logger.debug("newSelectDateGroupSum:,,Controller:{},,params:{}",this.getClass().getName(),params); - String dateFormatType = String.valueOf(params.get("dateFormatType")); - if("1".equals(dateFormatType)){ - params.put("dateFormat", "%Y"); - }else if("2".equals(dateFormatType)){ - params.put("dateFormat", "%Y-%m"); - }else if("3".equals(dateFormatType)){ - params.put("dateFormat", "%Y-%m-%d"); - }else{ - R.error("日期格式化不正确"); - } - List> result = commonService.newSelectDateGroupSum(params); - return R.ok().put("data", result); - } - - - /** - * 1查询字典表的分组统计总条数 - * tableName 表名 - * groupColumn 分组字段 - * dateFormatType 日期格式化类型 1:年 2:月 3:日 - * @return - */ - @RequestMapping("/newSelectDateGroupCount") - public R newSelectDateGroupCount(@RequestParam Map params) { - logger.debug("newSelectDateGroupCount:,,Controller:{},,params:{}",this.getClass().getName(),params); - String dateFormatType = String.valueOf(params.get("dateFormatType")); - if("1".equals(dateFormatType)){ - params.put("dateFormat", "%Y"); - }else if("2".equals(dateFormatType)){ - params.put("dateFormat", "%Y-%m"); - }else if("3".equals(dateFormatType)){ - params.put("dateFormat", "%Y-%m-%d"); - }else{ - R.error("日期格式化类型不正确"); - } - List> result = commonService.newSelectDateGroupCount(params); - return R.ok().put("data", result); - } -/** - * 饼状图 - * -- 饼状图 查询当前表 - -- 查询字典表【月】 - -- 统计 -- 查询某个月的每个类型的订单销售数量 - -- 求和 -- 查询某个月的每个类型的订单销售额 - -- 查询某个字符串【月】 - -- 统计 -- 查询某个月的每个员工的订单销售数量 - -- 求和 -- 查询某个月的每个员工的订单销售额 - -- 查询时间【年】 - -- 统计 -- 查询每个月的订单销售数量 - -- 求和 -- 查询每个月的订单销售额 - -- 饼状图 查询级联表 - -- 查询字典表 - -- 统计 -- 查询某个月的每个类型的订单销售数量 - -- 求和 -- 查询某个月的每个类型的订单销售额 - -- 查询某个字符串 - -- 统计 -- 查询某个月的每个员工的订单销售数量 - -- 求和 -- 查询某个月的每个员工的订单销售额 - -- 查询时间 - -- 统计 -- 统计每个月的订单销售数量 - -- 求和 -- 查询每个月的订单销售额 - */ - - -/** - * 柱状图 - -- 柱状图 查询当前表 - -- 某个【年,月】 - -- 当前表 2 级联表 1 - -- 统计 - -- 【日期,字符串,下拉框】 - -- 求和 - -- 【日期,字符串,下拉框】 - -- 柱状图 查询级联表 - -- 某个【年,月】 - -- 统计 - -- 【日期,字符串,下拉框】 - -- 求和 - -- 【日期,字符串,下拉框】 - */ - - /** - * 柱状图求和 - */ - @RequestMapping("/barSum") - public R barSum(@RequestParam Map params) { - logger.debug("barSum方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params)); - Boolean isJoinTableFlag = false;//是否有级联表相关 - String one = "";//第一优先 - String two = "";//第二优先 - - //处理thisTable和joinTable 处理内容是把json字符串转为Map并把带有,的切割为数组 - //当前表 - Map thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class); - params.put("thisTable",thisTable); - - //级联表 - String joinTableString = String.valueOf(params.get("joinTable")); - if(StringUtil.isNotEmpty(joinTableString)) { - Map joinTable = JSON.parseObject(joinTableString, Map.class); - params.put("joinTable", joinTable); - isJoinTableFlag = true; - } - - if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))){//当前表日期 - thisTable.put("date",String.valueOf(thisTable.get("date")).split(",")); - one = "thisDate0"; - } - if(isJoinTableFlag){//级联表日期 - Map joinTable = (Map) params.get("joinTable"); - if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("date")))){ - joinTable.put("date",String.valueOf(joinTable.get("date")).split(",")); - if(StringUtil.isEmpty(one)){ - one ="joinDate0"; - }else{ - if(StringUtil.isEmpty(two)){ - two ="joinDate0"; - } - } - } - } - if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("string")))){//当前表字符串 - thisTable.put("string",String.valueOf(thisTable.get("string")).split(",")); - if(StringUtil.isEmpty(one)){ - one ="thisString0"; - }else{ - if(StringUtil.isEmpty(two)){ - two ="thisString0"; - } - } - } - if(isJoinTableFlag){//级联表字符串 - Map joinTable = (Map) params.get("joinTable"); - if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("string")))){ - joinTable.put("string",String.valueOf(joinTable.get("string")).split(",")); - if(StringUtil.isEmpty(one)){ - one ="joinString0"; - }else{ - if(StringUtil.isEmpty(two)){ - two ="joinString0"; - } - } - } - } - if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("types")))){//当前表类型 - thisTable.put("types",String.valueOf(thisTable.get("types")).split(",")); - if(StringUtil.isEmpty(one)){ - one ="thisTypes0"; - }else{ - if(StringUtil.isEmpty(two)){ - two ="thisTypes0"; - } - } - } - if(isJoinTableFlag){//级联表类型 - Map joinTable = (Map) params.get("joinTable"); - if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("types")))){ - joinTable.put("types",String.valueOf(joinTable.get("types")).split(",")); - if(StringUtil.isEmpty(one)){ - one ="joinTypes0"; - }else{ - if(StringUtil.isEmpty(two)){ - two ="joinTypes0"; - } - } - - } - } - - List> result = commonService.barSum(params); - - List xAxis = new ArrayList<>();//报表x轴 - List> yAxis = new ArrayList<>();//y轴 - List legend = new ArrayList<>();//标题 - - if(StringUtil.isEmpty(two)){//不包含第二列 - List yAxis0 = new ArrayList<>(); - yAxis.add(yAxis0); - legend.add("数值"); - for(Map map :result){ - String oneValue = String.valueOf(map.get(one)); - String value = String.valueOf(map.get("value")); - xAxis.add(oneValue); - yAxis0.add(value); - } - }else{//包含第二列 - Map> dataMap = new LinkedHashMap<>(); - if(StringUtil.isNotEmpty(two)){ - for(Map map :result){ - String oneValue = String.valueOf(map.get(one)); - String twoValue = String.valueOf(map.get(two)); - String value = String.valueOf(map.get("value")); - if(!legend.contains(twoValue)){ - legend.add(twoValue);//添加完成后 就是最全的第二列的类型 - } - if(dataMap.containsKey(oneValue)){ - dataMap.get(oneValue).put(twoValue,value); - }else{ - HashMap oneData = new HashMap<>(); - oneData.put(twoValue,value); - dataMap.put(oneValue,oneData); - } - - } - } - - for(int i =0; i()); - } - - Set keys = dataMap.keySet(); - for(String key:keys){ - xAxis.add(key); - HashMap map = dataMap.get(key); - for(int i =0; i data = yAxis.get(i); - if(StringUtil.isNotEmpty(map.get(legend.get(i)))){ - data.add(map.get(legend.get(i))); - }else{ - data.add("0"); - } - } - } - System.out.println(); - } - - Map resultMap = new HashMap<>(); - resultMap.put("xAxis",xAxis); - resultMap.put("yAxis",yAxis); - resultMap.put("legend",legend); - return R.ok().put("data", resultMap); - } - - /** - * 柱状图统计 - */ - @RequestMapping("/barCount") - public R barCount(@RequestParam Map params) { - logger.debug("barCount方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params)); - Boolean isJoinTableFlag = false;//是否有级联表相关 - String one = "";//第一优先 - String two = "";//第二优先 - - //处理thisTable和joinTable 处理内容是把json字符串转为Map并把带有,的切割为数组 - //当前表 - Map thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class); - params.put("thisTable",thisTable); - - //级联表 - String joinTableString = String.valueOf(params.get("joinTable")); - if(StringUtil.isNotEmpty(joinTableString)) { - Map joinTable = JSON.parseObject(joinTableString, Map.class); - params.put("joinTable", joinTable); - isJoinTableFlag = true; - } - - if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))){//当前表日期 - thisTable.put("date",String.valueOf(thisTable.get("date")).split(",")); - one = "thisDate0"; - } - if(isJoinTableFlag){//级联表日期 - Map joinTable = (Map) params.get("joinTable"); - if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("date")))){ - joinTable.put("date",String.valueOf(joinTable.get("date")).split(",")); - if(StringUtil.isEmpty(one)){ - one ="joinDate0"; - }else{ - if(StringUtil.isEmpty(two)){ - two ="joinDate0"; - } - } - } - } - if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("string")))){//当前表字符串 - thisTable.put("string",String.valueOf(thisTable.get("string")).split(",")); - if(StringUtil.isEmpty(one)){ - one ="thisString0"; - }else{ - if(StringUtil.isEmpty(two)){ - two ="thisString0"; - } - } - } - if(isJoinTableFlag){//级联表字符串 - Map joinTable = (Map) params.get("joinTable"); - if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("string")))){ - joinTable.put("string",String.valueOf(joinTable.get("string")).split(",")); - if(StringUtil.isEmpty(one)){ - one ="joinString0"; - }else{ - if(StringUtil.isEmpty(two)){ - two ="joinString0"; - } - } - } - } - if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("types")))){//当前表类型 - thisTable.put("types",String.valueOf(thisTable.get("types")).split(",")); - if(StringUtil.isEmpty(one)){ - one ="thisTypes0"; - }else{ - if(StringUtil.isEmpty(two)){ - two ="thisTypes0"; - } - } - } - if(isJoinTableFlag){//级联表类型 - Map joinTable = (Map) params.get("joinTable"); - if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("types")))){ - joinTable.put("types",String.valueOf(joinTable.get("types")).split(",")); - if(StringUtil.isEmpty(one)){ - one ="joinTypes0"; - }else{ - if(StringUtil.isEmpty(two)){ - two ="joinTypes0"; - } - } - - } - } - - List> result = commonService.barCount(params); - - List xAxis = new ArrayList<>();//报表x轴 - List> yAxis = new ArrayList<>();//y轴 - List legend = new ArrayList<>();//标题 - - if(StringUtil.isEmpty(two)){//不包含第二列 - List yAxis0 = new ArrayList<>(); - yAxis.add(yAxis0); - legend.add("数值"); - for(Map map :result){ - String oneValue = String.valueOf(map.get(one)); - String value = String.valueOf(map.get("value")); - xAxis.add(oneValue); - yAxis0.add(value); - } - }else{//包含第二列 - Map> dataMap = new LinkedHashMap<>(); - if(StringUtil.isNotEmpty(two)){ - for(Map map :result){ - String oneValue = String.valueOf(map.get(one)); - String twoValue = String.valueOf(map.get(two)); - String value = String.valueOf(map.get("value")); - if(!legend.contains(twoValue)){ - legend.add(twoValue);//添加完成后 就是最全的第二列的类型 - } - if(dataMap.containsKey(oneValue)){ - dataMap.get(oneValue).put(twoValue,value); - }else{ - HashMap oneData = new HashMap<>(); - oneData.put(twoValue,value); - dataMap.put(oneValue,oneData); - } - - } - } - - for(int i =0; i()); - } - - Set keys = dataMap.keySet(); - for(String key:keys){ - xAxis.add(key); - HashMap map = dataMap.get(key); - for(int i =0; i data = yAxis.get(i); - if(StringUtil.isNotEmpty(map.get(legend.get(i)))){ - data.add(map.get(legend.get(i))); - }else{ - data.add("0"); - } - } - } - System.out.println(); - } - - Map resultMap = new HashMap<>(); - resultMap.put("xAxis",xAxis); - resultMap.put("yAxis",yAxis); - resultMap.put("legend",legend); - return R.ok().put("data", resultMap); - } -} + // 调用通用服务类的 \ No newline at end of file diff --git a/src/main/java/com/controller/ConfigController.java b/src/main/java/com/controller/ConfigController.java index 6e9f123..9569096 100644 --- a/src/main/java/com/controller/ConfigController.java +++ b/src/main/java/com/controller/ConfigController.java @@ -1,111 +1,156 @@ - package com.controller; - +// 导入用于操作数组的工具类 import java.util.Arrays; +// 导入Map接口,用于存储键值对 import java.util.Map; +// 导入Spring的自动注入注解 import org.springframework.beans.factory.annotation.Autowired; +// 导入Spring的路径变量注解,用于从URL中获取参数 import org.springframework.web.bind.annotation.PathVariable; +// 导入Spring的POST请求映射注解 import org.springframework.web.bind.annotation.PostMapping; +// 导入Spring的请求体注解,用于获取请求体中的数据 import org.springframework.web.bind.annotation.RequestBody; +// 导入Spring的请求映射注解,用于映射请求路径 import org.springframework.web.bind.annotation.RequestMapping; +// 导入Spring的请求参数注解,用于获取请求参数 import org.springframework.web.bind.annotation.RequestParam; +// 导入Spring的RESTful控制器注解 import org.springframework.web.bind.annotation.RestController; +// 导入自定义的忽略权限验证注解 import com.annotation.IgnoreAuth; +// 导入MyBatis-Plus的实体包装器类,用于构建查询条件 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入配置实体类 import com.entity.ConfigEntity; +// 导入配置服务接口 import com.service.ConfigService; +// 导入分页工具类 import com.utils.PageUtils; +// 导入自定义的响应结果类 import com.utils.R; +// 导入自定义的验证工具类 import com.utils.ValidatorUtils; /** * 登录相关 */ +// 映射请求路径,所有以/config开头的请求都会由该控制器处理 @RequestMapping("config") +// 声明该类为RESTful控制器 @RestController -public class ConfigController{ - - @Autowired - private ConfigService configService; +public class ConfigController { + + // 自动注入配置服务接口的实现类实例 + @Autowired + private ConfigService configService; - /** + /** * 列表 */ + // 映射/page请求路径,支持GET请求 @RequestMapping("/page") - public R page(@RequestParam Map params,ConfigEntity config){ + public R page(@RequestParam Map params, ConfigEntity config) { + // 创建一个EntityWrapper对象,用于构建查询条件 EntityWrapper ew = new EntityWrapper(); - PageUtils page = configService.queryPage(params); + // 调用配置服务的queryPage方法,根据请求参数进行分页查询 + PageUtils page = configService.queryPage(params); + // 返回成功响应,并将分页查询结果放入响应数据中 return R.ok().put("data", page); } - - /** + + /** * 列表 */ + // 映射/list请求路径,支持GET请求,且忽略权限验证 @IgnoreAuth @RequestMapping("/list") - public R list(@RequestParam Map params,ConfigEntity config){ + public R list(@RequestParam Map params, ConfigEntity config) { + // 创建一个EntityWrapper对象,用于构建查询条件 EntityWrapper ew = new EntityWrapper(); - PageUtils page = configService.queryPage(params); + // 调用配置服务的queryPage方法,根据请求参数进行分页查询 + PageUtils page = configService.queryPage(params); + // 返回成功响应,并将分页查询结果放入响应数据中 return R.ok().put("data", page); } /** * 信息 */ + // 映射/info/{id}请求路径,支持GET请求,{id}为路径变量 @RequestMapping("/info/{id}") - public R info(@PathVariable("id") String id){ + public R info(@PathVariable("id") String id) { + // 调用配置服务的selectById方法,根据ID查询配置信息 ConfigEntity config = configService.selectById(id); + // 返回成功响应,并将查询到的配置信息放入响应数据中 return R.ok().put("data", config); } - + /** * 详情 */ + // 映射/detail/{id}请求路径,支持GET请求,{id}为路径变量,且忽略权限验证 @IgnoreAuth @RequestMapping("/detail/{id}") - public R detail(@PathVariable("id") String id){ + public R detail(@PathVariable("id") String id) { + // 调用配置服务的selectById方法,根据ID查询配置信息 ConfigEntity config = configService.selectById(id); + // 返回成功响应,并将查询到的配置信息放入响应数据中 return R.ok().put("data", config); } - + /** * 根据name获取信息 */ + // 映射/info请求路径,支持GET请求 @RequestMapping("/info") - public R infoByName(@RequestParam String name){ + public R infoByName(@RequestParam String name) { + // 调用配置服务的selectOne方法,根据名称查询配置信息 ConfigEntity config = configService.selectOne(new EntityWrapper().eq("name", "faceFile")); + // 返回成功响应,并将查询到的配置信息放入响应数据中 return R.ok().put("data", config); } - + /** * 保存 */ + // 映射/save请求路径,支持POST请求 @PostMapping("/save") - public R save(@RequestBody ConfigEntity config){ + public R save(@RequestBody ConfigEntity config) { + // 注释掉的代码,原本用于验证实体数据的合法性 // ValidatorUtils.validateEntity(config); - configService.insert(config); + // 调用配置服务的insert方法,将配置信息插入数据库 + configService.insert(config); + // 返回成功响应 return R.ok(); } /** * 修改 */ + // 映射/update请求路径,支持GET或POST请求 @RequestMapping("/update") - public R update(@RequestBody ConfigEntity config){ + public R update(@RequestBody ConfigEntity config) { + // 注释掉的代码,原本用于验证实体数据的合法性 // ValidatorUtils.validateEntity(config); - configService.updateById(config);//全部更新 + // 调用配置服务的updateById方法,根据ID更新配置信息,全部字段更新 + configService.updateById(config); + // 返回成功响应 return R.ok(); } /** * 删除 */ + // 映射/delete请求路径,支持GET或POST请求 @RequestMapping("/delete") - public R delete(@RequestBody Long[] ids){ - configService.deleteBatchIds(Arrays.asList(ids)); + public R delete(@RequestBody Long[] ids) { + // 调用配置服务的deleteBatchIds方法,根据ID数组批量删除配置信息 + configService.deleteBatchIds(Arrays.asList(ids)); + // 返回成功响应 return R.ok(); } -} +} \ No newline at end of file diff --git a/src/main/java/com/controller/DictionaryController.java b/src/main/java/com/controller/DictionaryController.java index 489f8a8..33da60e 100644 --- a/src/main/java/com/controller/DictionaryController.java +++ b/src/main/java/com/controller/DictionaryController.java @@ -1,35 +1,62 @@ - package com.controller; +// 导入文件操作类 import java.io.File; +// 导入用于高精度计算的类 import java.math.BigDecimal; +// 导入用于处理URL的类 import java.net.URL; +// 导入用于日期格式化的类 import java.text.SimpleDateFormat; +// 导入阿里巴巴的JSON对象类 import com.alibaba.fastjson.JSONObject; +// 导入常用的集合类 import java.util.*; +// 导入Spring的Bean属性复制工具类 import org.springframework.beans.BeanUtils; +// 导入Servlet请求相关类 import javax.servlet.http.HttpServletRequest; +// 导入Spring的上下文加载器类 import org.springframework.web.context.ContextLoader; +// 导入Servlet上下文类 import javax.servlet.ServletContext; +// 导入令牌服务类 import com.service.TokenService; +// 导入自定义工具类 import com.utils.*; +// 导入反射调用异常类 import java.lang.reflect.InvocationTargetException; - +// 导入字典服务类 import com.service.DictionaryService; +// 导入Apache Commons提供的字符串工具类 import org.apache.commons.lang3.StringUtils; +// 导入自定义的忽略权限注解类 import com.annotation.IgnoreAuth; +// 导入日志记录器接口 import org.slf4j.Logger; +// 导入日志记录器工厂类 import org.slf4j.LoggerFactory; +// 导入Spring的自动注入注解 import org.springframework.beans.factory.annotation.Autowired; +// 导入Spring的控制器注解 import org.springframework.stereotype.Controller; +// 导入Spring的请求映射注解 import org.springframework.web.bind.annotation.*; +// 导入MyBatis-Plus的实体包装器类 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入MyBatis-Plus的查询包装器接口 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入自定义的实体类 import com.entity.*; +// 导入自定义的视图类 import com.entity.view.*; +// 导入自定义的服务类 import com.service.*; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的响应结果类 import com.utils.R; +// 导入阿里巴巴的JSON工具类 import com.alibaba.fastjson.*; /** @@ -37,214 +64,284 @@ import com.alibaba.fastjson.*; * 后端接口 * @author * @email -*/ + */ +// 声明该类为RESTful控制器 @RestController +// 声明该类为控制器 @Controller +// 映射请求路径,所有以/dictionary开头的请求都会由该控制器处理 @RequestMapping("/dictionary") public class DictionaryController { + // 日志记录器,用于记录当前控制器类的日志信息 private static final Logger logger = LoggerFactory.getLogger(DictionaryController.class); - @Autowired - private DictionaryService dictionaryService; - - - @Autowired - private TokenService tokenService; - - //级联表service - - @Autowired + // 此处注解有误,应为@Autowired,自动注入用户服务类 + @Autow private YonghuService yonghuService; + // 自动注入医生服务类 @Autowired private YishengService yishengService; - /** - * 后端列表 - */ + * 后端列表 + */ + // 映射/page请求路径,支持GET请求,且忽略权限验证 @RequestMapping("/page") @IgnoreAuth - public R page(@RequestParam Map params, HttpServletRequest request){ - logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); - if(params.get("orderBy")==null || params.get("orderBy")==""){ - params.put("orderBy","id"); + public R page(@RequestParam Map params, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求参数 + logger.debug("page方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params)); + // 如果请求参数中没有指定排序字段,则默认按id排序 + if (params.get("orderBy") == null || params.get("orderBy") == "") { + params.put("orderBy", "id"); } + // 调用字典服务的queryPage方法,根据请求参数进行分页查询 PageUtils page = dictionaryService.queryPage(params); - //字典表数据转换 - List list =(List)page.getList(); - for(DictionaryView c:list){ - //修改对应字典表字段 + // 将分页结果中的列表转换为字典视图列表 + List list = (List) page.getList(); + // 遍历字典视图列表 + for (DictionaryView c : list) { + // 调用字典服务的dictionaryConvert方法,修改对应字典表字段 dictionaryService.dictionaryConvert(c, request); } + // 返回成功响应,并将分页查询结果放入响应数据中 return R.ok().put("data", page); } /** - * 后端详情 - */ + * 后端详情 + */ + // 映射/info/{id}请求路径,支持GET请求,{id}为路径变量 @RequestMapping("/info/{id}") - public R info(@PathVariable("id") Long id, HttpServletRequest request){ - logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); + public R info(@PathVariable("id") Long id, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求的id + logger.debug("info方法:,,Controller:{},,id:{}", this.getClass().getName(), id); + // 调用字典服务的selectById方法,根据id查询字典实体 DictionaryEntity dictionary = dictionaryService.selectById(id); - if(dictionary !=null){ - //entity转view + // 如果查询到字典实体 + if (dictionary != null) { + // 创建字典视图对象 DictionaryView view = new DictionaryView(); - BeanUtils.copyProperties( dictionary , view );//把实体数据重构到view中 - - //修改对应字典表字段 + // 使用BeanUtils将字典实体的属性复制到字典视图中 + BeanUtils.copyProperties(dictionary, view); + // 调用字典服务的dictionaryConvert方法,修改对应字典表字段 dictionaryService.dictionaryConvert(view, request); + // 返回成功响应,并将字典视图对象放入响应数据中 return R.ok().put("data", view); - }else { - return R.error(511,"查不到数据"); + } else { + // 如果未查询到数据,返回错误响应,错误码为511 + return R.error(511, "查不到数据"); } - } /** - * 后端保存 - */ + * 后端保存 + */ + // 映射/save请求路径,支持POST请求 @RequestMapping("/save") - public R save(@RequestBody DictionaryEntity dictionary, HttpServletRequest request){ - logger.debug("save方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString()); - + public R save(@RequestBody DictionaryEntity dictionary, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和要保存的字典实体信息 + logger.debug("save方法:,,Controller:{},,dictionary:{}", this.getClass().getName(), dictionary.toString()); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); - if(false) - return R.error(511,"永远不会进入"); - + // 此条件永远为false,注释掉的代码表示永远不会进入该分支 + if (false) + return R.error(511, "永远不会进入"); + // 创建查询包装器,用于构建查询条件 Wrapper queryWrapper = new EntityWrapper() - .eq("dic_code", dictionary.getDicCode()) - .eq("index_name", dictionary.getIndexName()) - ; - if(dictionary.getDicCode().contains("_erji_types")){ - queryWrapper.eq("super_id",dictionary.getSuperId()); + .eq("dic_code", dictionary.getDicCode()) + .eq("index_name", dictionary.getIndexName()); + // 如果字典代码包含_erji_types,则添加super_id的查询条件 + if (dictionary.getDicCode().contains("_erji_types")) { + queryWrapper.eq("super_id", dictionary.getSuperId()); } - - logger.info("sql语句:"+queryWrapper.getSqlSegment()); + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 调用字典服务的selectOne方法,根据查询条件查询是否存在相同数据 DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper); - if(dictionaryEntity==null){ + // 如果未查询到相同数据 + if (dictionaryEntity == null) { + // 设置字典实体的创建时间为当前时间 dictionary.setCreateTime(new Date()); + // 调用字典服务的insert方法,将字典实体插入数据库 dictionaryService.insert(dictionary); - //字典表新增数据,把数据再重新查出,放入监听器中 + // 查询所有字典实体 List dictionaryEntities = dictionaryService.selectList(new EntityWrapper()); + // 获取Servlet上下文 ServletContext servletContext = request.getServletContext(); - Map> map = new HashMap<>(); - for(DictionaryEntity d :dictionaryEntities){ + // 创建一个Map用于存储字典数据 + Map> map = new HashMap<>(); + // 遍历所有字典实体 + for (DictionaryEntity d : dictionaryEntities) { + // 获取当前字典代码对应的子Map Map m = map.get(d.getDicCode()); - if(m ==null || m.isEmpty()){ + // 如果子Map为空,则创建一个新的子Map + if (m == null || m.isEmpty()) { m = new HashMap<>(); } - m.put(d.getCodeIndex(),d.getIndexName()); - map.put(d.getDicCode(),m); + // 将当前字典实体的代码索引和索引名称存入子Map + m.put(d.getCodeIndex(), d.getIndexName()); + // 将子Map存入主Map + map.put(d.getDicCode(), m); } - servletContext.setAttribute("dictionaryMap",map); + // 将主Map存入Servlet上下文的属性中 + servletContext.setAttribute("dictionaryMap", map); + // 返回成功响应 return R.ok(); - }else { - return R.error(511,"表中有相同数据"); + } else { + // 如果查询到相同数据,返回错误响应,错误码为511 + return R.error(511, "表中有相同数据"); } } /** - * 后端修改 - */ + * 后端修改 + */ + // 映射/update请求路径,支持POST请求 @RequestMapping("/update") - public R update(@RequestBody DictionaryEntity dictionary, HttpServletRequest request){ - logger.debug("update方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString()); - + public R update(@RequestBody DictionaryEntity dictionary, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和要修改的字典实体信息 + logger.debug("update方法:,,Controller:{},,dictionary:{}", this.getClass().getName(), dictionary.toString()); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); -// if(false) -// return R.error(511,"永远不会进入"); - //根据字段查询是否有相同数据 + // 此条件注释掉,表示永远不会进入该分支 +// if (false) +// return R.error(511, "永远不会进入"); + // 创建查询包装器,用于构建查询条件,排除当前要修改的记录 Wrapper queryWrapper = new EntityWrapper() - .notIn("id",dictionary.getId()) - .eq("dic_code", dictionary.getDicCode()) - .eq("index_name", dictionary.getIndexName()) - ; - - if(dictionary.getDicCode().contains("_erji_types")){ - queryWrapper.eq("super_id",dictionary.getSuperId()); + .notIn("id", dictionary.getId()) + .eq("dic_code", dictionary.getDicCode()) + .eq("index_name", dictionary.getIndexName()); + // 如果字典代码包含_erji_types,则添加super_id的查询条件 + if (dictionary.getDicCode().contains("_erji_types")) { + queryWrapper.eq("super_id", dictionary.getSuperId()); } - logger.info("sql语句:"+queryWrapper.getSqlSegment()); + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 调用字典服务的selectOne方法,根据查询条件查询是否存在相同数据 DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper); - if(dictionaryEntity==null){ - dictionaryService.updateById(dictionary);//根据id更新 - //如果字典表修改数据的话,把数据再重新查出,放入监听器中 + // 如果未查询到相同数据 + if (dictionaryEntity == null) { + // 调用字典服务的updateById方法,根据id更新字典实体 + dictionaryService.updateById(dictionary); + // 查询所有字典实体 List dictionaryEntities = dictionaryService.selectList(new EntityWrapper()); + // 获取Servlet上下文 ServletContext servletContext = request.getServletContext(); - Map> map = new HashMap<>(); - for(DictionaryEntity d :dictionaryEntities){ + // 创建一个Map用于存储字典数据 + Map> map = new HashMap<>(); + // 遍历所有字典实体 + for (DictionaryEntity d : dictionaryEntities) { + // 获取当前字典代码对应的子Map Map m = map.get(d.getDicCode()); - if(m ==null || m.isEmpty()){ + // 如果子Map为空,则创建一个新的子Map + if (m == null || m.isEmpty()) { m = new HashMap<>(); } - m.put(d.getCodeIndex(),d.getIndexName()); - map.put(d.getDicCode(),m); + // 将当前字典实体的代码索引和索引名称存入子Map + m.put(d.getCodeIndex(), d.getIndexName()); + // 将子Map存入主Map + map.put(d.getDicCode(), m); } - servletContext.setAttribute("dictionaryMap",map); + // 将主Map存入Servlet上下文的属性中 + servletContext.setAttribute("dictionaryMap", map); + // 返回成功响应 return R.ok(); - }else { - return R.error(511,"表中有相同数据"); + } else { + // 如果查询到相同数据,返回错误响应,错误码为511 + return R.error(511, "表中有相同数据"); } } /** - * 删除 - */ + * 删除 + */ + // 映射/delete请求路径,支持POST请求 @RequestMapping("/delete") - public R delete(@RequestBody Integer[] ids){ - logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); + public R delete(@RequestBody Integer[] ids) { + // 记录方法调用日志,包含控制器类名和要删除的记录id数组 + logger.debug("delete:,,Controller:{},,ids:{}", this.getClass().getName(), ids.toString()); + // 调用字典服务的deleteBatchIds方法,根据id数组批量删除记录 dictionaryService.deleteBatchIds(Arrays.asList(ids)); + // 返回成功响应 return R.ok(); } /** * 最大值 */ + // 映射/maxCodeIndex请求路径,支持POST请求 @RequestMapping("/maxCodeIndex") - public R maxCodeIndex(@RequestBody DictionaryEntity dictionary){ - logger.debug("maxCodeIndex:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString()); + public R maxCodeIndex(@RequestBody DictionaryEntity dictionary) { + // 记录方法调用日志,包含控制器类名和传入的字典实体信息 + logger.debug("maxCodeIndex:,,Controller:{},,dictionary:{}", this.getClass().getName(), dictionary.toString()); + // 创建一个列表,用于存储排序字段 List descs = new ArrayList<>(); + // 添加按code_index降序排序的字段 descs.add("code_index"); + // 创建查询包装器,用于构建查询条件 Wrapper queryWrapper = new EntityWrapper() .eq("dic_code", dictionary.getDicCode()) .orderDesc(descs); - logger.info("sql语句:"+queryWrapper.getSqlSegment()); + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 调用字典服务的selectList方法,根据查询条件查询字典实体列表 List dictionaryEntityList = dictionaryService.selectList(queryWrapper); - if(dictionaryEntityList != null ){ - return R.ok().put("maxCodeIndex",dictionaryEntityList.get(0).getCodeIndex()+1); - }else{ - return R.ok().put("maxCodeIndex",1); + // 如果查询到的列表不为空 + if (dictionaryEntityList != null) { + // 返回成功响应,并将最大的code_index加1作为结果放入响应数据中 + return R.ok().put("maxCodeIndex", dictionaryEntityList.get(0).getCodeIndex() + 1); + } else { + // 如果未查询到数据,返回成功响应,并将最大的code_index设为1 + return R.ok().put("maxCodeIndex", 1); } } /** * 批量上传 */ + // 映射/batchInsert请求路径,支持POST请求 @RequestMapping("/batchInsert") - public R save( String fileName){ - logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); + public R save(String fileName) { + // 记录方法调用日志,包含控制器类名和文件名 + logger.debug("batchInsert方法:,,Controller:{},,fileName:{}", this.getClass().getName(), fileName); try { - List dictionaryList = new ArrayList<>();//上传的东西 - Map> seachFields= new HashMap<>();//要查询的字段 + // 创建一个列表,用于存储要上传的字典实体 + List dictionaryList = new ArrayList<>(); + // 创建一个Map,用于存储要查询的字段 + Map> seachFields = new HashMap<>(); + // 获取当前时间 Date date = new Date(); + // 获取文件名中最后一个点的索引 int lastIndexOf = fileName.lastIndexOf("."); - if(lastIndexOf == -1){ - return R.error(511,"该文件没有后缀"); - }else{ + // 如果文件名中没有点,返回错误响应,错误码为511 + if (lastIndexOf == -1) { + return R.error(511, "该文件没有后缀"); + } else { + // 获取文件后缀 String suffix = fileName.substring(lastIndexOf); - if(!".xls".equals(suffix)){ - return R.error(511,"只支持后缀为xls的excel文件"); - }else{ - URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径 + // 如果文件后缀不是.xls,返回错误响应,错误码为511 + if (!".xls".equals(suffix)) { + return R.error(511, "只支持后缀为xls的excel文件"); + } else { + // 获取文件的URL + URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName); + // 创建文件对象 File file = new File(resource.getFile()); - if(!file.exists()){ - return R.error(511,"找不到上传文件,请联系管理员"); - }else{ - List> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件 - dataList.remove(0);//删除第一行,因为第一行是提示 - for(List data:dataList){ - //循环 + // 如果文件不存在,返回错误响应,错误码为511 + if (!file.exists()) { + return R.error(511, "找不到上传文件,请联系管理员"); + } else { + // 使用PoiUtil工具类读取xls文件的数据 + List> dataList = PoiUtil.poiImport(file.getPath()); + // 删除第一行数据,因为第一行通常是表头 + dataList.remove(0); + // 遍历数据列表 + for (List data : dataList) { + // 创建一个新的字典实体 DictionaryEntity dictionaryEntity = new DictionaryEntity(); + // 以下代码注释掉,表示需要根据实际情况修改字段赋值 // dictionaryEntity.setDicCode(data.get(0)); //字段 要改的 // dictionaryEntity.setDicName(data.get(0)); //字段名 要改的 // dictionaryEntity.setCodeIndex(Integer.valueOf(data.get(0))); //编码 要改的 @@ -252,26 +349,22 @@ public class DictionaryController { // dictionaryEntity.setSuperId(Integer.valueOf(data.get(0))); //父字段id 要改的 // dictionaryEntity.setBeizhu(data.get(0)); //备注 要改的 // dictionaryEntity.setCreateTime(date);//时间 + // 将字典实体添加到上传列表中 dictionaryList.add(dictionaryEntity); - - //把要查询是否重复的字段放入map中 + // 把要查询是否重复的字段放入map中 } - //查询是否重复 + // 调用字典服务的insertBatch方法,批量插入字典实体 dictionaryService.insertBatch(dictionaryList); + // 返回成功响应 return R.ok(); } } } - }catch (Exception e){ - return R.error(511,"批量插入数据异常,请联系管理员"); + } catch (Exception e) { + // 如果发生异常,返回错误响应,错误码为511 + return R.error(511, "批量插入数据异常,请联系管理员"); } } - - - - - - -} +} \ No newline at end of file diff --git a/src/main/java/com/controller/FileController.java b/src/main/java/com/controller/FileController.java index 7bd4f8e..a5d1e85 100644 --- a/src/main/java/com/controller/FileController.java +++ b/src/main/java/com/controller/FileController.java @@ -1,110 +1,370 @@ package com.controller; +// 导入文件操作类 import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.UUID; - -import org.apache.commons.io.FileUtils; +// 导入用于高精度计算的类 +import java.math.BigDecimal; +// 导入用于处理URL的类 +import java.net.URL; +// 导入用于日期格式化的类 +import java.text.SimpleDateFormat; +// 导入阿里巴巴的JSON对象类 +import com.alibaba.fastjson.JSONObject; +// 导入常用的集合类 +import java.util.*; +// 导入Spring的Bean属性复制工具类 +import org.springframework.beans.BeanUtils; +// 导入Servlet请求相关类 +import javax.servlet.http.HttpServletRequest; +// 导入Spring的上下文加载器类 +import org.springframework.web.context.ContextLoader; +// 导入Servlet上下文类 +import javax.servlet.ServletContext; +// 导入令牌服务类 +import com.service.TokenService; +// 导入自定义工具类 +import com.utils.*; +// 导入反射调用异常类 +import java.lang.reflect.InvocationTargetException; +// 导入字典服务类 +import com.service.DictionaryService; +// 导入Apache Commons提供的字符串工具类 import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.util.ResourceUtils; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - +// 导入自定义的忽略权限注解类 import com.annotation.IgnoreAuth; +// 导入日志记录器接口 +import org.slf4j.Logger; +// 导入日志记录器工厂类 +import org.slf4j.LoggerFactory; +// 导入Spring的自动注入注解 +import org.springframework.beans.factory.annotation.Autowired; +// 导入Spring的控制器注解 +import org.springframework.stereotype.Controller; +// 导入Spring的请求映射注解 +import org.springframework.web.bind.annotation.*; +// 导入MyBatis-Plus的实体包装器类 import com.baomidou.mybatisplus.mapper.EntityWrapper; -import com.entity.ConfigEntity; -import com.entity.EIException; -import com.service.ConfigService; +// 导入MyBatis-Plus的查询包装器接口 +import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入自定义的实体类 +import com.entity.*; +// 导入自定义的视图类 +import com.entity.view.*; +// 导入自定义的服务类 +import com.service.*; +// 导入自定义的分页工具类 +import com.utils.PageUtils; +// 导入自定义的响应结果类 import com.utils.R; +// 导入阿里巴巴的JSON工具类 +import com.alibaba.fastjson.*; /** - * 上传文件映射表 + * 字典表 + * 后端接口 + * @author + * @email */ +// 声明该类为RESTful控制器 @RestController -@RequestMapping("file") -@SuppressWarnings({"unchecked","rawtypes"}) -public class FileController{ +// 声明该类为控制器 +@Controller +// 映射请求路径,所有以/dictionary开头的请求都会由该控制器处理 +@RequestMapping("/dictionary") +public class DictionaryController { + // 日志记录器,用于记录当前控制器类的日志信息 + private static final Logger logger = LoggerFactory.getLogger(DictionaryController.class); + + // 此处注解有误,应为@Autowired,自动注入用户服务类 + @Autow + private YonghuService yonghuService; + // 自动注入医生服务类 @Autowired - private ConfigService configService; + private YishengService yishengService; + /** - * 上传文件 + * 后端列表 */ - @RequestMapping("/upload") - public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception { - if (file.isEmpty()) { - throw new EIException("上传文件不能为空"); + // 映射/page请求路径,支持GET请求,且忽略权限验证 + @RequestMapping("/page") + @IgnoreAuth + public R page(@RequestParam Map params, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求参数 + logger.debug("page方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params)); + // 如果请求参数中没有指定排序字段,则默认按id排序 + if (params.get("orderBy") == null || params.get("orderBy") == "") { + params.put("orderBy", "id"); } - String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1); - File path = new File(ResourceUtils.getURL("classpath:static").getPath()); - if(!path.exists()) { - path = new File(""); + // 调用字典服务的queryPage方法,根据请求参数进行分页查询 + PageUtils page = dictionaryService.queryPage(params); + + // 将分页结果中的列表转换为字典视图列表 + List list = (List) page.getList(); + // 遍历字典视图列表 + for (DictionaryView c : list) { + // 调用字典服务的dictionaryConvert方法,修改对应字典表字段 + dictionaryService.dictionaryConvert(c, request); } - File upload = new File(path.getAbsolutePath(),"/upload/"); - if(!upload.exists()) { - upload.mkdirs(); + // 返回成功响应,并将分页查询结果放入响应数据中 + return R.ok().put("data", page); + } + + /** + * 后端详情 + */ + // 映射/info/{id}请求路径,支持GET请求,{id}为路径变量 + @RequestMapping("/info/{id}") + public R info(@PathVariable("id") Long id, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求的id + logger.debug("info方法:,,Controller:{},,id:{}", this.getClass().getName(), id); + // 调用字典服务的selectById方法,根据id查询字典实体 + DictionaryEntity dictionary = dictionaryService.selectById(id); + // 如果查询到字典实体 + if (dictionary != null) { + // 创建字典视图对象 + DictionaryView view = new DictionaryView(); + // 使用BeanUtils将字典实体的属性复制到字典视图中 + BeanUtils.copyProperties(dictionary, view); + // 调用字典服务的dictionaryConvert方法,修改对应字典表字段 + dictionaryService.dictionaryConvert(view, request); + // 返回成功响应,并将字典视图对象放入响应数据中 + return R.ok().put("data", view); + } else { + // 如果未查询到数据,返回错误响应,错误码为511 + return R.error(511, "查不到数据"); } - String fileName = new Date().getTime()+"."+fileExt; - File dest = new File(upload.getAbsolutePath()+"/"+fileName); - file.transferTo(dest); - if(StringUtils.isNotBlank(type) && type.equals("1")) { - ConfigEntity configEntity = configService.selectOne(new EntityWrapper().eq("name", "faceFile")); - if(configEntity==null) { - configEntity = new ConfigEntity(); - configEntity.setName("faceFile"); - configEntity.setValue(fileName); - } else { - configEntity.setValue(fileName); + } + + /** + * 后端保存 + */ + // 映射/save请求路径,支持POST请求 + @RequestMapping("/save") + public R save(@RequestBody DictionaryEntity dictionary, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和要保存的字典实体信息 + logger.debug("save方法:,,Controller:{},,dictionary:{}", this.getClass().getName(), dictionary.toString()); + // 从请求会话中获取用户角色 + String role = String.valueOf(request.getSession().getAttribute("role")); + // 此条件永远为false,注释掉的代码表示永远不会进入该分支 + if (false) + return R.error(511, "永远不会进入"); + // 创建查询包装器,用于构建查询条件 + Wrapper queryWrapper = new EntityWrapper() + .eq("dic_code", dictionary.getDicCode()) + .eq("index_name", dictionary.getIndexName()); + // 如果字典代码包含_erji_types,则添加super_id的查询条件 + if (dictionary.getDicCode().contains("_erji_types")) { + queryWrapper.eq("super_id", dictionary.getSuperId()); + } + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 调用字典服务的selectOne方法,根据查询条件查询是否存在相同数据 + DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper); + // 如果未查询到相同数据 + if (dictionaryEntity == null) { + // 设置字典实体的创建时间为当前时间 + dictionary.setCreateTime(new Date()); + // 调用字典服务的insert方法,将字典实体插入数据库 + dictionaryService.insert(dictionary); + // 查询所有字典实体 + List dictionaryEntities = dictionaryService.selectList(new EntityWrapper()); + // 获取Servlet上下文 + ServletContext servletContext = request.getServletContext(); + // 创建一个Map用于存储字典数据 + Map> map = new HashMap<>(); + // 遍历所有字典实体 + for (DictionaryEntity d : dictionaryEntities) { + // 获取当前字典代码对应的子Map + Map m = map.get(d.getDicCode()); + // 如果子Map为空,则创建一个新的子Map + if (m == null || m.isEmpty()) { + m = new HashMap<>(); + } + // 将当前字典实体的代码索引和索引名称存入子Map + m.put(d.getCodeIndex(), d.getIndexName()); + // 将子Map存入主Map + map.put(d.getDicCode(), m); } - configService.insertOrUpdate(configEntity); + // 将主Map存入Servlet上下文的属性中 + servletContext.setAttribute("dictionaryMap", map); + // 返回成功响应 + return R.ok(); + } else { + // 如果查询到相同数据,返回错误响应,错误码为511 + return R.error(511, "表中有相同数据"); } - return R.ok().put("file", fileName); } - + /** - * 下载文件 + * 后端修改 */ - @IgnoreAuth - @RequestMapping("/download") - public ResponseEntity download(@RequestParam String fileName) { - try { - File path = new File(ResourceUtils.getURL("classpath:static").getPath()); - if(!path.exists()) { - path = new File(""); - } - File upload = new File(path.getAbsolutePath(),"/upload/"); - if(!upload.exists()) { - upload.mkdirs(); + // 映射/update请求路径,支持POST请求 + @RequestMapping("/update") + public R update(@RequestBody DictionaryEntity dictionary, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和要修改的字典实体信息 + logger.debug("update方法:,,Controller:{},,dictionary:{}", this.getClass().getName(), dictionary.toString()); + // 从请求会话中获取用户角色 + String role = String.valueOf(request.getSession().getAttribute("role")); + // 此条件注释掉,表示永远不会进入该分支 +// if (false) +// return R.error(511, "永远不会进入"); + // 创建查询包装器,用于构建查询条件,排除当前要修改的记录 + Wrapper queryWrapper = new EntityWrapper() + .notIn("id", dictionary.getId()) + .eq("dic_code", dictionary.getDicCode()) + .eq("index_name", dictionary.getIndexName()); + // 如果字典代码包含_erji_types,则添加super_id的查询条件 + if (dictionary.getDicCode().contains("_erji_types")) { + queryWrapper.eq("super_id", dictionary.getSuperId()); + } + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 调用字典服务的selectOne方法,根据查询条件查询是否存在相同数据 + DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper); + // 如果未查询到相同数据 + if (dictionaryEntity == null) { + // 调用字典服务的updateById方法,根据id更新字典实体 + dictionaryService.updateById(dictionary); + // 查询所有字典实体 + List dictionaryEntities = dictionaryService.selectList(new EntityWrapper()); + // 获取Servlet上下文 + ServletContext servletContext = request.getServletContext(); + // 创建一个Map用于存储字典数据 + Map> map = new HashMap<>(); + // 遍历所有字典实体 + for (DictionaryEntity d : dictionaryEntities) { + // 获取当前字典代码对应的子Map + Map m = map.get(d.getDicCode()); + // 如果子Map为空,则创建一个新的子Map + if (m == null || m.isEmpty()) { + m = new HashMap<>(); + } + // 将当前字典实体的代码索引和索引名称存入子Map + m.put(d.getCodeIndex(), d.getIndexName()); + // 将子Map存入主Map + map.put(d.getDicCode(), m); } - File file = new File(upload.getAbsolutePath()+"/"+fileName); - if(file.exists()){ - /*if(!fileService.canRead(file, SessionManager.getSessionUser())){ - getResponse().sendError(403); - }*/ - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); - headers.setContentDispositionFormData("attachment", fileName); - return new ResponseEntity(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED); + // 将主Map存入Servlet上下文的属性中 + servletContext.setAttribute("dictionaryMap", map); + // 返回成功响应 + return R.ok(); + } else { + // 如果查询到相同数据,返回错误响应,错误码为511 + return R.error(511, "表中有相同数据"); + } + } + + /** + * 删除 + */ + // 映射/delete请求路径,支持POST请求 + @RequestMapping("/delete") + public R delete(@RequestBody Integer[] ids) { + // 记录方法调用日志,包含控制器类名和要删除的记录id数组 + logger.debug("delete:,,Controller:{},,ids:{}", this.getClass().getName(), ids.toString()); + // 调用字典服务的deleteBatchIds方法,根据id数组批量删除记录 + dictionaryService.deleteBatchIds(Arrays.asList(ids)); + // 返回成功响应 + return R.ok(); + } + + /** + * 最大值 + */ + // 映射/maxCodeIndex请求路径,支持POST请求 + @RequestMapping("/maxCodeIndex") + public R maxCodeIndex(@RequestBody DictionaryEntity dictionary) { + // 记录方法调用日志,包含控制器类名和传入的字典实体信息 + logger.debug("maxCodeIndex:,,Controller:{},,dictionary:{}", this.getClass().getName(), dictionary.toString()); + // 创建一个列表,用于存储排序字段 + List descs = new ArrayList<>(); + // 添加按code_index降序排序的字段 + descs.add("code_index"); + // 创建查询包装器,用于构建查询条件 + Wrapper queryWrapper = new EntityWrapper() + .eq("dic_code", dictionary.getDicCode()) + .orderDesc(descs); + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 调用字典服务的selectList方法,根据查询条件查询字典实体列表 + List dictionaryEntityList = dictionaryService.selectList(queryWrapper); + // 如果查询到的列表不为空 + if (dictionaryEntityList != null) { + // 返回成功响应,并将最大的code_index加1作为结果放入响应数据中 + return R.ok().put("maxCodeIndex", dictionaryEntityList.get(0).getCodeIndex() + 1); + } else { + // 如果未查询到数据,返回成功响应,并将最大的code_index设为1 + return R.ok().put("maxCodeIndex", 1); + } + } + + /** + * 批量上传 + */ + // 映射/batchInsert请求路径,支持POST请求 + @RequestMapping("/batchInsert") + public R save(String fileName) { + // 记录方法调用日志,包含控制器类名和文件名 + logger.debug("batchInsert方法:,,Controller:{},,fileName:{}", this.getClass().getName(), fileName); + try { + // 创建一个列表,用于存储要上传的字典实体 + List dictionaryList = new ArrayList<>(); + // 创建一个Map,用于存储要查询的字段 + Map> seachFields = new HashMap<>(); + // 获取当前时间 + Date date = new Date(); + // 获取文件名中最后一个点的索引 + int lastIndexOf = fileName.lastIndexOf("."); + // 如果文件名中没有点,返回错误响应,错误码为511 + if (lastIndexOf == -1) { + return R.error(511, "该文件没有后缀"); + } else { + // 获取文件后缀 + String suffix = fileName.substring(lastIndexOf); + // 如果文件后缀不是.xls,返回错误响应,错误码为511 + if (!".xls".equals(suffix)) { + return R.error(511, "只支持后缀为xls的excel文件"); + } else { + // 获取文件的URL + URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName); + // 创建文件对象 + File file = new File(resource.getFile()); + // 如果文件不存在,返回错误响应,错误码为511 + if (!file.exists()) { + return R.error(511, "找不到上传文件,请联系管理员"); + } else { + // 使用PoiUtil工具类读取xls文件的数据 + List> dataList = PoiUtil.poiImport(file.getPath()); + // 删除第一行数据,因为第一行通常是表头 + dataList.remove(0); + // 遍历数据列表 + for (List data : dataList) { + // 创建一个新的字典实体 + DictionaryEntity dictionaryEntity = new DictionaryEntity(); + // 以下代码注释掉,表示需要根据实际情况修改字段赋值 +// dictionaryEntity.setDicCode(data.get(0)); //字段 要改的 +// dictionaryEntity.setDicName(data.get(0)); //字段名 要改的 +// dictionaryEntity.setCodeIndex(Integer.valueOf(data.get(0))); //编码 要改的 +// dictionaryEntity.setIndexName(data.get(0)); //编码名字 要改的 +// dictionaryEntity.setSuperId(Integer.valueOf(data.get(0))); //父字段id 要改的 +// dictionaryEntity.setBeizhu(data.get(0)); //备注 要改的 +// dictionaryEntity.setCreateTime(date);//时间 + // 将字典实体添加到上传列表中 + dictionaryList.add(dictionaryEntity); + + // 把要查询是否重复的字段放入map中 + } + + // 调用字典服务的insertBatch方法,批量插入字典实体 + dictionaryService.insertBatch(dictionaryList); + // 返回成功响应 + return R.ok(); + } + } } - } catch (IOException e) { - e.printStackTrace(); + } catch (Exception e) { + // 如果发生异常,返回错误响应,错误码为511 + return R.error(511, "批量插入数据异常,请联系管理员"); } - return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); } - -} +} \ No newline at end of file diff --git a/src/main/java/com/controller/GuahaoController.java b/src/main/java/com/controller/GuahaoController.java index f953ab6..e0c609f 100644 --- a/src/main/java/com/controller/GuahaoController.java +++ b/src/main/java/com/controller/GuahaoController.java @@ -1,35 +1,63 @@ - package com.controller; +// 导入文件操作相关类 import java.io.File; +// 导入用于高精度计算的类 import java.math.BigDecimal; +// 导入用于处理URL的类 import java.net.URL; +// 导入用于日期格式化的类 import java.text.SimpleDateFormat; +// 导入阿里巴巴的JSON对象类 import com.alibaba.fastjson.JSONObject; +// 导入常用的集合类 import java.util.*; +// 导入Spring的Bean属性复制工具类 import org.springframework.beans.BeanUtils; +// 导入Servlet请求相关类 import javax.servlet.http.HttpServletRequest; +// 导入Spring的上下文加载器类 import org.springframework.web.context.ContextLoader; +// 导入Servlet上下文类 import javax.servlet.ServletContext; +// 导入令牌服务类 import com.service.TokenService; +// 导入自定义工具类 import com.utils.*; +// 导入反射调用异常类 import java.lang.reflect.InvocationTargetException; +// 导入字典服务类 import com.service.DictionaryService; +// 导入Apache Commons提供的字符串工具类 import org.apache.commons.lang3.StringUtils; +// 导入自定义的忽略权限注解类 import com.annotation.IgnoreAuth; +// 导入日志记录器接口 import org.slf4j.Logger; +// 导入日志记录器工厂类 import org.slf4j.LoggerFactory; +// 导入Spring的自动注入注解 import org.springframework.beans.factory.annotation.Autowired; +// 导入Spring的控制器注解 import org.springframework.stereotype.Controller; +// 导入Spring的请求映射注解 import org.springframework.web.bind.annotation.*; +// 导入MyBatis-Plus的实体包装器类 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入MyBatis-Plus的查询包装器接口 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入自定义的实体类 import com.entity.*; +// 导入自定义的视图类 import com.entity.view.*; +// 导入自定义的服务类 import com.service.*; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的响应结果类 import com.utils.R; +// 导入阿里巴巴的JSON工具类 import com.alibaba.fastjson.*; /** @@ -37,205 +65,276 @@ import com.alibaba.fastjson.*; * 后端接口 * @author * @email -*/ + */ +// 声明该类为RESTful控制器 @RestController +// 声明该类为控制器 @Controller +// 映射请求路径,所有以/guahao开头的请求都会由该控制器处理 @RequestMapping("/guahao") public class GuahaoController { + // 日志记录器,用于记录当前控制器类的日志信息 private static final Logger logger = LoggerFactory.getLogger(GuahaoController.class); + // 自动注入挂号服务类,用于处理挂号相关业务逻辑 @Autowired private GuahaoService guahaoService; - + // 自动注入令牌服务类 @Autowired private TokenService tokenService; + // 自动注入字典服务类 @Autowired private DictionaryService dictionaryService; - //级联表service + // 级联表service,自动注入医生服务类 @Autowired private YishengService yishengService; + // 级联表service,自动注入用户服务类 @Autowired private YonghuService yonghuService; - - /** - * 后端列表 - */ + * 后端列表 + */ + // 映射/page请求路径,支持GET请求 @RequestMapping("/page") - public R page(@RequestParam Map params, HttpServletRequest request){ - logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); + public R page(@RequestParam Map params, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求参数 + logger.debug("page方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params)); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); - if(false) - return R.error(511,"永不会进入"); - else if("用户".equals(role)) - params.put("yonghuId",request.getSession().getAttribute("userId")); - else if("医生".equals(role)) - params.put("yishengId",request.getSession().getAttribute("userId")); - if(params.get("orderBy")==null || params.get("orderBy")==""){ - params.put("orderBy","id"); + // 此条件永远为false,注释掉的代码表示永远不会进入该分支 + if (false) + return R.error(511, "永不会进入"); + // 如果用户角色为"用户" + else if ("用户".equals(role)) + // 在请求参数中添加用户id + params.put("yonghuId", request.getSession().getAttribute("userId")); + // 如果用户角色为"医生" + else if ("医生".equals(role)) + // 在请求参数中添加医生id + params.put("yishengId", request.getSession().getAttribute("userId")); + // 如果请求参数中没有指定排序字段,则默认按id排序 + if (params.get("orderBy") == null || params.get("orderBy") == "") { + params.put("orderBy", "id"); } + // 调用挂号服务的queryPage方法,根据请求参数进行分页查询 PageUtils page = guahaoService.queryPage(params); - //字典表数据转换 - List list =(List)page.getList(); - for(GuahaoView c:list){ - //修改对应字典表字段 + // 将分页结果中的列表转换为挂号视图列表 + List list = (List) page.getList(); + // 遍历挂号视图列表 + for (GuahaoView c : list) { + // 调用字典服务的dictionaryConvert方法,修改对应字典表字段 dictionaryService.dictionaryConvert(c, request); } + // 返回成功响应,并将分页查询结果放入响应数据中 return R.ok().put("data", page); } /** - * 后端详情 - */ + * 后端详情 + */ + // 映射/info/{id}请求路径,支持GET请求,{id}为路径变量 @RequestMapping("/info/{id}") - public R info(@PathVariable("id") Long id, HttpServletRequest request){ - logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); + public R info(@PathVariable("id") Long id, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求的id + logger.debug("info方法:,,Controller:{},,id:{}", this.getClass().getName(), id); + // 调用挂号服务的selectById方法,根据id查询挂号实体 GuahaoEntity guahao = guahaoService.selectById(id); - if(guahao !=null){ - //entity转view + // 如果查询到挂号实体 + if (guahao != null) { + // 创建挂号视图对象 GuahaoView view = new GuahaoView(); - BeanUtils.copyProperties( guahao , view );//把实体数据重构到view中 - - //级联表 - YishengEntity yisheng = yishengService.selectById(guahao.getYishengId()); - if(yisheng != null){ - BeanUtils.copyProperties( yisheng , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段 - view.setYishengId(yisheng.getId()); - } - //级联表 - YonghuEntity yonghu = yonghuService.selectById(guahao.getYonghuId()); - if(yonghu != null){ - BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段 - view.setYonghuId(yonghu.getId()); - } - //修改对应字典表字段 + // 使用BeanUtils将挂号实体的属性复制到挂号视图中 + BeanUtils.copyProperties(guahao, view); + + // 级联查询医生信息 + YishengEntity yisheng = yishengService.selectById(guahao.getYishengId()); + // 如果查询到医生信息 + if (yisheng != null) { + // 将医生信息的部分属性复制到挂号视图中,并排除指定字段 + BeanUtils.copyProperties(yisheng, view, new String[]{"id", "createTime", "insertTime", "updateTime"}); + // 设置挂号视图中的医生id + view.setYishengId(yisheng.getId()); + } + // 级联查询用户信息 + YonghuEntity yonghu = yonghuService.selectById(guahao.getYonghuId()); + // 如果查询到用户信息 + if (yonghu != null) { + // 将用户信息的部分属性复制到挂号视图中,并排除指定字段 + BeanUtils.copyProperties(yonghu, view, new String[]{"id", "createTime", "insertTime", "updateTime"}); + // 设置挂号视图中的用户id + view.setYonghuId(yonghu.getId()); + } + // 调用字典服务的dictionaryConvert方法,修改对应字典表字段 dictionaryService.dictionaryConvert(view, request); + // 返回成功响应,并将挂号视图对象放入响应数据中 return R.ok().put("data", view); - }else { - return R.error(511,"查不到数据"); + } else { + // 如果未查询到数据,返回错误响应,错误码为511 + return R.error(511, "查不到数据"); } - } /** - * 后端保存 - */ + * 后端保存 + */ + // 映射/save请求路径,支持POST请求 @RequestMapping("/save") - public R save(@RequestBody GuahaoEntity guahao, HttpServletRequest request){ - logger.debug("save方法:,,Controller:{},,guahao:{}",this.getClass().getName(),guahao.toString()); - + public R save(@RequestBody GuahaoEntity guahao, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和要保存的挂号实体信息 + logger.debug("save方法:,,Controller:{},,guahao:{}", this.getClass().getName(), guahao.toString()); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); - if(false) - return R.error(511,"永远不会进入"); - else if("医生".equals(role)) + // 此条件永远为false,注释掉的代码表示永远不会进入该分支 + if (false) + return R.error(511, "永远不会进入"); + // 如果用户角色为"医生" + else if ("医生".equals(role)) + // 设置挂号实体的医生id为当前会话中的用户id guahao.setYishengId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")))); - else if("用户".equals(role)) + // 如果用户角色为"用户" + else if ("用户".equals(role)) + // 设置挂号实体的用户id为当前会话中的用户id guahao.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")))); + // 创建查询包装器,用于构建查询条件 Wrapper queryWrapper = new EntityWrapper() - .eq("yisheng_id", guahao.getYishengId()) - .eq("yonghu_id", guahao.getYonghuId()) - .eq("guahao_uuin_number", guahao.getGuahaoUuinNumber()) - .eq("guahao_time", new SimpleDateFormat("yyyy-MM-dd").format(guahao.getGuahaoTime())) - .eq("guahao_types", guahao.getGuahaoTypes()) - .eq("guahao_status_types", guahao.getGuahaoStatusTypes()) - .eq("guahao_yesno_types", guahao.getGuahaoYesnoTypes()) - .eq("guahao_yesno_text", guahao.getGuahaoYesnoText()) - ; - - logger.info("sql语句:"+queryWrapper.getSqlSegment()); + .eq("yisheng_id", guahao.getYishengId()) + .eq("yonghu_id", guahao.getYonghuId()) + .eq("guahao_uuin_number", guahao.getGuahaoUuinNumber()) + .eq("guahao_time", new SimpleDateFormat("yyyy-MM-dd").format(guahao.getGuahaoTime())) + .eq("guahao_types", guahao.getGuahaoTypes()) + .eq("guahao_status_types", guahao.getGuahaoStatusTypes()) + .eq("guahao_yesno_types", guahao.getGuahaoYesnoTypes()) + .eq("guahao_yesno_text", guahao.getGuahaoYesnoText()); + + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 调用挂号服务的selectOne方法,根据查询条件查询是否存在相同数据 GuahaoEntity guahaoEntity = guahaoService.selectOne(queryWrapper); - if(guahaoEntity==null){ + // 如果未查询到相同数据 + if (guahaoEntity == null) { + // 设置挂号审核类型为1 guahao.setGuahaoYesnoTypes(1); + // 设置挂号实体的创建时间为当前时间 guahao.setCreateTime(new Date()); + // 调用挂号服务的insert方法,将挂号实体插入数据库 guahaoService.insert(guahao); + // 返回成功响应 return R.ok(); - }else { - return R.error(511,"表中有相同数据"); + } else { + // 如果查询到相同数据,返回错误响应,错误码为511 + return R.error(511, "表中有相同数据"); } } /** - * 后端修改 - */ + * 后端修改 + */ + // 映射/update请求路径,支持POST请求 @RequestMapping("/update") - public R update(@RequestBody GuahaoEntity guahao, HttpServletRequest request){ - logger.debug("update方法:,,Controller:{},,guahao:{}",this.getClass().getName(),guahao.toString()); - + public R update(@RequestBody GuahaoEntity guahao, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和要修改的挂号实体信息 + logger.debug("update方法:,,Controller:{},,guahao:{}", this.getClass().getName(), guahao.toString()); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); -// if(false) -// return R.error(511,"永远不会进入"); -// else if("医生".equals(role)) + // 此条件注释掉,表示永远不会进入该分支 +// if (false) +// return R.error(511, "永远不会进入"); +// else if ("医生".equals(role)) // guahao.setYishengId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")))); -// else if("用户".equals(role)) +// else if ("用户".equals(role)) // guahao.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")))); - //根据字段查询是否有相同数据 + // 创建查询包装器,用于构建查询条件,排除当前要修改的记录 Wrapper queryWrapper = new EntityWrapper() - .notIn("id",guahao.getId()) - .andNew() - .eq("yisheng_id", guahao.getYishengId()) - .eq("yonghu_id", guahao.getYonghuId()) - .eq("guahao_uuin_number", guahao.getGuahaoUuinNumber()) - .eq("guahao_time", guahao.getGuahaoTime()) - .eq("guahao_types", guahao.getGuahaoTypes()) - .eq("guahao_status_types", guahao.getGuahaoStatusTypes()) - .eq("guahao_yesno_types", guahao.getGuahaoYesnoTypes()) - .eq("guahao_yesno_text", guahao.getGuahaoYesnoText()) - ; - - logger.info("sql语句:"+queryWrapper.getSqlSegment()); + .notIn("id", guahao.getId()) + .andNew() + .eq("yisheng_id", guahao.getYishengId()) + .eq("yonghu_id", guahao.getYonghuId()) + .eq("guahao_uuin_number", guahao.getGuahaoUuinNumber()) + .eq("guahao_time", guahao.getGuahaoTime()) + .eq("guahao_types", guahao.getGuahaoTypes()) + .eq("guahao_status_types", guahao.getGuahaoStatusTypes()) + .eq("guahao_yesno_types", guahao.getGuahaoYesnoTypes()) + .eq("guahao_yesno_text", guahao.getGuahaoYesnoText()); + + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 调用挂号服务的selectOne方法,根据查询条件查询是否存在相同数据 GuahaoEntity guahaoEntity = guahaoService.selectOne(queryWrapper); - if(guahaoEntity==null){ - guahaoService.updateById(guahao);//根据id更新 + // 如果未查询到相同数据 + if (guahaoEntity == null) { + // 调用挂号服务的updateById方法,根据id更新挂号实体 + guahaoService.updateById(guahao); + // 返回成功响应 return R.ok(); - }else { - return R.error(511,"表中有相同数据"); + } else { + // 如果查询到相同数据,返回错误响应,错误码为511 + return R.error(511, "表中有相同数据"); } } /** - * 删除 - */ + * 删除 + */ + // 映射/delete请求路径,支持POST请求 @RequestMapping("/delete") - public R delete(@RequestBody Integer[] ids){ - logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); + public R delete(@RequestBody Integer[] ids) { + // 记录方法调用日志,包含控制器类名和要删除的记录id数组 + logger.debug("delete:,,Controller:{},,ids:{}", this.getClass().getName(), ids.toString()); + // 调用挂号服务的deleteBatchIds方法,根据id数组批量删除记录 guahaoService.deleteBatchIds(Arrays.asList(ids)); + // 返回成功响应 return R.ok(); } - /** * 批量上传 */ + // 映射/batchInsert请求路径,支持POST请求 @RequestMapping("/batchInsert") - public R save( String fileName){ - logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); + public R save(String fileName) { + // 记录方法调用日志,包含控制器类名和文件名 + logger.debug("batchInsert方法:,,Controller:{},,fileName:{}", this.getClass().getName(), fileName); try { - List guahaoList = new ArrayList<>();//上传的东西 - Map> seachFields= new HashMap<>();//要查询的字段 + // 创建一个列表,用于存储要上传的挂号实体 + List guahaoList = new ArrayList<>(); + // 创建一个Map,用于存储要查询的字段 + Map> seachFields = new HashMap<>(); + // 获取当前时间 Date date = new Date(); + // 获取文件名中最后一个点的索引 int lastIndexOf = fileName.lastIndexOf("."); - if(lastIndexOf == -1){ - return R.error(511,"该文件没有后缀"); - }else{ + // 如果文件名中没有点,返回错误响应,错误码为511 + if (lastIndexOf == -1) { + return R.error(511, "该文件没有后缀"); + } else { + // 获取文件后缀 String suffix = fileName.substring(lastIndexOf); - if(!".xls".equals(suffix)){ - return R.error(511,"只支持后缀为xls的excel文件"); - }else{ - URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径 + // 如果文件后缀不是.xls,返回错误响应,错误码为511 + if (!".xls".equals(suffix)) { + return R.error(511, "只支持后缀为xls的excel文件"); + } else { + // 获取文件的URL + URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName); + // 创建文件对象 File file = new File(resource.getFile()); - if(!file.exists()){ - return R.error(511,"找不到上传文件,请联系管理员"); - }else{ - List> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件 - dataList.remove(0);//删除第一行,因为第一行是提示 - for(List data:dataList){ - //循环 + // 如果文件不存在,返回错误响应,错误码为511 + if (!file.exists()) { + return R.error(511, "找不到上传文件,请联系管理员"); + } else { + // 使用PoiUtil工具类读取xls文件的数据 + List> dataList = PoiUtil.poiImport(file.getPath()); + // 删除第一行数据,因为第一行通常是表头 + dataList.remove(0); + // 遍历数据列表 + for (List data : dataList) { + // 创建一个新的挂号实体 GuahaoEntity guahaoEntity = new GuahaoEntity(); + // 以下代码注释掉,表示需要根据实际情况修改字段赋值 // guahaoEntity.setYishengId(Integer.valueOf(data.get(0))); //医生 要改的 // guahaoEntity.setYonghuId(Integer.valueOf(data.get(0))); //用户 要改的 // guahaoEntity.setGuahaoUuinNumber(Integer.valueOf(data.get(0))); //就诊识别码 要改的 @@ -245,119 +344,10 @@ public class GuahaoController { // guahaoEntity.setGuahaoYesnoTypes(Integer.valueOf(data.get(0))); //挂号审核 要改的 // guahaoEntity.setGuahaoYesnoText(data.get(0)); //审核结果 要改的 // guahaoEntity.setCreateTime(date);//时间 + // 将挂号实体添加到上传列表中 guahaoList.add(guahaoEntity); - - //把要查询是否重复的字段放入map中 + // 把要查询是否重复的字段放入map中 } - //查询是否重复 - guahaoService.insertBatch(guahaoList); - return R.ok(); - } - } - } - }catch (Exception e){ - return R.error(511,"批量插入数据异常,请联系管理员"); - } - } - - - - - - /** - * 前端列表 - */ - @IgnoreAuth - @RequestMapping("/list") - public R list(@RequestParam Map params, HttpServletRequest request){ - logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); - - // 没有指定排序字段就默认id倒序 - if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){ - params.put("orderBy","id"); - } - PageUtils page = guahaoService.queryPage(params); - - //字典表数据转换 - List list =(List)page.getList(); - for(GuahaoView c:list) - dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段 - return R.ok().put("data", page); - } - - /** - * 前端详情 - */ - @RequestMapping("/detail/{id}") - public R detail(@PathVariable("id") Long id, HttpServletRequest request){ - logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id); - GuahaoEntity guahao = guahaoService.selectById(id); - if(guahao !=null){ - - - //entity转view - GuahaoView view = new GuahaoView(); - BeanUtils.copyProperties( guahao , view );//把实体数据重构到view中 - - //级联表 - YishengEntity yisheng = yishengService.selectById(guahao.getYishengId()); - if(yisheng != null){ - BeanUtils.copyProperties( yisheng , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段 - view.setYishengId(yisheng.getId()); - } - //级联表 - YonghuEntity yonghu = yonghuService.selectById(guahao.getYonghuId()); - if(yonghu != null){ - BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段 - view.setYonghuId(yonghu.getId()); - } - //修改对应字典表字段 - dictionaryService.dictionaryConvert(view, request); - return R.ok().put("data", view); - }else { - return R.error(511,"查不到数据"); - } - } - - - /** - * 前端保存 - */ - @RequestMapping("/add") - public R add(@RequestBody GuahaoEntity guahao, HttpServletRequest request){ - logger.debug("add方法:,,Controller:{},,guahao:{}",this.getClass().getName(),guahao.toString()); - Wrapper queryWrapper = new EntityWrapper() - .eq("yisheng_id", guahao.getYishengId()) - .eq("yonghu_id", guahao.getYonghuId()) - .eq("guahao_uuin_number", guahao.getGuahaoUuinNumber()) - .eq("guahao_types", guahao.getGuahaoTypes()) - .eq("guahao_status_types", guahao.getGuahaoStatusTypes()) - .eq("guahao_yesno_types", guahao.getGuahaoYesnoTypes()) - .eq("guahao_yesno_text", guahao.getGuahaoYesnoText()) - ; - logger.info("sql语句:"+queryWrapper.getSqlSegment()); - GuahaoEntity guahaoEntity = guahaoService.selectOne(queryWrapper); - if(guahaoEntity==null){ - guahao.setGuahaoYesnoTypes(1); - guahao.setCreateTime(new Date()); - YonghuEntity userId = yonghuService.selectById((Integer) request.getSession().getAttribute("userId")); - YishengEntity yishengEntity = yishengService.selectById(guahao.getYishengId()); - if(userId.getNewMoney() params, HttpServletRequest request){ - logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); + public R page(@RequestParam Map params, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求参数 + logger.debug("page方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params)); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); - if(false) - return R.error(511,"永不会进入"); - else if("用户".equals(role)) - params.put("yonghuId",request.getSession().getAttribute("userId")); - else if("医生".equals(role)) - params.put("yishengId",request.getSession().getAttribute("userId")); - params.put("jiankangjiaoyuDeleteStart",1);params.put("jiankangjiaoyuDeleteEnd",1); - if(params.get("orderBy")==null || params.get("orderBy")==""){ - params.put("orderBy","id"); + // 此条件永远为false,注释掉的代码表示永远不会进入该分支 + if (false) + return R.error(511, "永不会进入"); + // 如果用户角色为"用户" + else if ("用户".equals(role)) + // 在请求参数中添加用户id + params.put("yonghuId", request.getSession().getAttribute("userId")); + // 如果用户角色为"医生" + else if ("医生".equals(role)) + // 在请求参数中添加医生id + params.put("yishengId", request.getSession().getAttribute("userId")); + // 设置查询条件,限定健康教育未被删除(逻辑删除字段值为1) + params.put("jiankangjiaoyuDeleteStart", 1); + params.put("jiankangjiaoyuDeleteEnd", 1); + // 如果请求参数中没有指定排序字段,则默认按id排序 + if (params.get("orderBy") == null || params.get("orderBy") == "") { + params.put("orderBy", "id"); } + // 调用健康教育服务的queryPage方法,根据请求参数进行分页查询 PageUtils page = jiankangjiaoyuService.queryPage(params); - //字典表数据转换 - List list =(List)page.getList(); - for(JiankangjiaoyuView c:list){ - //修改对应字典表字段 + // 将分页结果中的列表转换为健康教育视图列表 + List list = (List) page.getList(); + // 遍历健康教育视图列表 + for (JiankangjiaoyuView c : list) { + // 调用字典服务的dictionaryConvert方法,修改对应字典表字段 dictionaryService.dictionaryConvert(c, request); } + // 返回成功响应,并将分页查询结果放入响应数据中 return R.ok().put("data", page); } /** - * 后端详情 - */ + * 后端详情 + */ + // 映射/info/{id}请求路径,支持GET请求,{id}为路径变量,用于获取指定id的健康教育信息详情 @RequestMapping("/info/{id}") - public R info(@PathVariable("id") Long id, HttpServletRequest request){ - logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); + public R info(@PathVariable("id") Long id, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求的id + logger.debug("info方法:,,Controller:{},,id:{}", this.getClass().getName(), id); + // 调用健康教育服务的selectById方法,根据id查询健康教育实体 JiankangjiaoyuEntity jiankangjiaoyu = jiankangjiaoyuService.selectById(id); - if(jiankangjiaoyu !=null){ - //entity转view + // 如果查询到健康教育实体 + if (jiankangjiaoyu != null) { + // 创建健康教育视图对象 JiankangjiaoyuView view = new JiankangjiaoyuView(); - BeanUtils.copyProperties( jiankangjiaoyu , view );//把实体数据重构到view中 + // 使用BeanUtils将健康教育实体的属性复制到健康教育视图中 + BeanUtils.copyProperties(jiankangjiaoyu, view); - //修改对应字典表字段 + // 调用字典服务的dictionaryConvert方法,修改对应字典表字段 dictionaryService.dictionaryConvert(view, request); + // 返回成功响应,并将健康教育视图对象放入响应数据中 return R.ok().put("data", view); - }else { - return R.error(511,"查不到数据"); + } else { + // 如果未查询到数据,返回错误响应,错误码为511 + return R.error(511, "查不到数据"); } - } /** - * 后端保存 - */ + * 后端保存 + */ + // 映射/save请求路径,支持POST请求,用于保存新的健康教育信息 @RequestMapping("/save") - public R save(@RequestBody JiankangjiaoyuEntity jiankangjiaoyu, HttpServletRequest request){ - logger.debug("save方法:,,Controller:{},,jiankangjiaoyu:{}",this.getClass().getName(),jiankangjiaoyu.toString()); - + public R save(@RequestBody JiankangjiaoyuEntity jiankangjiaoyu, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和要保存的健康教育实体信息 + logger.debug("save方法:,,Controller:{},,jiankangjiaoyu:{}", this.getClass().getName(), jiankangjiaoyu.toString()); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); - if(false) - return R.error(511,"永远不会进入"); + // 此条件永远为false,注释掉的代码表示永远不会进入该分支 + if (false) + return R.error(511, "永远不会进入"); + // 创建查询包装器,用于构建查询条件,检查是否存在相同的健康教育信息 Wrapper queryWrapper = new EntityWrapper() - .eq("jiankangjiaoyu_name", jiankangjiaoyu.getJiankangjiaoyuName()) - .eq("jiankangjiaoyu_types", jiankangjiaoyu.getJiankangjiaoyuTypes()) - .eq("jiankangjiaoyu_delete", jiankangjiaoyu.getJiankangjiaoyuDelete()) - ; + .eq("jiankangjiaoyu_name", jiankangjiaoyu.getJiankangjiaoyuName()) + .eq("jiankangjiaoyu_types", jiankangjiaoyu.getJiankangjiaoyuTypes()) + .eq("jiankangjiaoyu_delete", jiankangjiaoyu.getJiankangjiaoyuDelete()); - logger.info("sql语句:"+queryWrapper.getSqlSegment()); + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 调用健康教育服务的selectOne方法,根据查询条件查询是否存在相同数据 JiankangjiaoyuEntity jiankangjiaoyuEntity = jiankangjiaoyuService.selectOne(queryWrapper); - if(jiankangjiaoyuEntity==null){ + // 如果未查询到相同数据 + if (jiankangjiaoyuEntity == null) { + // 设置插入时间为当前时间 jiankangjiaoyu.setInsertTime(new Date()); + // 设置逻辑删除字段为1,表示未删除 jiankangjiaoyu.setJiankangjiaoyuDelete(1); + // 设置创建时间为当前时间 jiankangjiaoyu.setCreateTime(new Date()); + // 调用健康教育服务的insert方法,将健康教育实体插入数据库 jiankangjiaoyuService.insert(jiankangjiaoyu); + // 返回成功响应 return R.ok(); - }else { - return R.error(511,"表中有相同数据"); + } else { + // 如果查询到相同数据,返回错误响应,错误码为511 + return R.error(511, "表中有相同数据"); } } /** - * 后端修改 - */ + * 后端修改 + */ + // 映射/update请求路径,支持POST请求,用于修改已有的健康教育信息 @RequestMapping("/update") - public R update(@RequestBody JiankangjiaoyuEntity jiankangjiaoyu, HttpServletRequest request){ - logger.debug("update方法:,,Controller:{},,jiankangjiaoyu:{}",this.getClass().getName(),jiankangjiaoyu.toString()); - + public R update(@RequestBody JiankangjiaoyuEntity jiankangjiaoyu, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和要修改的健康教育实体信息 + logger.debug("update方法:,,Controller:{},,jiankangjiaoyu:{}", this.getClass().getName(), jiankangjiaoyu.toString()); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); -// if(false) -// return R.error(511,"永远不会进入"); - //根据字段查询是否有相同数据 + // 此条件注释掉,表示永远不会进入该分支 +// if (false) +// return R.error(511, "永远不会进入"); + // 创建查询包装器,用于构建查询条件,排除当前要修改的记录,检查是否存在相同的健康教育信息 Wrapper queryWrapper = new EntityWrapper() - .notIn("id",jiankangjiaoyu.getId()) - .andNew() - .eq("jiankangjiaoyu_name", jiankangjiaoyu.getJiankangjiaoyuName()) - .eq("jiankangjiaoyu_types", jiankangjiaoyu.getJiankangjiaoyuTypes()) - .eq("jiankangjiaoyu_delete", jiankangjiaoyu.getJiankangjiaoyuDelete()) - ; - - logger.info("sql语句:"+queryWrapper.getSqlSegment()); + .notIn("id", jiankangjiaoyu.getId()) + .andNew() + .eq("jiankangjiaoyu_name", jiankangjiaoyu.getJiankangjiaoyuName()) + .eq("jiankangjiaoyu_types", jiankangjiaoyu.getJiankangjiaoyuTypes()) + .eq("jiankangjiaoyu_delete", jiankangjiaoyu.getJiankangjiaoyuDelete()); + + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 调用健康教育服务的selectOne方法,根据查询条件查询是否存在相同数据 JiankangjiaoyuEntity jiankangjiaoyuEntity = jiankangjiaoyuService.selectOne(queryWrapper); - if("".equals(jiankangjiaoyu.getJiankangjiaoyuPhoto()) || "null".equals(jiankangjiaoyu.getJiankangjiaoyuPhoto())){ - jiankangjiaoyu.setJiankangjiaoyuPhoto(null); + // 如果健康教育照片字段为空字符串或"null",则将其设置为null + if ("".equals(jiankangjiaoyu.getJiankangjiaoyuPhoto()) || "null".equals(jiankangjiaoyu.getJiankangjiaoyuPhoto())) { + jiankangjiaoyu.setJiankangjiaoyuPhoto(null); } - if(jiankangjiaoyuEntity==null){ - jiankangjiaoyuService.updateById(jiankangjiaoyu);//根据id更新 + // 如果未查询到相同数据 + if (jiankangjiaoyuEntity == null) { + // 调用健康教育服务的updateById方法,根据id更新健康教育实体 + jiankangjiaoyuService.updateById(jiankangjiaoyu); + // 返回成功响应 return R.ok(); - }else { - return R.error(511,"表中有相同数据"); + } else { + // 如果查询到相同数据,返回错误响应,错误码为511 + return R.error(511, "表中有相同数据"); } } /** - * 删除 - */ + * 删除 + */ + // 映射/delete请求路径,支持POST请求,用于删除健康教育信息(逻辑删除) @RequestMapping("/delete") - public R delete(@RequestBody Integer[] ids){ - logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); + public R delete(@RequestBody Integer[] ids) { + // 记录方法调用日志,包含控制器类名和要删除的记录id数组 + logger.debug("delete:,,Controller:{},,ids:{}", this.getClass().getName(), ids.toString()); + // 创建一个ArrayList,用于存储要更新的健康教育实体 ArrayList list = new ArrayList<>(); - for(Integer id:ids){ + // 遍历要删除的记录id数组 + for (Integer id : ids) { + // 创建一个新的健康教育实体 JiankangjiaoyuEntity jiankangjiaoyuEntity = new JiankangjiaoyuEntity(); + // 设置健康教育实体的id jiankangjiaoyuEntity.setId(id); + // 设置逻辑删除字段为2,表示已删除 jiankangjiaoyuEntity.setJiankangjiaoyuDelete(2); + // 将健康教育实体添加到列表中 list.add(jiankangjiaoyuEntity); } - if(list != null && list.size() >0){ + // 如果列表不为空 + if (list != null && list.size() > 0) { + // 调用健康教育服务的updateBatchById方法,批量更新健康教育实体 jiankangjiaoyuService.updateBatchById(list); } + // 返回成功响应 return R.ok(); } - /** * 批量上传 */ + // 映射/batchInsert请求路径,支持POST请求,用于批量上传健康教育信息 @RequestMapping("/batchInsert") - public R save( String fileName){ - logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); + public R save(String fileName) { + // 记录方法调用日志,包含控制器类名和文件名 + logger.debug("batchInsert方法:,,Controller:{},,fileName:{}", this.getClass().getName(), fileName); try { - List jiankangjiaoyuList = new ArrayList<>();//上传的东西 - Map> seachFields= new HashMap<>();//要查询的字段 + // 创建一个列表,用于存储要上传的健康教育实体 + List jiankangjiaoyuList = new ArrayList<>(); + // 创建一个Map,用于存储要查询的字段 + Map> seachFields = new HashMap<>(); + // 获取当前时间 Date date = new Date(); + // 获取文件名中最后一个点的索引 int lastIndexOf = fileName.lastIndexOf("."); - if(lastIndexOf == -1){ - return R.error(511,"该文件没有后缀"); - }else{ + // 如果文件名中没有点,返回错误响应,错误码为511 + if (lastIndexOf == -1) { + return R.error(511, "该文件没有后缀"); + } else { + // 获取文件后缀 String suffix = fileName.substring(lastIndexOf); - if(!".xls".equals(suffix)){ - return R.error(511,"只支持后缀为xls的excel文件"); - }else{ - URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径 + // 如果文件后缀不是.xls,返回错误响应,错误码为511 + if (!".xls".equals(suffix)) { + return R.error(511, "只支持后缀为xls的excel文件"); + } else { + // 获取文件的URL + URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName); + // 创建文件对象 File file = new File(resource.getFile()); - if(!file.exists()){ - return R.error(511,"找不到上传文件,请联系管理员"); - }else{ - List> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件 - dataList.remove(0);//删除第一行,因为第一行是提示 - for(List data:dataList){ - //循环 + // 如果文件不存在,返回错误响应,错误码为511 + if (!file.exists()) { + return R.error(511, "找不到上传文件,请联系管理员"); + } else { + // 使用PoiUtil工具类读取xls文件的数据 + List> dataList = PoiUtil.poiImport(file.getPath()); + // 删除第一行数据,因为第一行通常是表头 + dataList.remove(0); + // 遍历数据列表 + for (List data : dataList) { + // 创建一个新的健康教育实体 JiankangjiaoyuEntity jiankangjiaoyuEntity = new JiankangjiaoyuEntity(); + // 以下代码注释掉,表示需要根据实际情况修改字段赋值 // jiankangjiaoyuEntity.setJiankangjiaoyuName(data.get(0)); //健康教育标题 要改的 // jiankangjiaoyuEntity.setJiankangjiaoyuTypes(Integer.valueOf(data.get(0))); //健康教育类型 要改的 // jiankangjiaoyuEntity.setJiankangjiaoyuPhoto("");//照片 @@ -227,94 +327,111 @@ public class JiankangjiaoyuController { // jiankangjiaoyuEntity.setJiankangjiaoyuContent("");//照片 // jiankangjiaoyuEntity.setJiankangjiaoyuDelete(1);//逻辑删除字段 // jiankangjiaoyuEntity.setCreateTime(date);//时间 + // 将健康教育实体添加到上传列表中 jiankangjiaoyuList.add(jiankangjiaoyuEntity); - - //把要查询是否重复的字段放入map中 + // 把要查询是否重复的字段放入map中 } - //查询是否重复 + // 调用健康教育服务的insertBatch方法,批量插入健康教育实体 jiankangjiaoyuService.insertBatch(jiankangjiaoyuList); + // 返回成功响应 return R.ok(); } } } - }catch (Exception e){ - return R.error(511,"批量插入数据异常,请联系管理员"); + } catch (Exception e) { + // 如果发生异常,返回错误响应,错误码为511 + return R.error(511, "批量插入数据异常,请联系管理员"); } } - - - - /** - * 前端列表 - */ + * 前端列表 + */ + // 映射/list请求路径,支持GET请求,用于前端获取健康教育信息的分页列表,忽略权限验证 @IgnoreAuth @RequestMapping("/list") - public R list(@RequestParam Map params, HttpServletRequest request){ - logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); - - // 没有指定排序字段就默认id倒序 - if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){ - params.put("orderBy","id"); + public R list(@RequestParam Map params, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求参数 + logger.debug("list方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params)); + // 如果请求参数中没有指定排序字段,则默认按id倒序排序 + if (StringUtil.isEmpty(String.valueOf(params.get("orderBy")))) { + params.put("orderBy", "id"); } + // 调用健康教育服务的queryPage方法,根据请求参数进行分页查询 PageUtils page = jiankangjiaoyuService.queryPage(params); - //字典表数据转换 - List list =(List)page.getList(); - for(JiankangjiaoyuView c:list) - dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段 + // 将分页结果中的列表转换为健康教育视图列表 + List list = (List) page.getList(); + // 遍历健康教育视图列表 + for (JiankangjiaoyuView c : list) + // 调用字典服务的dictionaryConvert方法,修改对应字典表字段 + dictionaryService.dictionaryConvert(c, request); + // 返回成功响应,并将分页查询结果放入响应数据中 return R.ok().put("data", page); } /** - * 前端详情 - */ + * 前端详情 + */ + // 映射/detail/{id}请求路径,支持GET请求,{id}为路径变量,用于前端获取指定id的健康教育信息详情 @RequestMapping("/detail/{id}") - public R detail(@PathVariable("id") Long id, HttpServletRequest request){ - logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id); + public R detail(@PathVariable("id") Long id, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求的id + logger.debug("detail方法:,,Controller:{},,id:{}", this.getClass().getName(), id); + // 调用健康教育服务的selectById方法,根据id查询健康教育实体 JiankangjiaoyuEntity jiankangjiaoyu = jiankangjiaoyuService.selectById(id); - if(jiankangjiaoyu !=null){ - - - //entity转view - JiankangjiaoyuView view = new JiankangjiaoyuView(); - BeanUtils.copyProperties( jiankangjiaoyu , view );//把实体数据重构到view中 + // 如果查询到健康教育实体 + if (jiankangjiaoyu != null) { + // 创建健康教育视图对象 + JiankangjiaoyuView view = new JiankangjiaoyuView(); + // 使用BeanUtils将健康教育实体的属性复制到健康教育视图中 + BeanUtils.copyProperties(jiankangjiaoyu, view); - //修改对应字典表字段 - dictionaryService.dictionaryConvert(view, request); - return R.ok().put("data", view); - }else { - return R.error(511,"查不到数据"); - } + // 调用字典服务的dictionaryConvert方法,修改对应字典表字段 + dictionaryService.dictionaryConvert(view, request); + // 返回成功响应,并将健康教育视图对象放入响应数据中 + return R.ok().put("data", view); + } else { + // 如果未查询到数据,返回错误响应,错误码为511 + return R.error(511, "查不到数据"); + } } - /** - * 前端保存 - */ + * 前端保存 + */ + // 映射/add请求路径,支持POST请求,用于前端保存新的健康教育信息 @RequestMapping("/add") - public R add(@RequestBody JiankangjiaoyuEntity jiankangjiaoyu, HttpServletRequest request){ - logger.debug("add方法:,,Controller:{},,jiankangjiaoyu:{}",this.getClass().getName(),jiankangjiaoyu.toString()); + public R add(@RequestBody JiankangjiaoyuEntity jiankangjiaoyu, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和要保存的健康教育实体信息 + logger.debug("add方法:,,Controller:{},,jiankangjiaoyu:{}", this.getClass().getName(), jiankangjiaoyu.toString()); + // 创建查询包装器,用于构建查询条件,检查是否存在相同的健康教育信息 Wrapper queryWrapper = new EntityWrapper() - .eq("jiankangjiaoyu_name", jiankangjiaoyu.getJiankangjiaoyuName()) - .eq("jiankangjiaoyu_types", jiankangjiaoyu.getJiankangjiaoyuTypes()) - .eq("jiankangjiaoyu_delete", jiankangjiaoyu.getJiankangjiaoyuDelete()) - ; - logger.info("sql语句:"+queryWrapper.getSqlSegment()); + .eq("jiankangjiaoyu_name", jiankangjiaoyu.getJiankangjiaoyuName()) + .eq("jiankangjiaoyu_types", jiankangjiaoyu.getJiankangjiaoyuTypes()) + .eq("jiankangjiaoyu_delete", jiankangjiaoyu.getJiankangjiaoyuDelete()); + + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 调用健康教育服务的selectOne方法,根据查询条件查询是否存在相同数据 JiankangjiaoyuEntity jiankangjiaoyuEntity = jiankangjiaoyuService.selectOne(queryWrapper); - if(jiankangjiaoyuEntity==null){ + // 如果未查询到相同数据 + if (jiankangjiaoyuEntity == null) { + // 设置插入时间为当前时间 jiankangjiaoyu.setInsertTime(new Date()); + // 设置逻辑删除字段为1,表示未删除 jiankangjiaoyu.setJiankangjiaoyuDelete(1); + // 设置创建时间为当前时间 jiankangjiaoyu.setCreateTime(new Date()); - jiankangjiaoyuService.insert(jiankangjiaoyu); + // 调用健康教育服务的insert方法,将健康教育实体插入数据库 + jiankangjiaoyuService.insert(jiankangjiaoyu); + // 返回成功响应 return R.ok(); - }else { - return R.error(511,"表中有相同数据"); + } else { + // 如果查询到相同数据,返回错误响应,错误码为511 + return R.error(511, "表中有相同数据"); } } - - -} +} \ No newline at end of file diff --git a/src/main/java/com/controller/NewsController.java b/src/main/java/com/controller/NewsController.java index b60b121..2ae7a01 100644 --- a/src/main/java/com/controller/NewsController.java +++ b/src/main/java/com/controller/NewsController.java @@ -1,35 +1,63 @@ - package com.controller; +// 导入文件操作相关类 import java.io.File; +// 导入用于高精度计算的类 import java.math.BigDecimal; +// 导入用于处理URL的类 import java.net.URL; +// 导入用于日期格式化的类 import java.text.SimpleDateFormat; +// 导入阿里巴巴的JSON对象类 import com.alibaba.fastjson.JSONObject; +// 导入常用的集合类 import java.util.*; +// 导入Spring的Bean属性复制工具类 import org.springframework.beans.BeanUtils; +// 导入Servlet请求相关类 import javax.servlet.http.HttpServletRequest; +// 导入Spring的上下文加载器类 import org.springframework.web.context.ContextLoader; +// 导入Servlet上下文类 import javax.servlet.ServletContext; +// 导入令牌服务类 import com.service.TokenService; +// 导入自定义工具类 import com.utils.*; +// 导入反射调用异常类 import java.lang.reflect.InvocationTargetException; +// 导入字典服务类 import com.service.DictionaryService; +// 导入Apache Commons提供的字符串工具类 import org.apache.commons.lang3.StringUtils; +// 导入自定义的忽略权限注解类 import com.annotation.IgnoreAuth; +// 导入日志记录器接口 import org.slf4j.Logger; +// 导入日志记录器工厂类 import org.slf4j.LoggerFactory; +// 导入Spring的自动注入注解 import org.springframework.beans.factory.annotation.Autowired; +// 导入Spring的控制器注解 import org.springframework.stereotype.Controller; +// 导入Spring的请求映射注解 import org.springframework.web.bind.annotation.*; +// 导入MyBatis-Plus的实体包装器类 import com.baomidou.mybatisplus.mapper.EntityWrapper; +// 导入MyBatis-Plus的查询包装器接口 import com.baomidou.mybatisplus.mapper.Wrapper; +// 导入自定义的实体类 import com.entity.*; +// 导入自定义的视图类 import com.entity.view.*; +// 导入自定义的服务类 import com.service.*; +// 导入自定义的分页工具类 import com.utils.PageUtils; +// 导入自定义的响应结果类 import com.utils.R; +// 导入阿里巴巴的JSON工具类 import com.alibaba.fastjson.*; /** @@ -37,268 +65,322 @@ import com.alibaba.fastjson.*; * 后端接口 * @author * @email -*/ + */ +// 声明该类为RESTful控制器,用于处理HTTP请求并返回JSON数据 @RestController +// 声明该类为Spring MVC控制器 @Controller +// 映射请求路径,所有以/news开头的请求都会由该控制器处理 @RequestMapping("/news") public class NewsController { + // 日志记录器,用于记录当前控制器类的日志信息 private static final Logger logger = LoggerFactory.getLogger(NewsController.class); + // 自动注入新闻服务类,用于处理新闻相关业务逻辑 @Autowired private NewsService newsService; - + // 自动注入令牌服务类 @Autowired private TokenService tokenService; + // 自动注入字典服务类,用于字典表数据转换 @Autowired private DictionaryService dictionaryService; - //级联表service - + // 级联表service,自动注入用户服务类 @Autowired private YonghuService yonghuService; + // 级联表service,自动注入医生服务类 @Autowired private YishengService yishengService; - /** - * 后端列表 - */ + * 后端列表 + */ + // 映射/page请求路径,支持GET请求,用于获取公告信息的分页列表 @RequestMapping("/page") - public R page(@RequestParam Map params, HttpServletRequest request){ - logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); + public R page(@RequestParam Map params, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求参数 + logger.debug("page方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params)); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); - if(false) - return R.error(511,"永不会进入"); - else if("用户".equals(role)) - params.put("yonghuId",request.getSession().getAttribute("userId")); - else if("医生".equals(role)) - params.put("yishengId",request.getSession().getAttribute("userId")); - if(params.get("orderBy")==null || params.get("orderBy")==""){ - params.put("orderBy","id"); + // 此条件永远为false,注释掉的代码表示永远不会进入该分支 + if (false) + return R.error(511, "永不会进入"); + // 如果用户角色为"用户" + else if ("用户".equals(role)) + // 在请求参数中添加用户id + params.put("yonghuId", request.getSession().getAttribute("userId")); + // 如果用户角色为"医生" + else if ("医生".equals(role)) + // 在请求参数中添加医生id + params.put("yishengId", request.getSession().getAttribute("userId")); + // 如果请求参数中没有指定排序字段,则默认按id排序 + if (params.get("orderBy") == null || params.get("orderBy") == "") { + params.put("orderBy", "id"); } + // 调用新闻服务的queryPage方法,根据请求参数进行分页查询 PageUtils page = newsService.queryPage(params); - //字典表数据转换 - List list =(List)page.getList(); - for(NewsView c:list){ - //修改对应字典表字段 + // 将分页结果中的列表转换为新闻视图列表 + List list = (List) page.getList(); + // 遍历新闻视图列表 + for (NewsView c : list) { + // 调用字典服务的dictionaryConvert方法,修改对应字典表字段 dictionaryService.dictionaryConvert(c, request); } + // 返回成功响应,并将分页查询结果放入响应数据中 return R.ok().put("data", page); } /** - * 后端详情 - */ + * 后端详情 + */ + // 映射/info/{id}请求路径,支持GET请求,{id}为路径变量,用于获取指定id的公告信息详情 @RequestMapping("/info/{id}") - public R info(@PathVariable("id") Long id, HttpServletRequest request){ - logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); + public R info(@PathVariable("id") Long id, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求的id + logger.debug("info方法:,,Controller:{},,id:{}", this.getClass().getName(), id); + // 调用新闻服务的selectById方法,根据id查询新闻实体 NewsEntity news = newsService.selectById(id); - if(news !=null){ - //entity转view + // 如果查询到新闻实体 + if (news != null) { + // 创建新闻视图对象 NewsView view = new NewsView(); - BeanUtils.copyProperties( news , view );//把实体数据重构到view中 + // 使用BeanUtils将新闻实体的属性复制到新闻视图中 + BeanUtils.copyProperties(news, view); - //修改对应字典表字段 + // 调用字典服务的dictionaryConvert方法,修改对应字典表字段 dictionaryService.dictionaryConvert(view, request); + // 返回成功响应,并将新闻视图对象放入响应数据中 return R.ok().put("data", view); - }else { - return R.error(511,"查不到数据"); + } else { + // 如果未查询到数据,返回错误响应,错误码为511 + return R.error(511, "查不到数据"); } - } /** - * 后端保存 - */ + * 后端保存 + */ + // 映射/save请求路径,支持POST请求,用于保存新的公告信息 @RequestMapping("/save") - public R save(@RequestBody NewsEntity news, HttpServletRequest request){ - logger.debug("save方法:,,Controller:{},,news:{}",this.getClass().getName(),news.toString()); - + public R save(@RequestBody NewsEntity news, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和要保存的新闻实体信息 + logger.debug("save方法:,,Controller:{},,news:{}", this.getClass().getName(), news.toString()); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); - if(false) - return R.error(511,"永远不会进入"); + // 此条件永远为false,注释掉的代码表示永远不会进入该分支 + if (false) + return R.error(511, "永远不会进入"); + // 创建查询包装器,用于构建查询条件,检查是否存在相同的公告信息 Wrapper queryWrapper = new EntityWrapper() - .eq("news_name", news.getNewsName()) - .eq("news_types", news.getNewsTypes()) - ; + .eq("news_name", news.getNewsName()) + .eq("news_types", news.getNewsTypes()); - logger.info("sql语句:"+queryWrapper.getSqlSegment()); + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 调用新闻服务的selectOne方法,根据查询条件查询是否存在相同数据 NewsEntity newsEntity = newsService.selectOne(queryWrapper); - if(newsEntity==null){ + // 如果未查询到相同数据 + if (newsEntity == null) { + // 设置插入时间为当前时间 news.setInsertTime(new Date()); + // 设置创建时间为当前时间 news.setCreateTime(new Date()); + // 调用新闻服务的insert方法,将新闻实体插入数据库 newsService.insert(news); + // 返回成功响应 return R.ok(); - }else { - return R.error(511,"表中有相同数据"); + } else { + // 如果查询到相同数据,返回错误响应,错误码为511 + return R.error(511, "表中有相同数据"); } } /** - * 后端修改 - */ + * 后端修改 + */ + // 映射/update请求路径,支持POST请求,用于修改已有的公告信息 @RequestMapping("/update") - public R update(@RequestBody NewsEntity news, HttpServletRequest request){ - logger.debug("update方法:,,Controller:{},,news:{}",this.getClass().getName(),news.toString()); - + public R update(@RequestBody NewsEntity news, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和要修改的新闻实体信息 + logger.debug("update方法:,,Controller:{},,news:{}", this.getClass().getName(), news.toString()); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); -// if(false) -// return R.error(511,"永远不会进入"); - //根据字段查询是否有相同数据 + // 此条件注释掉,表示永远不会进入该分支 +// if (false) +// return R.error(511, "永远不会进入"); + // 创建查询包装器,用于构建查询条件,排除当前要修改的记录,检查是否存在相同的公告信息 Wrapper queryWrapper = new EntityWrapper() - .notIn("id",news.getId()) - .andNew() - .eq("news_name", news.getNewsName()) - .eq("news_types", news.getNewsTypes()) - ; - - logger.info("sql语句:"+queryWrapper.getSqlSegment()); + .notIn("id", news.getId()) + .andNew() + .eq("news_name", news.getNewsName()) + .eq("news_types", news.getNewsTypes()); + + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 调用新闻服务的selectOne方法,根据查询条件查询是否存在相同数据 NewsEntity newsEntity = newsService.selectOne(queryWrapper); - if("".equals(news.getNewsPhoto()) || "null".equals(news.getNewsPhoto())){ - news.setNewsPhoto(null); + // 如果新闻照片字段为空字符串或"null",则将其设置为null + if ("".equals(news.getNewsPhoto()) || "null".equals(news.getNewsPhoto())) { + news.setNewsPhoto(null); } - if(newsEntity==null){ - newsService.updateById(news);//根据id更新 + // 如果未查询到相同数据 + if (newsEntity == null) { + // 调用新闻服务的updateById方法,根据id更新新闻实体 + newsService.updateById(news); + // 返回成功响应 return R.ok(); - }else { - return R.error(511,"表中有相同数据"); + } else { + // 如果查询到相同数据,返回错误响应,错误码为511 + return R.error(511, "表中有相同数据"); } } /** - * 删除 - */ + * 删除 + */ + // 映射/delete请求路径,支持POST请求,用于删除公告信息 @RequestMapping("/delete") - public R delete(@RequestBody Integer[] ids){ - logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); + public R delete(@RequestBody Integer[] ids) { + // 记录方法调用日志,包含控制器类名和要删除的记录id数组 + logger.debug("delete:,,Controller:{},,ids:{}", this.getClass().getName(), ids.toString()); + // 调用新闻服务的deleteBatchIds方法,根据id数组批量删除记录 newsService.deleteBatchIds(Arrays.asList(ids)); + // 返回成功响应 return R.ok(); } - /** * 批量上传 */ + // 映射/batchInsert请求路径,支持POST请求,用于批量上传公告信息 @RequestMapping("/batchInsert") - public R save( String fileName){ - logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); + public R save(String fileName) { + // 记录方法调用日志,包含控制器类名和文件名 + logger.debug("batchInsert方法:,,Controller:{},,fileName:{}", this.getClass().getName(), fileName); try { - List newsList = new ArrayList<>();//上传的东西 - Map> seachFields= new HashMap<>();//要查询的字段 + // 创建一个列表,用于存储要上传的新闻实体 + List newsList = new ArrayList<>(); + // 创建一个Map,用于存储要查询的字段 + Map> seachFields = new HashMap<>(); + // 获取当前时间 Date date = new Date(); + // 获取文件名中最后一个点的索引 int lastIndexOf = fileName.lastIndexOf("."); - if(lastIndexOf == -1){ - return R.error(511,"该文件没有后缀"); - }else{ + // 如果文件名中没有点,返回错误响应,错误码为511 + if (lastIndexOf == -1) { + return R.error(511, "该文件没有后缀"); + } else { + // 获取文件后缀 String suffix = fileName.substring(lastIndexOf); - if(!".xls".equals(suffix)){ - return R.error(511,"只支持后缀为xls的excel文件"); - }else{ - URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径 + // 如果文件后缀不是.xls,返回错误响应,错误码为511 + if (!".xls".equals(suffix)) { + return R.error(511, "只支持后缀为xls的excel文件"); + } else { + // 获取文件的URL + URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName); + // 创建文件对象 File file = new File(resource.getFile()); - if(!file.exists()){ - return R.error(511,"找不到上传文件,请联系管理员"); - }else{ - List> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件 - dataList.remove(0);//删除第一行,因为第一行是提示 - for(List data:dataList){ - //循环 + // 如果文件不存在,返回错误响应,错误码为511 + if (!file.exists()) { + return R.error(511, "找不到上传文件,请联系管理员"); + } else { + // 使用PoiUtil工具类读取xls文件的数据 + List> dataList = PoiUtil.poiImport(file.getPath()); + // 删除第一行数据,因为第一行通常是表头 + dataList.remove(0); + // 遍历数据列表 + for (List data : dataList) { + // 创建一个新的新闻实体 NewsEntity newsEntity = new NewsEntity(); + // 以下代码注释掉,表示需要根据实际情况修改字段赋值 // newsEntity.setNewsName(data.get(0)); //公告名称 要改的 // newsEntity.setNewsPhoto("");//照片 // newsEntity.setNewsTypes(Integer.valueOf(data.get(0))); //公告类型 要改的 // newsEntity.setInsertTime(date);//时间 // newsEntity.setNewsContent("");//照片 // newsEntity.setCreateTime(date);//时间 + // 将新闻实体添加到上传列表中 newsList.add(newsEntity); - - //把要查询是否重复的字段放入map中 + // 把要查询是否重复的字段放入map中 } - //查询是否重复 + // 调用新闻服务的insertBatch方法,批量插入新闻实体 newsService.insertBatch(newsList); + // 返回成功响应 return R.ok(); } } } - }catch (Exception e){ - return R.error(511,"批量插入数据异常,请联系管理员"); + } catch (Exception e) { + // 如果发生异常,返回错误响应,错误码为511 + return R.error(511, "批量插入数据异常,请联系管理员"); } } - - - - /** - * 前端列表 - */ + * 前端列表 + */ + // 映射/list请求路径,支持GET请求,用于前端获取公告信息的分页列表,忽略权限验证 @IgnoreAuth @RequestMapping("/list") - public R list(@RequestParam Map params, HttpServletRequest request){ - logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); - - // 没有指定排序字段就默认id倒序 - if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){ - params.put("orderBy","id"); + public R list(@RequestParam Map params, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求参数 + logger.debug("list方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params)); + // 如果请求参数中没有指定排序字段,则默认按id倒序排序 + if (StringUtil.isEmpty(String.valueOf(params.get("orderBy")))) { + params.put("orderBy", "id"); } + // 调用新闻服务的queryPage方法,根据请求参数进行分页查询 PageUtils page = newsService.queryPage(params); - //字典表数据转换 - List list =(List)page.getList(); - for(NewsView c:list) - dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段 + // 将分页结果中的列表转换为新闻视图列表 + List list = (List) page.getList(); + // 遍历新闻视图列表 + for (NewsView c : list) + // 调用字典服务的dictionaryConvert方法,修改对应字典表字段 + dictionaryService.dictionaryConvert(c, request); + // 返回成功响应,并将分页查询结果放入响应数据中 return R.ok().put("data", page); } /** - * 前端详情 - */ + * 前端详情 + */ + // 映射/detail/{id}请求路径,支持GET请求,{id}为路径变量,用于前端获取指定id的公告信息详情 @RequestMapping("/detail/{id}") - public R detail(@PathVariable("id") Long id, HttpServletRequest request){ - logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id); + public R detail(@PathVariable("id") Long id, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求的id + logger.debug("detail方法:,,Controller:{},,id:{}", this.getClass().getName(), id); + // 调用新闻服务的selectById方法,根据id查询新闻实体 NewsEntity news = newsService.selectById(id); - if(news !=null){ - - - //entity转view - NewsView view = new NewsView(); - BeanUtils.copyProperties( news , view );//把实体数据重构到view中 + // 如果查询到新闻实体 + if (news != null) { + // 创建新闻视图对象 + NewsView view = new NewsView(); + // 使用BeanUtils将新闻实体的属性复制到新闻视图中 + BeanUtils.copyProperties(news, view); - //修改对应字典表字段 - dictionaryService.dictionaryConvert(view, request); - return R.ok().put("data", view); - }else { - return R.error(511,"查不到数据"); - } + // 调用字典服务的dictionaryConvert方法,修改对应字典表字段 + dictionaryService.dictionaryConvert(view, request); + // 返回成功响应,并将新闻视图对象放入响应数据中 + return R.ok().put("data", view); + } else { + // 如果未查询到数据,返回错误响应,错误码为511 + return R.error(511, "查不到数据"); + } } - /** - * 前端保存 - */ + * 前端保存 + */ + // 映射/add请求路径,支持POST请求,用于前端保存新的公告信息 @RequestMapping("/add") - public R add(@RequestBody NewsEntity news, HttpServletRequest request){ - logger.debug("add方法:,,Controller:{},,news:{}",this.getClass().getName(),news.toString()); - Wrapper queryWrapper = new EntityWrapper() - .eq("news_name", news.getNewsName()) - .eq("news_types", news.getNewsTypes()) - ; - logger.info("sql语句:"+queryWrapper.getSqlSegment()); - NewsEntity newsEntity = newsService.selectOne(queryWrapper); - if(newsEntity==null){ - news.setInsertTime(new Date()); - news.setCreateTime(new Date()); - newsService.insert(news); - return R.ok(); - }else { - return R.error(511,"表中有相同数据"); - } - } - - -} + public R add(@RequestBody NewsEntity news, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和要保存的新闻实体信息 + logger.debug("add方法:,,Controller:{},,news:{}", this.getClass().getName(), news.toString()); + // 创建查询包装器,用于构建查询条件,检查是否存在相同的公告信息 \ No newline at end of file diff --git a/src/main/java/com/controller/UsersController.java b/src/main/java/com/controller/UsersController.java index b0105d2..60211f4 100644 --- a/src/main/java/com/controller/UsersController.java +++ b/src/main/java/com/controller/UsersController.java @@ -1,7 +1,5 @@ - package com.controller; - import java.util.Arrays; import java.util.Map; @@ -28,141 +26,213 @@ import com.utils.R; /** * 登录相关 */ +// 定义请求映射路径,所有以/users开头的请求会被该控制器处理 @RequestMapping("users") +// 声明该类为一个RESTful风格的控制器,用于处理HTTP请求并返回JSON数据 @RestController public class UsersController { - + + // 自动注入UsersService,用于处理与用户相关的业务逻辑 @Autowired private UsersService usersService; - + + // 自动注入TokenService,用于处理与令牌相关的业务逻辑 @Autowired private TokenService tokenService; /** - * 登录 + * 处理用户登录请求 + * @param username 用户名 + * @param password 密码 + * @param captcha 验证码(当前代码未实际使用该参数) + * @param request HTTP请求对象 + * @return R类型的响应对象,包含登录结果信息 */ - @IgnoreAuth + @IgnoreAuth // 忽略权限验证的注解 @PostMapping(value = "/login") public R login(String username, String password, String captcha, HttpServletRequest request) { + // 根据用户名查询用户实体 UsersEntity user = usersService.selectOne(new EntityWrapper().eq("username", username)); - if(user==null || !user.getPassword().equals(password)) { + // 如果用户不存在或者用户输入的密码与数据库中存储的密码不匹配 + if (user == null || !user.getPassword().equals(password)) { + // 返回错误响应,提示账号或密码不正确 return R.error("账号或密码不正确"); } - String token = tokenService.generateToken(user.getId(),username, "users", user.getRole()); + // 生成用户令牌,参数依次为用户ID、用户名、用户类型标识、用户角色 + String token = tokenService.generateToken(user.getId(), username, "users", user.getRole()); + // 创建一个成功的响应对象 R r = R.ok(); + // 将生成的令牌放入响应数据中 r.put("token", token); - r.put("role",user.getRole()); - r.put("userId",user.getId()); + // 将用户的角色信息放入响应数据中 + r.put("role", user.getRole()); + // 将用户的ID信息放入响应数据中 + r.put("userId", user.getId()); + // 返回响应对象 return r; } - + /** - * 注册 - */111 - @IgnoreAuth + * 处理用户注册请求 + * @param user 用户实体对象,通过请求体获取 + * @return R类型的响应对象,包含注册结果信息 + */ + @IgnoreAuth // 忽略权限验证的注解 @PostMapping(value = "/register") - public R register(@RequestBody UsersEntity user){ -// ValidatorUtils.validateEntity(user); - if(usersService.selectOne(new EntityWrapper().eq("username", user.getUsername())) !=null) { - return R.error("用户已存在"); - } - usersService.insert(user); - return R.ok(); - } + public R register(@RequestBody UsersEntity user) { +// ValidatorUtils.validateEntity(user); // 被注释掉的代码,可能用于验证用户实体的合法性,目前未启用 + // 根据用户名查询数据库,判断用户是否已经存在 + if (usersService.selectOne(new EntityWrapper().eq("username", user.getUsername())) != null) { + // 如果用户已存在,返回错误响应 + return R.error("用户已存在"); + } + // 将新用户插入到数据库中 + usersService.insert(user); + // 返回成功响应 + return R.ok(); + } /** - * 退出 - */43242 + * 处理用户退出登录请求 + * @param request HTTP请求对象 + * @return R类型的响应对象,包含退出结果信息 + */ @GetMapping(value = "logout") public R logout(HttpServletRequest request) { + // 使当前用户的会话失效,实现退出登录 request.getSession().invalidate(); + // 返回成功响应,并附带退出成功的提示信息 return R.ok("退出成功"); } - + /** - * 密码重置 - */ - @IgnoreAuth + * 处理用户密码重置请求 + * @param username 用户名 + * @param request HTTP请求对象 + * @return R类型的响应对象,包含密码重置结果信息 + */ + @IgnoreAuth // 忽略权限验证的注解 @RequestMapping(value = "/resetPass") - public R resetPass(String username, HttpServletRequest request){ - UsersEntity user = usersService.selectOne(new EntityWrapper().eq("username", username)); - if(user==null) { - return R.error("账号不存在"); - } - user.setPassword("123456"); - usersService.update(user,null); - return R.ok("密码已重置为:123456"); - } - + public R resetPass(String username, HttpServletRequest request) { + // 根据用户名查询用户实体 + UsersEntity user = usersService.selectOne(new EntityWrapper().eq("username", username)); + // 如果用户不存在 + if (user == null) { + // 返回错误响应,提示账号不存在 + return R.error("账号不存在"); + } + // 将用户密码重置为默认值123456 + user.setPassword("123456"); + // 更新用户信息到数据库(第二个参数为null,可能表示更新时不设置额外的条件) + usersService.update(user, null); + // 返回成功响应,并附带密码已重置的提示信息 + return R.ok("密码已重置为:123456"); + } + + /** + * 处理获取用户列表的分页请求 + * @param params 包含分页和查询条件的参数Map + * @param user 用户实体对象,可能用于构建查询条件 + * @return R类型的响应对象,包含分页后的用户列表数据 + */ + @RequestMapping("/page") + public R page(@RequestParam Map params, UsersEntity user) { + // 创建一个EntityWrapper对象,用于构建查询条件 + EntityWrapper ew = new EntityWrapper(); + // 调用usersService的queryPage方法进行分页查询,MPUtil.sort等方法用于处理查询条件和排序 + PageUtils page = usersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params)); + // 返回成功响应,并将分页结果数据放入响应中 + return R.ok().put("data", page); + } + + /** + * 处理获取用户列表的请求 + * @param user 用户实体对象,用于构建查询条件 + * @return R类型的响应对象,包含用户列表数据 + */ + @RequestMapping("/list") + public R list(UsersEntity user) { + // 创建一个EntityWrapper对象 + EntityWrapper ew = new EntityWrapper(); + // 根据用户实体对象构建查询条件,使用MPUtil.allEQMapPre方法设置相等条件 + ew.allEq(MPUtil.allEQMapPre(user, "user")); + // 调用usersService的selectListView方法查询用户列表,并将结果放入响应中返回 + return R.ok().put("data", usersService.selectListView(ew)); + } + + /** + * 处理获取指定用户信息的请求 + * @param id 用户ID,通过路径变量获取 + * @return R类型的响应对象,包含指定用户的信息 + */ + @RequestMapping("/info/{id}") + public R info(@PathVariable("id") String id) { + // 根据用户ID查询用户实体 + UsersEntity user = usersService.selectById(id); + // 返回成功响应,并将用户信息放入响应中 + return R.ok().put("data", user); + } + + /** + * 处理获取当前会话用户信息的请求 + * @param request HTTP请求对象 + * @return R类型的响应对象,包含当前会话用户的信息 + */ + @RequestMapping("/session") + public R getCurrUser(HttpServletRequest request) { + // 从当前会话中获取用户ID + Integer id = (Integer) request.getSession().getAttribute("userId"); + // 根据用户ID查询用户实体 + UsersEntity user = usersService.selectById(id); + // 返回成功响应,并将用户信息放入响应中 + return R.ok().put("data", user); + } + + /** + * 处理保存新用户的请求 + * @param user 用户实体对象,通过请求体获取 + * @return R类型的响应对象,包含保存结果信息 + */ + @PostMapping("/save") + public R save(@RequestBody UsersEntity user) { +// ValidatorUtils.validateEntity(user); // 被注释掉的代码,可能用于验证用户实体的合法性,目前未启用 + // 根据用户名查询数据库,判断用户是否已经存在 + if (usersService.selectOne(new EntityWrapper().eq("username", user.getUsername())) != null) { + // 如果用户已存在,返回错误响应 + return R.error("用户已存在"); + } + // 设置用户密码为默认值123456 + user.setPassword("123456"); + // 将用户插入到数据库中 + usersService.insert(user); + // 返回成功响应 + return R.ok(); + } + /** - * 列表 - */ - @RequestMapping("/page") - public R page(@RequestParam Map params,UsersEntity user){ - EntityWrapper ew = new EntityWrapper(); - PageUtils page = usersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params)); - return R.ok().put("data", page); - } + * 处理更新用户信息的请求 + * @param user 用户实体对象,通过请求体获取 + * @return R类型的响应对象,包含更新结果信息 + */ + @RequestMapping("/update") + public R update(@RequestBody UsersEntity user) { +// ValidatorUtils.validateEntity(user); // 被注释掉的代码,可能用于验证用户实体的合法性,目前未启用 + // 根据用户ID更新用户信息到数据库 + usersService.updateById(user); // 全部更新 + // 返回成功响应 + return R.ok(); + } /** - * 列表 - */ - @RequestMapping("/list") - public R list( UsersEntity user){ - EntityWrapper ew = new EntityWrapper(); - ew.allEq(MPUtil.allEQMapPre( user, "user")); - return R.ok().put("data", usersService.selectListView(ew)); - } - - /** - * 信息 - */ - @RequestMapping("/info/{id}") - public R info(@PathVariable("id") String id){ - UsersEntity user = usersService.selectById(id); - return R.ok().put("data", user); - } - - /** - * 获取用户的session用户信息 - */ - @RequestMapping("/session") - public R getCurrUser(HttpServletRequest request){ - Integer id = (Integer)request.getSession().getAttribute("userId"); - UsersEntity user = usersService.selectById(id); - return R.ok().put("data", user); - } - - /** - * 保存 - */ - @PostMapping("/save") - public R save(@RequestBody UsersEntity user){ -// ValidatorUtils.validateEntity(user); - if(usersService.selectOne(new EntityWrapper().eq("username", user.getUsername())) !=null) { - return R.error("用户已存在"); - } - user.setPassword("123456"); - usersService.insert(user); - return R.ok(); - } - - /** - * 修改 - */ - @RequestMapping("/update") - public R update(@RequestBody UsersEntity user){ -// ValidatorUtils.validateEntity(user); - usersService.updateById(user);//全部更新 - return R.ok(); - } - - /** - * 删除 - */ - @RequestMapping("/delete") - public R delete(@RequestBody Long[] ids){ - usersService.deleteBatchIds(Arrays.asList(ids)); - return R.ok(); - } -} + * 处理删除用户的请求 + * @param ids 要删除的用户ID数组,通过请求体获取 + * @return R类型的响应对象,包含删除结果信息 + */ + @RequestMapping("/delete") + public R delete(@RequestBody Long[] ids) { + // 根据用户ID数组批量删除用户 + usersService.deleteBatchIds(Arrays.asList(ids)); + // 返回成功响应 + return R.ok(); + } +} \ No newline at end of file diff --git a/src/main/java/com/controller/YishengController.java b/src/main/java/com/controller/YishengController.java index c056d20..a080aa1 100644 --- a/src/main/java/com/controller/YishengController.java +++ b/src/main/java/com/controller/YishengController.java @@ -1,4 +1,3 @@ - package com.controller; import java.io.File; @@ -37,176 +36,232 @@ import com.alibaba.fastjson.*; * 后端接口 * @author * @email -*/ + */ +// 声明为RESTful控制器,处理HTTP请求并返回JSON数据 @RestController +// 声明为Spring MVC控制器 @Controller +// 定义请求映射路径,所有以/yisheng开头的请求由该控制器处理 @RequestMapping("/yisheng") public class YishengController { + // 日志记录器,用于记录当前控制器的日志信息 private static final Logger logger = LoggerFactory.getLogger(YishengController.class); + // 自动注入医生服务类,用于处理医生相关业务逻辑 @Autowired private YishengService yishengService; - + // 自动注入令牌服务类,用于生成和管理令牌 @Autowired private TokenService tokenService; + // 自动注入字典服务类,用于字典表数据转换 @Autowired private DictionaryService dictionaryService; - //级联表service - + // 级联表service,自动注入用户服务类 @Autowired private YonghuService yonghuService; - /** - * 后端列表 - */ + * 后端获取医生信息列表(分页) + */ @RequestMapping("/page") - public R page(@RequestParam Map params, HttpServletRequest request){ - logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); + public R page(@RequestParam Map params, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求参数 + logger.debug("page方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params)); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); - if(false) - return R.error(511,"永不会进入"); - else if("用户".equals(role)) - params.put("yonghuId",request.getSession().getAttribute("userId")); - else if("医生".equals(role)) - params.put("yishengId",request.getSession().getAttribute("userId")); - if(params.get("orderBy")==null || params.get("orderBy")==""){ - params.put("orderBy","id"); + // 此条件永远为false,不会进入该分支 + if (false) + return R.error(511, "永不会进入"); + // 如果用户角色是"用户" + else if ("用户".equals(role)) + // 在请求参数中添加用户ID + params.put("yonghuId", request.getSession().getAttribute("userId")); + // 如果用户角色是"医生" + else if ("医生".equals(role)) + // 在请求参数中添加医生ID + params.put("yishengId", request.getSession().getAttribute("userId")); + // 如果请求参数中未指定排序字段,则默认按id排序 + if (params.get("orderBy") == null || params.get("orderBy") == "") { + params.put("orderBy", "id"); } + // 调用医生服务的queryPage方法进行分页查询 PageUtils page = yishengService.queryPage(params); - //字典表数据转换 - List list =(List)page.getList(); - for(YishengView c:list){ - //修改对应字典表字段 + // 将分页结果中的列表转换为医生视图列表 + List list = (List) page.getList(); + // 遍历医生视图列表,进行字典表数据转换 + for (YishengView c : list) { dictionaryService.dictionaryConvert(c, request); } + // 返回成功响应,并将分页结果数据放入响应中 return R.ok().put("data", page); } /** - * 后端详情 - */ + * 后端获取医生信息详情 + */ @RequestMapping("/info/{id}") - public R info(@PathVariable("id") Long id, HttpServletRequest request){ - logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); + public R info(@PathVariable("id") Long id, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求的ID + logger.debug("info方法:,,Controller:{},,id:{}", this.getClass().getName(), id); + // 根据ID查询医生实体 YishengEntity yisheng = yishengService.selectById(id); - if(yisheng !=null){ - //entity转view + // 如果查询到医生实体 + if (yisheng != null) { + // 创建医生视图对象 YishengView view = new YishengView(); - BeanUtils.copyProperties( yisheng , view );//把实体数据重构到view中 + // 将医生实体数据复制到医生视图中 + BeanUtils.copyProperties(yisheng, view); - //修改对应字典表字段 + // 进行字典表数据转换 dictionaryService.dictionaryConvert(view, request); + // 返回成功响应,并将医生视图数据放入响应中 return R.ok().put("data", view); - }else { - return R.error(511,"查不到数据"); + } else { + // 如果未查询到数据,返回错误响应 + return R.error(511, "查不到数据"); } - } /** - * 后端保存 - */ + * 后端保存医生信息 + */ @RequestMapping("/save") - public R save(@RequestBody YishengEntity yisheng, HttpServletRequest request){ - logger.debug("save方法:,,Controller:{},,yisheng:{}",this.getClass().getName(),yisheng.toString()); + public R save(@RequestBody YishengEntity yisheng, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和要保存的医生实体信息 + logger.debug("save方法:,,Controller:{},,yisheng:{}", this.getClass().getName(), yisheng.toString()); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); - if(false) - return R.error(511,"永远不会进入"); + // 此条件永远为false,不会进入该分支 + if (false) + return R.error(511, "永远不会进入"); + // 创建查询包装器,检查用户名或联系方式是否已存在 Wrapper queryWrapper = new EntityWrapper() - .eq("username", yisheng.getUsername()) - .or() - .eq("yisheng_phone", yisheng.getYishengPhone()) - ; + .eq("username", yisheng.getUsername()) + .or() + .eq("yisheng_phone", yisheng.getYishengPhone()); - logger.info("sql语句:"+queryWrapper.getSqlSegment()); + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 根据查询条件查询医生实体 YishengEntity yishengEntity = yishengService.selectOne(queryWrapper); - if(yishengEntity==null){ + // 如果未查询到相同的医生实体 + if (yishengEntity == null) { + // 设置创建时间为当前时间 yisheng.setCreateTime(new Date()); + // 设置默认密码为123456 yisheng.setPassword("123456"); + // 插入医生信息到数据库 yishengService.insert(yisheng); + // 返回成功响应 return R.ok(); - }else { - return R.error(511,"账户或者联系方式已经被使用"); + } else { + // 如果已存在相同的用户名或联系方式,返回错误响应 + return R.error(511, "账户或者联系方式已经被使用"); } } /** - * 后端修改 - */ + * 后端更新医生信息 + */ @RequestMapping("/update") - public R update(@RequestBody YishengEntity yisheng, HttpServletRequest request){ - logger.debug("update方法:,,Controller:{},,yisheng:{}",this.getClass().getName(),yisheng.toString()); + public R update(@RequestBody YishengEntity yisheng, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和要更新的医生实体信息 + logger.debug("update方法:,,Controller:{},,yisheng:{}", this.getClass().getName(), yisheng.toString()); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); -// if(false) -// return R.error(511,"永远不会进入"); - //根据字段查询是否有相同数据 + // 此条件被注释掉,不会进入该分支 +// if (false) +// return R.error(511, "永远不会进入"); + // 创建查询包装器,排除当前要更新的记录,检查用户名或联系方式是否已存在 Wrapper queryWrapper = new EntityWrapper() - .notIn("id",yisheng.getId()) - .andNew() - .eq("username", yisheng.getUsername()) - .or() - .eq("yisheng_phone", yisheng.getYishengPhone()) - ; - - logger.info("sql语句:"+queryWrapper.getSqlSegment()); + .notIn("id", yisheng.getId()) + .andNew() + .eq("username", yisheng.getUsername()) + .or() + .eq("yisheng_phone", yisheng.getYishengPhone()); + + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 根据查询条件查询医生实体 YishengEntity yishengEntity = yishengService.selectOne(queryWrapper); - if("".equals(yisheng.getYishengPhoto()) || "null".equals(yisheng.getYishengPhoto())){ - yisheng.setYishengPhoto(null); + // 如果医生照片为空字符串或"null",设置为null + if ("".equals(yisheng.getYishengPhoto()) || "null".equals(yisheng.getYishengPhoto())) { + yisheng.setYishengPhoto(null); } - if(yishengEntity==null){ - yishengService.updateById(yisheng);//根据id更新 + // 如果未查询到相同的医生实体 + if (yishengEntity == null) { + // 根据ID更新医生信息 + yishengService.updateById(yisheng); + // 返回成功响应 return R.ok(); - }else { - return R.error(511,"账户或者联系方式已经被使用"); + } else { + // 如果已存在相同的用户名或联系方式,返回错误响应 + return R.error(511, "账户或者联系方式已经被使用"); } } /** - * 删除 - */ + * 删除医生信息 + */ @RequestMapping("/delete") - public R delete(@RequestBody Integer[] ids){ - logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); + public R delete(@RequestBody Integer[] ids) { + // 记录方法调用日志,包含控制器类名和要删除的ID数组 + logger.debug("delete:,,Controller:{},,ids:{}", this.getClass().getName(), ids.toString()); + // 根据ID数组批量删除医生信息 yishengService.deleteBatchIds(Arrays.asList(ids)); + // 返回成功响应 return R.ok(); } - /** - * 批量上传 + * 批量上传医生信息 */ @RequestMapping("/batchInsert") - public R save( String fileName){ - logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); + public R save(String fileName) { + // 记录方法调用日志,包含控制器类名和文件名 + logger.debug("batchInsert方法:,,Controller:{},,fileName:{}", this.getClass().getName(), fileName); try { - List yishengList = new ArrayList<>();//上传的东西 - Map> seachFields= new HashMap<>();//要查询的字段 + // 创建列表用于存储要上传的医生实体 + List yishengList = new ArrayList<>(); + // 创建Map用于存储要查询的字段 + Map> seachFields = new HashMap<>(); + // 获取当前日期 Date date = new Date(); + // 获取文件名中最后一个点的索引 int lastIndexOf = fileName.lastIndexOf("."); - if(lastIndexOf == -1){ - return R.error(511,"该文件没有后缀"); - }else{ + // 如果文件名没有后缀,返回错误响应 + if (lastIndexOf == -1) { + return R.error(511, "该文件没有后缀"); + } else { + // 获取文件后缀 String suffix = fileName.substring(lastIndexOf); - if(!".xls".equals(suffix)){ - return R.error(511,"只支持后缀为xls的excel文件"); - }else{ - URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径 + // 如果文件后缀不是.xls,返回错误响应 + if (!".xls".equals(suffix)) { + return R.error(511, "只支持后缀为xls的excel文件"); + } else { + // 获取文件路径 + URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName); + // 创建文件对象 File file = new File(resource.getFile()); - if(!file.exists()){ - return R.error(511,"找不到上传文件,请联系管理员"); - }else{ - List> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件 - dataList.remove(0);//删除第一行,因为第一行是提示 - for(List data:dataList){ - //循环 + // 如果文件不存在,返回错误响应 + if (!file.exists()) { + return R.error(511, "找不到上传文件,请联系管理员"); + } else { + // 读取xls文件数据 + List> dataList = PoiUtil.poiImport(file.getPath()); + // 删除第一行(表头) + dataList.remove(0); + // 遍历数据行 + for (List data : dataList) { + // 创建医生实体对象 YishengEntity yishengEntity = new YishengEntity(); + // 以下字段赋值被注释,需根据实际情况修改 // yishengEntity.setYishengUuidNumber(data.get(0)); //医生工号 要改的 // yishengEntity.setUsername(data.get(0)); //账户 要改的 // //yishengEntity.setPassword("123456");//密码 @@ -221,255 +276,90 @@ public class YishengController { // yishengEntity.setYishengNewMoney(data.get(0)); //挂号价格 要改的 // yishengEntity.setYishengContent("");//照片 // yishengEntity.setCreateTime(date);//时间 + // 将医生实体添加到列表中 yishengList.add(yishengEntity); - - //把要查询是否重复的字段放入map中 - //医生工号 - if(seachFields.containsKey("yishengUuidNumber")){ - List yishengUuidNumber = seachFields.get("yishengUuidNumber"); - yishengUuidNumber.add(data.get(0));//要改的 - }else{ - List yishengUuidNumber = new ArrayList<>(); - yishengUuidNumber.add(data.get(0));//要改的 - seachFields.put("yishengUuidNumber",yishengUuidNumber); - } - //账户 - if(seachFields.containsKey("username")){ - List username = seachFields.get("username"); - username.add(data.get(0));//要改的 - }else{ - List username = new ArrayList<>(); - username.add(data.get(0));//要改的 - seachFields.put("username",username); - } - //联系方式 - if(seachFields.containsKey("yishengPhone")){ - List yishengPhone = seachFields.get("yishengPhone"); - yishengPhone.add(data.get(0));//要改的 - }else{ - List yishengPhone = new ArrayList<>(); - yishengPhone.add(data.get(0));//要改的 - seachFields.put("yishengPhone",yishengPhone); - } + // 将可能重复的字段添加到seachFields中 + // 医生工号 + if (seachFields.containsKey("yishengUuidNumber")) { + List yishengUuidNumber = seachFields.get("yishengUuidNumber"); + yishengUuidNumber.add(data.get(0));//要改的 + } else { + List yishengUuidNumber = new ArrayList<>(); + yishengUuidNumber.add(data.get(0));//要改的 + seachFields.put("yishengUuidNumber", yishengUuidNumber); + } + // 账户 + if (seachFields.containsKey("username")) { + List username = seachFields.get("username"); + username.add(data.get(0));//要改的 + } else { + List username = new ArrayList<>(); + username.add(data.get(0));//要改的 + seachFields.put("username", username); + } + // 联系方式 + if (seachFields.containsKey("yishengPhone")) { + List yishengPhone = seachFields.get("yishengPhone"); + yishengPhone.add(data.get(0));//要改的 + } else { + List yishengPhone = new ArrayList<>(); + yishengPhone.add(data.get(0));//要改的 + seachFields.put("yishengPhone", yishengPhone); + } } - //查询是否重复 - //医生工号 + // 检查是否有重复数据 + // 医生工号 List yishengEntities_yishengUuidNumber = yishengService.selectList(new EntityWrapper().in("yisheng_uuid_number", seachFields.get("yishengUuidNumber"))); - if(yishengEntities_yishengUuidNumber.size() >0 ){ + if (yishengEntities_yishengUuidNumber.size() > 0) { ArrayList repeatFields = new ArrayList<>(); - for(YishengEntity s:yishengEntities_yishengUuidNumber){ + for (YishengEntity s : yishengEntities_yishengUuidNumber) { repeatFields.add(s.getYishengUuidNumber()); } - return R.error(511,"数据库的该表中的 [医生工号] 字段已经存在 存在数据为:"+repeatFields.toString()); + return R.error(511, "数据库的该表中的 [医生工号] 字段已经存在 存在数据为:" + repeatFields.toString()); } - //账户 + // 账户 List yishengEntities_username = yishengService.selectList(new EntityWrapper().in("username", seachFields.get("username"))); - if(yishengEntities_username.size() >0 ){ + if (yishengEntities_username.size() > 0) { ArrayList repeatFields = new ArrayList<>(); - for(YishengEntity s:yishengEntities_username){ + for (YishengEntity s : yishengEntities_username) { repeatFields.add(s.getUsername()); } - return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString()); + return R.error(511, "数据库的该表中的 [账户] 字段已经存在 存在数据为:" + repeatFields.toString()); } - //联系方式 + // 联系方式 List yishengEntities_yishengPhone = yishengService.selectList(new EntityWrapper().in("yisheng_phone", seachFields.get("yishengPhone"))); - if(yishengEntities_yishengPhone.size() >0 ){ + if (yishengEntities_yishengPhone.size() > 0) { ArrayList repeatFields = new ArrayList<>(); - for(YishengEntity s:yishengEntities_yishengPhone){ + for (YishengEntity s : yishengEntities_yishengPhone) { repeatFields.add(s.getYishengPhone()); } - return R.error(511,"数据库的该表中的 [联系方式] 字段已经存在 存在数据为:"+repeatFields.toString()); + return R.error(511, "数据库的该表中的 [联系方式] 字段已经存在 存在数据为:" + repeatFields.toString()); } + // 批量插入医生信息 yishengService.insertBatch(yishengList); + // 返回成功响应 return R.ok(); } } } - }catch (Exception e){ - return R.error(511,"批量插入数据异常,请联系管理员"); + } catch (Exception e) { + // 如果发生异常,返回错误响应 + return R.error(511, "批量插入数据异常,请联系管理员"); } } - /** - * 登录 - */ + * 医生登录 + */ @IgnoreAuth @RequestMapping(value = "/login") public R login(String username, String password, String captcha, HttpServletRequest request) { + // 根据用户名查询医生实体 YishengEntity yisheng = yishengService.selectOne(new EntityWrapper().eq("username", username)); - if(yisheng==null || !yisheng.getPassword().equals(password)) + // 如果医生不存在或密码不正确 + if (yisheng == null || !yisheng.getPassword().equals(password)) return R.error("账号或密码不正确"); - // // 获取监听器中的字典表 - // ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext(); - // Map> dictionaryMap= (Map>) servletContext.getAttribute("dictionaryMap"); - // Map role_types = dictionaryMap.get("role_types"); - // role_types.get(.getRoleTypes()); - String token = tokenService.generateToken(yisheng.getId(),username, "yisheng", "医生"); - R r = R.ok(); - r.put("token", token); - r.put("role","医生"); - r.put("username",yisheng.getYishengName()); - r.put("tableName","yisheng"); - r.put("userId",yisheng.getId()); - return r; - } - - /** - * 注册 - */ - @IgnoreAuth - @PostMapping(value = "/register") - public R register(@RequestBody YishengEntity yisheng){ -// ValidatorUtils.validateEntity(user); - Wrapper queryWrapper = new EntityWrapper() - .eq("username", yisheng.getUsername()) - .or() - .eq("yisheng_phone", yisheng.getYishengPhone()) - ; - YishengEntity yishengEntity = yishengService.selectOne(queryWrapper); - if(yishengEntity != null) - return R.error("账户或者联系方式已经被使用"); - yisheng.setYishengNewMoney(0.0); - yisheng.setCreateTime(new Date()); - yishengService.insert(yisheng); - return R.ok(); - } - - /** - * 重置密码 - */ - @GetMapping(value = "/resetPassword") - public R resetPassword(Integer id){ - YishengEntity yisheng = new YishengEntity(); - yisheng.setPassword("123456"); - yisheng.setId(id); - yishengService.updateById(yisheng); - return R.ok(); - } - - - /** - * 忘记密码 - */ - @IgnoreAuth - @RequestMapping(value = "/resetPass") - public R resetPass(String username, HttpServletRequest request) { - YishengEntity yisheng = yishengService.selectOne(new EntityWrapper().eq("username", username)); - if(yisheng!=null){ - yisheng.setPassword("123456"); - boolean b = yishengService.updateById(yisheng); - if(!b){ - return R.error(); - } - }else{ - return R.error("账号不存在"); - } - return R.ok(); - } - - - /** - * 获取用户的session用户信息 - */ - @RequestMapping("/session") - public R getCurrYisheng(HttpServletRequest request){ - Integer id = (Integer)request.getSession().getAttribute("userId"); - YishengEntity yisheng = yishengService.selectById(id); - if(yisheng !=null){ - //entity转view - YishengView view = new YishengView(); - BeanUtils.copyProperties( yisheng , view );//把实体数据重构到view中 - - //修改对应字典表字段 - dictionaryService.dictionaryConvert(view, request); - return R.ok().put("data", view); - }else { - return R.error(511,"查不到数据"); - } - } - - - /** - * 退出 - */ - @GetMapping(value = "logout") - public R logout(HttpServletRequest request) { - request.getSession().invalidate(); - return R.ok("退出成功"); - } - - - - - /** - * 前端列表 - */ - @IgnoreAuth - @RequestMapping("/list") - public R list(@RequestParam Map params, HttpServletRequest request){ - logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); - - // 没有指定排序字段就默认id倒序 - if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){ - params.put("orderBy","id"); - } - PageUtils page = yishengService.queryPage(params); - - //字典表数据转换 - List list =(List)page.getList(); - for(YishengView c:list) - dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段 - return R.ok().put("data", page); - } - - /** - * 前端详情 - */ - @RequestMapping("/detail/{id}") - public R detail(@PathVariable("id") Long id, HttpServletRequest request){ - logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id); - YishengEntity yisheng = yishengService.selectById(id); - if(yisheng !=null){ - - - //entity转view - YishengView view = new YishengView(); - BeanUtils.copyProperties( yisheng , view );//把实体数据重构到view中 - - //修改对应字典表字段 - dictionaryService.dictionaryConvert(view, request); - return R.ok().put("data", view); - }else { - return R.error(511,"查不到数据"); - } - } - - - /** - * 前端保存 - */ - @RequestMapping("/add") - public R add(@RequestBody YishengEntity yisheng, HttpServletRequest request){ - logger.debug("add方法:,,Controller:{},,yisheng:{}",this.getClass().getName(),yisheng.toString()); - Wrapper queryWrapper = new EntityWrapper() - .eq("username", yisheng.getUsername()) - .or() - .eq("yisheng_phone", yisheng.getYishengPhone()) - ; - logger.info("sql语句:"+queryWrapper.getSqlSegment()); - YishengEntity yishengEntity = yishengService.selectOne(queryWrapper); - if(yishengEntity==null){ - yisheng.setCreateTime(new Date()); - yisheng.setPassword("123456"); - yishengService.insert(yisheng); - return R.ok(); - }else { - return R.error(511,"账户或者联系方式已经被使用"); - } - } - - -} + // 以下代码被注释,可能是获取字典表相关操作,目前未启用 + // // \ No newline at end of file diff --git a/src/main/java/com/controller/YonghuController.java b/src/main/java/com/controller/YonghuController.java index c1adf4e..a080aa1 100644 --- a/src/main/java/com/controller/YonghuController.java +++ b/src/main/java/com/controller/YonghuController.java @@ -1,4 +1,3 @@ - package com.controller; import java.io.File; @@ -33,471 +32,334 @@ import com.utils.R; import com.alibaba.fastjson.*; /** - * 用户 + * 医生 * 后端接口 * @author * @email -*/ + */ +// 声明为RESTful控制器,处理HTTP请求并返回JSON数据 @RestController +// 声明为Spring MVC控制器 @Controller -@RequestMapping("/yonghu") -public class YonghuController { - private static final Logger logger = LoggerFactory.getLogger(YonghuController.class); +// 定义请求映射路径,所有以/yisheng开头的请求由该控制器处理 +@RequestMapping("/yisheng") +public class YishengController { + // 日志记录器,用于记录当前控制器的日志信息 + private static final Logger logger = LoggerFactory.getLogger(YishengController.class); + // 自动注入医生服务类,用于处理医生相关业务逻辑 @Autowired - private YonghuService yonghuService; - + private YishengService yishengService; + // 自动注入令牌服务类,用于生成和管理令牌 @Autowired private TokenService tokenService; + // 自动注入字典服务类,用于字典表数据转换 @Autowired private DictionaryService dictionaryService; - //级联表service - + // 级联表service,自动注入用户服务类 @Autowired - private YishengService yishengService; - + private YonghuService yonghuService; /** - * 后端列表 - */ + * 后端获取医生信息列表(分页) + */ @RequestMapping("/page") - public R page(@RequestParam Map params, HttpServletRequest request){ - logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); + public R page(@RequestParam Map params, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求参数 + logger.debug("page方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params)); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); - if(false) - return R.error(511,"永不会进入"); - else if("用户".equals(role)) - params.put("yonghuId",request.getSession().getAttribute("userId")); - else if("医生".equals(role)) - params.put("yishengId",request.getSession().getAttribute("userId")); - params.put("yonghuDeleteStart",1);params.put("yonghuDeleteEnd",1); - if(params.get("orderBy")==null || params.get("orderBy")==""){ - params.put("orderBy","id"); + // 此条件永远为false,不会进入该分支 + if (false) + return R.error(511, "永不会进入"); + // 如果用户角色是"用户" + else if ("用户".equals(role)) + // 在请求参数中添加用户ID + params.put("yonghuId", request.getSession().getAttribute("userId")); + // 如果用户角色是"医生" + else if ("医生".equals(role)) + // 在请求参数中添加医生ID + params.put("yishengId", request.getSession().getAttribute("userId")); + // 如果请求参数中未指定排序字段,则默认按id排序 + if (params.get("orderBy") == null || params.get("orderBy") == "") { + params.put("orderBy", "id"); } - PageUtils page = yonghuService.queryPage(params); + // 调用医生服务的queryPage方法进行分页查询 + PageUtils page = yishengService.queryPage(params); - //字典表数据转换 - List list =(List)page.getList(); - for(YonghuView c:list){ - //修改对应字典表字段 + // 将分页结果中的列表转换为医生视图列表 + List list = (List) page.getList(); + // 遍历医生视图列表,进行字典表数据转换 + for (YishengView c : list) { dictionaryService.dictionaryConvert(c, request); } + // 返回成功响应,并将分页结果数据放入响应中 return R.ok().put("data", page); } /** - * 后端详情 - */ + * 后端获取医生信息详情 + */ @RequestMapping("/info/{id}") - public R info(@PathVariable("id") Long id, HttpServletRequest request){ - logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); - YonghuEntity yonghu = yonghuService.selectById(id); - if(yonghu !=null){ - //entity转view - YonghuView view = new YonghuView(); - BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中 - - //修改对应字典表字段 + public R info(@PathVariable("id") Long id, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和请求的ID + logger.debug("info方法:,,Controller:{},,id:{}", this.getClass().getName(), id); + // 根据ID查询医生实体 + YishengEntity yisheng = yishengService.selectById(id); + // 如果查询到医生实体 + if (yisheng != null) { + // 创建医生视图对象 + YishengView view = new YishengView(); + // 将医生实体数据复制到医生视图中 + BeanUtils.copyProperties(yisheng, view); + + // 进行字典表数据转换 dictionaryService.dictionaryConvert(view, request); + // 返回成功响应,并将医生视图数据放入响应中 return R.ok().put("data", view); - }else { - return R.error(511,"查不到数据"); + } else { + // 如果未查询到数据,返回错误响应 + return R.error(511, "查不到数据"); } - } /** - * 后端保存 - */ + * 后端保存医生信息 + */ @RequestMapping("/save") - public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){ - logger.debug("save方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString()); + public R save(@RequestBody YishengEntity yisheng, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和要保存的医生实体信息 + logger.debug("save方法:,,Controller:{},,yisheng:{}", this.getClass().getName(), yisheng.toString()); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); - if(false) - return R.error(511,"永远不会进入"); - - Wrapper queryWrapper = new EntityWrapper() - .eq("username", yonghu.getUsername()) - .or() - .eq("yonghu_phone", yonghu.getYonghuPhone()) - .or() - .eq("yonghu_id_number", yonghu.getYonghuIdNumber()) - .andNew() - .eq("yonghu_delete", 1) - ; - - logger.info("sql语句:"+queryWrapper.getSqlSegment()); - YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper); - if(yonghuEntity==null){ - yonghu.setYonghuDelete(1); - yonghu.setCreateTime(new Date()); - yonghu.setPassword("123456"); - yonghuService.insert(yonghu); + // 此条件永远为false,不会进入该分支 + if (false) + return R.error(511, "永远不会进入"); + + // 创建查询包装器,检查用户名或联系方式是否已存在 + Wrapper queryWrapper = new EntityWrapper() + .eq("username", yisheng.getUsername()) + .or() + .eq("yisheng_phone", yisheng.getYishengPhone()); + + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 根据查询条件查询医生实体 + YishengEntity yishengEntity = yishengService.selectOne(queryWrapper); + // 如果未查询到相同的医生实体 + if (yishengEntity == null) { + // 设置创建时间为当前时间 + yisheng.setCreateTime(new Date()); + // 设置默认密码为123456 + yisheng.setPassword("123456"); + // 插入医生信息到数据库 + yishengService.insert(yisheng); + // 返回成功响应 return R.ok(); - }else { - return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用"); + } else { + // 如果已存在相同的用户名或联系方式,返回错误响应 + return R.error(511, "账户或者联系方式已经被使用"); } } /** - * 后端修改 - */ + * 后端更新医生信息 + */ @RequestMapping("/update") - public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request){ - logger.debug("update方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString()); + public R update(@RequestBody YishengEntity yisheng, HttpServletRequest request) { + // 记录方法调用日志,包含控制器类名和要更新的医生实体信息 + logger.debug("update方法:,,Controller:{},,yisheng:{}", this.getClass().getName(), yisheng.toString()); + // 从请求会话中获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role")); -// if(false) -// return R.error(511,"永远不会进入"); - //根据字段查询是否有相同数据 - Wrapper queryWrapper = new EntityWrapper() - .notIn("id",yonghu.getId()) - .andNew() - .eq("username", yonghu.getUsername()) - .or() - .eq("yonghu_phone", yonghu.getYonghuPhone()) - .or() - .eq("yonghu_id_number", yonghu.getYonghuIdNumber()) - .andNew() - .eq("yonghu_delete", 1) - ; - - logger.info("sql语句:"+queryWrapper.getSqlSegment()); - YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper); - if("".equals(yonghu.getYonghuPhoto()) || "null".equals(yonghu.getYonghuPhoto())){ - yonghu.setYonghuPhoto(null); + // 此条件被注释掉,不会进入该分支 +// if (false) +// return R.error(511, "永远不会进入"); + // 创建查询包装器,排除当前要更新的记录,检查用户名或联系方式是否已存在 + Wrapper queryWrapper = new EntityWrapper() + .notIn("id", yisheng.getId()) + .andNew() + .eq("username", yisheng.getUsername()) + .or() + .eq("yisheng_phone", yisheng.getYishengPhone()); + + // 记录生成的SQL查询语句 + logger.info("sql语句:" + queryWrapper.getSqlSegment()); + // 根据查询条件查询医生实体 + YishengEntity yishengEntity = yishengService.selectOne(queryWrapper); + // 如果医生照片为空字符串或"null",设置为null + if ("".equals(yisheng.getYishengPhoto()) || "null".equals(yisheng.getYishengPhoto())) { + yisheng.setYishengPhoto(null); } - if(yonghuEntity==null){ - yonghuService.updateById(yonghu);//根据id更新 + // 如果未查询到相同的医生实体 + if (yishengEntity == null) { + // 根据ID更新医生信息 + yishengService.updateById(yisheng); + // 返回成功响应 return R.ok(); - }else { - return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用"); + } else { + // 如果已存在相同的用户名或联系方式,返回错误响应 + return R.error(511, "账户或者联系方式已经被使用"); } } /** - * 删除 - */ + * 删除医生信息 + */ @RequestMapping("/delete") - public R delete(@RequestBody Integer[] ids){ - logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); - ArrayList list = new ArrayList<>(); - for(Integer id:ids){ - YonghuEntity yonghuEntity = new YonghuEntity(); - yonghuEntity.setId(id); - yonghuEntity.setYonghuDelete(2); - list.add(yonghuEntity); - } - if(list != null && list.size() >0){ - yonghuService.updateBatchById(list); - } + public R delete(@RequestBody Integer[] ids) { + // 记录方法调用日志,包含控制器类名和要删除的ID数组 + logger.debug("delete:,,Controller:{},,ids:{}", this.getClass().getName(), ids.toString()); + // 根据ID数组批量删除医生信息 + yishengService.deleteBatchIds(Arrays.asList(ids)); + // 返回成功响应 return R.ok(); } - /** - * 批量上传 + * 批量上传医生信息 */ @RequestMapping("/batchInsert") - public R save( String fileName){ - logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); + public R save(String fileName) { + // 记录方法调用日志,包含控制器类名和文件名 + logger.debug("batchInsert方法:,,Controller:{},,fileName:{}", this.getClass().getName(), fileName); try { - List yonghuList = new ArrayList<>();//上传的东西 - Map> seachFields= new HashMap<>();//要查询的字段 + // 创建列表用于存储要上传的医生实体 + List yishengList = new ArrayList<>(); + // 创建Map用于存储要查询的字段 + Map> seachFields = new HashMap<>(); + // 获取当前日期 Date date = new Date(); + // 获取文件名中最后一个点的索引 int lastIndexOf = fileName.lastIndexOf("."); - if(lastIndexOf == -1){ - return R.error(511,"该文件没有后缀"); - }else{ + // 如果文件名没有后缀,返回错误响应 + if (lastIndexOf == -1) { + return R.error(511, "该文件没有后缀"); + } else { + // 获取文件后缀 String suffix = fileName.substring(lastIndexOf); - if(!".xls".equals(suffix)){ - return R.error(511,"只支持后缀为xls的excel文件"); - }else{ - URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径 + // 如果文件后缀不是.xls,返回错误响应 + if (!".xls".equals(suffix)) { + return R.error(511, "只支持后缀为xls的excel文件"); + } else { + // 获取文件路径 + URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName); + // 创建文件对象 File file = new File(resource.getFile()); - if(!file.exists()){ - return R.error(511,"找不到上传文件,请联系管理员"); - }else{ - List> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件 - dataList.remove(0);//删除第一行,因为第一行是提示 - for(List data:dataList){ - //循环 - YonghuEntity yonghuEntity = new YonghuEntity(); -// yonghuEntity.setUsername(data.get(0)); //账户 要改的 -// //yonghuEntity.setPassword("123456");//密码 -// yonghuEntity.setYonghuName(data.get(0)); //用户姓名 要改的 -// yonghuEntity.setYonghuPhoto("");//照片 -// yonghuEntity.setYonghuPhone(data.get(0)); //用户手机号 要改的 -// yonghuEntity.setYonghuIdNumber(data.get(0)); //用户身份证号 要改的 -// yonghuEntity.setYonghuEmail(data.get(0)); //邮箱 要改的 -// yonghuEntity.setSexTypes(Integer.valueOf(data.get(0))); //性别 要改的 -// yonghuEntity.setNewMoney(data.get(0)); //余额 要改的 -// yonghuEntity.setYonghuDelete(1);//逻辑删除字段 -// yonghuEntity.setCreateTime(date);//时间 - yonghuList.add(yonghuEntity); - - - //把要查询是否重复的字段放入map中 - //账户 - if(seachFields.containsKey("username")){ - List username = seachFields.get("username"); - username.add(data.get(0));//要改的 - }else{ - List username = new ArrayList<>(); - username.add(data.get(0));//要改的 - seachFields.put("username",username); - } - //用户手机号 - if(seachFields.containsKey("yonghuPhone")){ - List yonghuPhone = seachFields.get("yonghuPhone"); - yonghuPhone.add(data.get(0));//要改的 - }else{ - List yonghuPhone = new ArrayList<>(); - yonghuPhone.add(data.get(0));//要改的 - seachFields.put("yonghuPhone",yonghuPhone); - } - //用户身份证号 - if(seachFields.containsKey("yonghuIdNumber")){ - List yonghuIdNumber = seachFields.get("yonghuIdNumber"); - yonghuIdNumber.add(data.get(0));//要改的 - }else{ - List yonghuIdNumber = new ArrayList<>(); - yonghuIdNumber.add(data.get(0));//要改的 - seachFields.put("yonghuIdNumber",yonghuIdNumber); - } + // 如果文件不存在,返回错误响应 + if (!file.exists()) { + return R.error(511, "找不到上传文件,请联系管理员"); + } else { + // 读取xls文件数据 + List> dataList = PoiUtil.poiImport(file.getPath()); + // 删除第一行(表头) + dataList.remove(0); + // 遍历数据行 + for (List data : dataList) { + // 创建医生实体对象 + YishengEntity yishengEntity = new YishengEntity(); + // 以下字段赋值被注释,需根据实际情况修改 +// yishengEntity.setYishengUuidNumber(data.get(0)); //医生工号 要改的 +// yishengEntity.setUsername(data.get(0)); //账户 要改的 +// //yishengEntity.setPassword("123456");//密码 +// yishengEntity.setYishengName(data.get(0)); //医生名称 要改的 +// yishengEntity.setYishengTypes(Integer.valueOf(data.get(0))); //科室 要改的 +// yishengEntity.setZhiweiTypes(Integer.valueOf(data.get(0))); //职位 要改的 +// yishengEntity.setYishengZhichneg(data.get(0)); //职称 要改的 +// yishengEntity.setYishengPhoto("");//照片 +// yishengEntity.setYishengPhone(data.get(0)); //联系方式 要改的 +// yishengEntity.setYishengGuahao(data.get(0)); //挂号须知 要改的 +// yishengEntity.setYishengEmail(data.get(0)); //邮箱 要改的 +// yishengEntity.setYishengNewMoney(data.get(0)); //挂号价格 要改的 +// yishengEntity.setYishengContent("");//照片 +// yishengEntity.setCreateTime(date);//时间 + // 将医生实体添加到列表中 + yishengList.add(yishengEntity); + + // 将可能重复的字段添加到seachFields中 + // 医生工号 + if (seachFields.containsKey("yishengUuidNumber")) { + List yishengUuidNumber = seachFields.get("yishengUuidNumber"); + yishengUuidNumber.add(data.get(0));//要改的 + } else { + List yishengUuidNumber = new ArrayList<>(); + yishengUuidNumber.add(data.get(0));//要改的 + seachFields.put("yishengUuidNumber", yishengUuidNumber); + } + // 账户 + if (seachFields.containsKey("username")) { + List username = seachFields.get("username"); + username.add(data.get(0));//要改的 + } else { + List username = new ArrayList<>(); + username.add(data.get(0));//要改的 + seachFields.put("username", username); + } + // 联系方式 + if (seachFields.containsKey("yishengPhone")) { + List yishengPhone = seachFields.get("yishengPhone"); + yishengPhone.add(data.get(0));//要改的 + } else { + List yishengPhone = new ArrayList<>(); + yishengPhone.add(data.get(0));//要改的 + seachFields.put("yishengPhone", yishengPhone); + } } - //查询是否重复 - //账户 - List yonghuEntities_username = yonghuService.selectList(new EntityWrapper().in("username", seachFields.get("username")).eq("yonghu_delete", 1)); - if(yonghuEntities_username.size() >0 ){ + // 检查是否有重复数据 + // 医生工号 + List yishengEntities_yishengUuidNumber = yishengService.selectList(new EntityWrapper().in("yisheng_uuid_number", seachFields.get("yishengUuidNumber"))); + if (yishengEntities_yishengUuidNumber.size() > 0) { ArrayList repeatFields = new ArrayList<>(); - for(YonghuEntity s:yonghuEntities_username){ - repeatFields.add(s.getUsername()); + for (YishengEntity s : yishengEntities_yishengUuidNumber) { + repeatFields.add(s.getYishengUuidNumber()); } - return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString()); + return R.error(511, "数据库的该表中的 [医生工号] 字段已经存在 存在数据为:" + repeatFields.toString()); } - //用户手机号 - List yonghuEntities_yonghuPhone = yonghuService.selectList(new EntityWrapper().in("yonghu_phone", seachFields.get("yonghuPhone")).eq("yonghu_delete", 1)); - if(yonghuEntities_yonghuPhone.size() >0 ){ + // 账户 + List yishengEntities_username = yishengService.selectList(new EntityWrapper().in("username", seachFields.get("username"))); + if (yishengEntities_username.size() > 0) { ArrayList repeatFields = new ArrayList<>(); - for(YonghuEntity s:yonghuEntities_yonghuPhone){ - repeatFields.add(s.getYonghuPhone()); + for (YishengEntity s : yishengEntities_username) { + repeatFields.add(s.getUsername()); } - return R.error(511,"数据库的该表中的 [用户手机号] 字段已经存在 存在数据为:"+repeatFields.toString()); + return R.error(511, "数据库的该表中的 [账户] 字段已经存在 存在数据为:" + repeatFields.toString()); } - //用户身份证号 - List yonghuEntities_yonghuIdNumber = yonghuService.selectList(new EntityWrapper().in("yonghu_id_number", seachFields.get("yonghuIdNumber")).eq("yonghu_delete", 1)); - if(yonghuEntities_yonghuIdNumber.size() >0 ){ + // 联系方式 + List yishengEntities_yishengPhone = yishengService.selectList(new EntityWrapper().in("yisheng_phone", seachFields.get("yishengPhone"))); + if (yishengEntities_yishengPhone.size() > 0) { ArrayList repeatFields = new ArrayList<>(); - for(YonghuEntity s:yonghuEntities_yonghuIdNumber){ - repeatFields.add(s.getYonghuIdNumber()); + for (YishengEntity s : yishengEntities_yishengPhone) { + repeatFields.add(s.getYishengPhone()); } - return R.error(511,"数据库的该表中的 [用户身份证号] 字段已经存在 存在数据为:"+repeatFields.toString()); + return R.error(511, "数据库的该表中的 [联系方式] 字段已经存在 存在数据为:" + repeatFields.toString()); } - yonghuService.insertBatch(yonghuList); + // 批量插入医生信息 + yishengService.insertBatch(yishengList); + // 返回成功响应 return R.ok(); } } } - }catch (Exception e){ - return R.error(511,"批量插入数据异常,请联系管理员"); + } catch (Exception e) { + // 如果发生异常,返回错误响应 + return R.error(511, "批量插入数据异常,请联系管理员"); } } - /** - * 登录 - */ + * 医生登录 + */ @IgnoreAuth @RequestMapping(value = "/login") public R login(String username, String password, String captcha, HttpServletRequest request) { - YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper().eq("username", username)); - if(yonghu==null || !yonghu.getPassword().equals(password)) + // 根据用户名查询医生实体 + YishengEntity yisheng = yishengService.selectOne(new EntityWrapper().eq("username", username)); + // 如果医生不存在或密码不正确 + if (yisheng == null || !yisheng.getPassword().equals(password)) return R.error("账号或密码不正确"); - else if(yonghu.getYonghuDelete() != 1) - return R.error("账户已被删除"); - // // 获取监听器中的字典表 - // ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext(); - // Map> dictionaryMap= (Map>) servletContext.getAttribute("dictionaryMap"); - // Map role_types = dictionaryMap.get("role_types"); - // role_types.get(.getRoleTypes()); - String token = tokenService.generateToken(yonghu.getId(),username, "yonghu", "用户"); - R r = R.ok(); - r.put("token", token); - r.put("role","用户"); - r.put("username",yonghu.getYonghuName()); - r.put("tableName","yonghu"); - r.put("userId",yonghu.getId()); - return r; - } - - /** - * 注册 - */ - @IgnoreAuth - @PostMapping(value = "/register") - public R register(@RequestBody YonghuEntity yonghu){ -// ValidatorUtils.validateEntity(user); - Wrapper queryWrapper = new EntityWrapper() - .eq("username", yonghu.getUsername()) - .or() - .eq("yonghu_phone", yonghu.getYonghuPhone()) - .or() - .eq("yonghu_id_number", yonghu.getYonghuIdNumber()) - .andNew() - .eq("yonghu_delete", 1) - ; - YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper); - if(yonghuEntity != null) - return R.error("账户或者用户手机号或者用户身份证号已经被使用"); - yonghu.setNewMoney(0.0); - yonghu.setYonghuDelete(1); - yonghu.setCreateTime(new Date()); - yonghuService.insert(yonghu); - return R.ok(); - } - - /** - * 重置密码 - */ - @GetMapping(value = "/resetPassword") - public R resetPassword(Integer id){ - YonghuEntity yonghu = new YonghuEntity(); - yonghu.setPassword("123456"); - yonghu.setId(id); - yonghuService.updateById(yonghu); - return R.ok(); - } - - - /** - * 忘记密码 - */ - @IgnoreAuth - @RequestMapping(value = "/resetPass") - public R resetPass(String username, HttpServletRequest request) { - YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper().eq("username", username)); - if(yonghu!=null){ - yonghu.setPassword("123456"); - boolean b = yonghuService.updateById(yonghu); - if(!b){ - return R.error(); - } - }else{ - return R.error("账号不存在"); - } - return R.ok(); - } - - - /** - * 获取用户的session用户信息 - */ - @RequestMapping("/session") - public R getCurrYonghu(HttpServletRequest request){ - Integer id = (Integer)request.getSession().getAttribute("userId"); - YonghuEntity yonghu = yonghuService.selectById(id); - if(yonghu !=null){ - //entity转view - YonghuView view = new YonghuView(); - BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中 - - //修改对应字典表字段 - dictionaryService.dictionaryConvert(view, request); - return R.ok().put("data", view); - }else { - return R.error(511,"查不到数据"); - } - } - - - /** - * 退出 - */ - @GetMapping(value = "logout") - public R logout(HttpServletRequest request) { - request.getSession().invalidate(); - return R.ok("退出成功"); - } - - - - - /** - * 前端列表 - */ - @IgnoreAuth - @RequestMapping("/list") - public R list(@RequestParam Map params, HttpServletRequest request){ - logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); - - // 没有指定排序字段就默认id倒序 - if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){ - params.put("orderBy","id"); - } - PageUtils page = yonghuService.queryPage(params); - - //字典表数据转换 - List list =(List)page.getList(); - for(YonghuView c:list) - dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段 - return R.ok().put("data", page); - } - - /** - * 前端详情 - */ - @RequestMapping("/detail/{id}") - public R detail(@PathVariable("id") Long id, HttpServletRequest request){ - logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id); - YonghuEntity yonghu = yonghuService.selectById(id); - if(yonghu !=null){ - - - //entity转view - YonghuView view = new YonghuView(); - BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中 - - //修改对应字典表字段 - dictionaryService.dictionaryConvert(view, request); - return R.ok().put("data", view); - }else { - return R.error(511,"查不到数据"); - } - } - - - /** - * 前端保存 - */ - @RequestMapping("/add") - public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){ - logger.debug("add方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString()); - Wrapper queryWrapper = new EntityWrapper() - .eq("username", yonghu.getUsername()) - .or() - .eq("yonghu_phone", yonghu.getYonghuPhone()) - .or() - .eq("yonghu_id_number", yonghu.getYonghuIdNumber()) - .andNew() - .eq("yonghu_delete", 1) - ; - logger.info("sql语句:"+queryWrapper.getSqlSegment()); - YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper); - if(yonghuEntity==null){ - yonghu.setYonghuDelete(1); - yonghu.setCreateTime(new Date()); - yonghu.setPassword("123456"); - yonghuService.insert(yonghu); - return R.ok(); - }else { - return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用"); - } - } - - -} + // 以下代码被注释,可能是获取字典表相关操作,目前未启用 + // // \ No newline at end of file diff --git a/src/main/java/com/entity/ChatEntity.java b/src/main/java/com/entity/ChatEntity.java index 772d087..c665b59 100644 --- a/src/main/java/com/entity/ChatEntity.java +++ b/src/main/java/com/entity/ChatEntity.java @@ -1,277 +1,310 @@ package com.entity; +// 导入 MyBatis-Plus 用于指定主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入 MyBatis-Plus 用于指定数据库表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入 JSR 303 验证注解,确保字段不为空字符串 import javax.validation.constraints.NotBlank; +// 导入 JSR 303 验证注解,确保集合或数组不为空 import javax.validation.constraints.NotEmpty; +// 导入 JSR 303 验证注解,确保字段不为 null import javax.validation.constraints.NotNull; - +// 导入 Jackson 注解,用于忽略 JSON 序列化和反序列化时的某些属性 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入反射调用可能抛出的异常类 import java.lang.reflect.InvocationTargetException; - +// 导入序列化接口 import java.io.Serializable; +// 导入日期类 import java.util.Date; +// 导入列表集合类 import java.util.List; - +// 导入 Spring 框架用于日期格式化的注解 import org.springframework.format.annotation.DateTimeFormat; +// 导入 Jackson 用于 JSON 序列化时日期格式化的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入 Apache Commons BeanUtils 工具类,用于对象属性复制 import org.apache.commons.beanutils.BeanUtils; +// 导入 MyBatis-Plus 用于指定字段的注解 import com.baomidou.mybatisplus.annotations.TableField; +// 导入 MyBatis-Plus 字段填充策略枚举 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入 MyBatis-Plus 主键生成策略枚举 import com.baomidou.mybatisplus.enums.IdType; /** * 在线咨询 * - * @author + * @author * @email */ +// 指定该类对应数据库中的 chat 表 @TableName("chat") +// 实现 Serializable 接口,使该类的对象可以进行序列化和反序列化操作 public class ChatEntity implements Serializable { + // 序列化版本号,确保序列化和反序列化的兼容性 private static final long serialVersionUID = 1L; + // 无参构造函数,方便创建 ChatEntity 类的实例 + public ChatEntity() { - public ChatEntity() { - - } - - public ChatEntity(T t) { - try { - BeanUtils.copyProperties(this, t); - } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } + } + // 带参构造函数,接收一个泛型对象 t,将其属性复制到当前 ChatEntity 对象 + public ChatEntity(T t) { + try { + // 使用 BeanUtils 工具类复制属性 + BeanUtils.copyProperties(this, t); + } catch (IllegalAccessException | InvocationTargetException e) { + // 若复制属性过程中出现异常,打印异常堆栈信息 + e.printStackTrace(); + } + } /** * 主键 */ + // 指定该字段为主键,且主键生成策略为自增 @TableId(type = IdType.AUTO) + // 指定该字段对应数据库表中的 id 字段 @TableField(value = "id") - + // 主键,用于唯一标识一条在线咨询记录 private Integer id; - /** * 提问用户 */ + // 指定该字段对应数据库表中的 yonghu_id 字段 @TableField(value = "yonghu_id") - + // 提问用户的 ID,关联用户表 private Integer yonghuId; - /** * 问题 */ + // 指定该字段对应数据库表中的 chat_issue 字段 @TableField(value = "chat_issue") - + // 用户提出的问题内容 private String chatIssue; - /** * 问题时间 */ - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象 + @DateTimeFormat + // 指定该字段对应数据库表中的 issue_time 字段 @TableField(value = "issue_time") - + // 用户提出问题的时间 private Date issueTime; - /** * 回复 */ + // 指定该字段对应数据库表中的 chat_reply 字段 @TableField(value = "chat_reply") - + // 针对用户问题的回复内容 private String chatReply; - /** * 回复时间 */ - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象 + @DateTimeFormat + // 指定该字段对应数据库表中的 reply_time 字段 @TableField(value = "reply_time") - + // 回复用户问题的时间 private Date replyTime; - /** * 状态 */ + // 指定该字段对应数据库表中的 zhuangtai_types 字段 @TableField(value = "zhuangtai_types") - + // 在线咨询的状态,可能用整数表示不同状态,如 0 表示待回复,1 表示已回复等 private Integer zhuangtaiTypes; - /** * 数据类型 */ + // 指定该字段对应数据库表中的 chat_types 字段 @TableField(value = "chat_types") - + // 在线咨询的数据类型,可能用整数表示不同类型,如 1 表示文字咨询,2 表示图片咨询等 private Integer chatTypes; - /** * 创建时间 */ - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat - @TableField(value = "insert_time",fill = FieldFill.INSERT) - + // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象 + @DateTimeFormat + // 指定该字段对应数据库表中的 insert_time 字段,且在插入数据时自动填充 + @TableField(value = "insert_time", fill = FieldFill.INSERT) + // 该条在线咨询记录的创建时间 private Date insertTime; - /** - * 设置:主键 - */ + * 设置:主键 + */ + // 获取主键的方法 public Integer getId() { return id; } - /** - * 获取:主键 - */ - + * 获取:主键 + */ + // 设置主键的方法 public void setId(Integer id) { this.id = id; } + /** - * 设置:提问用户 - */ + * 设置:提问用户 + */ + // 获取提问用户 ID 的方法 public Integer getYonghuId() { return yonghuId; } - /** - * 获取:提问用户 - */ - + * 获取:提问用户 + */ + // 设置提问用户 ID 的方法 public void setYonghuId(Integer yonghuId) { this.yonghuId = yonghuId; } + /** - * 设置:问题 - */ + * 设置:问题 + */ + // 获取问题内容的方法 public String getChatIssue() { return chatIssue; } - /** - * 获取:问题 - */ - + * 获取:问题 + */ + // 设置问题内容的方法 public void setChatIssue(String chatIssue) { this.chatIssue = chatIssue; } + /** - * 设置:问题时间 - */ + * 设置:问题时间 + */ + // 获取问题时间的方法 public Date getIssueTime() { return issueTime; } - /** - * 获取:问题时间 - */ - + * 获取:问题时间 + */ + // 设置问题时间的方法 public void setIssueTime(Date issueTime) { this.issueTime = issueTime; } + /** - * 设置:回复 - */ + * 设置:回复 + */ + // 获取回复内容的方法 public String getChatReply() { return chatReply; } - /** - * 获取:回复 - */ - + * 获取:回复 + */ + // 设置回复内容的方法 public void setChatReply(String chatReply) { this.chatReply = chatReply; } + /** - * 设置:回复时间 - */ + * 设置:回复时间 + */ + // 获取回复时间的方法 public Date getReplyTime() { return replyTime; } - /** - * 获取:回复时间 - */ - + * 获取:回复时间 + */ + // 设置回复时间的方法 public void setReplyTime(Date replyTime) { this.replyTime = replyTime; } + /** - * 设置:状态 - */ + * 设置:状态 + */ + // 获取状态的方法 public Integer getZhuangtaiTypes() { return zhuangtaiTypes; } - /** - * 获取:状态 - */ - + * 获取:状态 + */ + // 设置状态的方法 public void setZhuangtaiTypes(Integer zhuangtaiTypes) { this.zhuangtaiTypes = zhuangtaiTypes; } + /** - * 设置:数据类型 - */ + * 设置:数据类型 + */ + // 获取数据类型的方法 public Integer getChatTypes() { return chatTypes; } - /** - * 获取:数据类型 - */ - + * 获取:数据类型 + */ + // 设置数据类型的方法 public void setChatTypes(Integer chatTypes) { this.chatTypes = chatTypes; } + /** - * 设置:创建时间 - */ + * 设置:创建时间 + */ + // 获取创建时间的方法 public Date getInsertTime() { return insertTime; } - /** - * 获取:创建时间 - */ - + * 获取:创建时间 + */ + // 设置创建时间的方法 public void setInsertTime(Date insertTime) { this.insertTime = insertTime; } + // 重写 toString 方法,方便打印对象信息 @Override public String toString() { return "Chat{" + - "id=" + id + - ", yonghuId=" + yonghuId + - ", chatIssue=" + chatIssue + - ", issueTime=" + issueTime + - ", chatReply=" + chatReply + - ", replyTime=" + replyTime + - ", zhuangtaiTypes=" + zhuangtaiTypes + - ", chatTypes=" + chatTypes + - ", insertTime=" + insertTime + - "}"; + "id=" + id + + ", yonghuId=" + yonghuId + + ", chatIssue=" + chatIssue + + ", issueTime=" + issueTime + + ", chatReply=" + chatReply + + ", replyTime=" + replyTime + + ", zhuangtaiTypes=" + zhuangtaiTypes + + ", chatTypes=" + chatTypes + + ", insertTime=" + insertTime + + "}"; } -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/ConfigEntity.java b/src/main/java/com/entity/ConfigEntity.java index 7078bc2..327fd00 100644 --- a/src/main/java/com/entity/ConfigEntity.java +++ b/src/main/java/com/entity/ConfigEntity.java @@ -7,22 +7,21 @@ import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.enums.IdType; /** -* @author yangliyuan -* @version 创建时间:2020年2月7日 下午8:36:05 -* 类说明 : -*/ + * @author yangliyuan + * @version 创建时间:2020年2月7日 下午8:36:05 + * 类说明 : + */ @TableName("config") public class ConfigEntity implements Serializable{ -private static final long serialVersionUID = 1L; - + // 定义主键字段 @TableId(type = IdType.AUTO) private Long id; - + /** - * key + * name */ private String name; - + /** * value */ @@ -51,5 +50,4 @@ private static final long serialVersionUID = 1L; public void setValue(String value) { this.value = value; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/DictionaryEntity.java b/src/main/java/com/entity/DictionaryEntity.java index e49ac9d..a0ab3ec 100644 --- a/src/main/java/com/entity/DictionaryEntity.java +++ b/src/main/java/com/entity/DictionaryEntity.java @@ -1,249 +1,276 @@ package com.entity; +// 导入 MyBatis-Plus 用于指定主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入 MyBatis-Plus 用于指定数据库表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入 JSR 303 验证注解(在当前代码中未实际使用) import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; - +// 导入 Jackson 注解(在当前代码中未实际使用) import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入反射调用可能抛出的异常类 import java.lang.reflect.InvocationTargetException; - +// 导入序列化接口 import java.io.Serializable; +// 导入日期类 import java.util.Date; +// 导入列表集合类(在当前代码中未实际使用) import java.util.List; - +// 导入 Spring 框架用于日期格式化的注解 import org.springframework.format.annotation.DateTimeFormat; +// 导入 Jackson 用于 JSON 序列化时日期格式化的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入 Apache Commons BeanUtils 工具类,用于对象属性复制 import org.apache.commons.beanutils.BeanUtils; +// 导入 MyBatis-Plus 用于指定字段的注解 import com.baomidou.mybatisplus.annotations.TableField; +// 导入 MyBatis-Plus 字段填充策略枚举 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入 MyBatis-Plus 主键生成策略枚举 import com.baomidou.mybatisplus.enums.IdType; /** * 字典表 * - * @author + * @author * @email */ +// 使用 TableName 注解指定该类对应的数据库表名为 "dictionary" @TableName("dictionary") +// 定义泛型类 DictionaryEntity,实现 Serializable 接口,以便对象可以进行序列化和反序列化 public class DictionaryEntity implements Serializable { + // 定义序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性 private static final long serialVersionUID = 1L; + // 无参构造函数,用于创建 DictionaryEntity 对象 + public DictionaryEntity() { - public DictionaryEntity() { - - } - - public DictionaryEntity(T t) { - try { - BeanUtils.copyProperties(this, t); - } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } + } + // 带参构造函数,接受一个泛型对象 t,通过 BeanUtils.copyProperties 方法 + // 将对象 t 的属性复制到当前 DictionaryEntity 对象中 + public DictionaryEntity(T t) { + try { + BeanUtils.copyProperties(this, t); + } catch (IllegalAccessException | InvocationTargetException e) { + // 如果在复制属性过程中出现异常,打印异常堆栈信息 + e.printStackTrace(); + } + } /** * 主键 */ + // 使用 TableId 注解指定该字段为主键,主键生成策略为自动增长(AUTO) @TableId(type = IdType.AUTO) + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "id" @TableField(value = "id") - + // 存储字典表记录的主键值,用于唯一标识一条记录 private Integer id; - /** * 字段 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "dic_code" @TableField(value = "dic_code") - + // 存储字典表中的字段代码,可能用于标识不同的字典项类别等 private String dicCode; - /** * 字段名 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "dic_name" @TableField(value = "dic_name") - + // 存储字典表中字段的名称,与 dicCode 对应,提供更易读的名称标识 private String dicName; - /** * 编码 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "code_index" @TableField(value = "code_index") - + // 存储字典表中某一字典项的编码值,可能用于内部编码或排序等用途 private Integer codeIndex; - /** * 编码名字 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "index_name" @TableField(value = "index_name") - + // 存储编码对应的名称,与 codeIndex 对应,提供更详细的编码描述 private String indexName; - /** * 父字段id */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "super_id" @TableField(value = "super_id") - + // 存储当前字典项的父字段 ID,用于表示字典项之间的层级关系 private Integer superId; - /** * 备注 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "beizhu" @TableField(value = "beizhu") - + // 存储关于当前字典项的备注信息,用于记录额外的说明或注意事项 private String beizhu; - /** * 创建时间 */ - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat - @TableField(value = "create_time",fill = FieldFill.INSERT) - + // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象 + @DateTimeFormat + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "create_time", + // 并设置在插入数据时自动填充当前时间 + @TableField(value = "create_time", fill = FieldFill.INSERT) + // 存储字典表记录的创建时间,用于记录数据的创建时间戳 private Date createTime; - /** - * 设置:主键 - */ + * 设置:主键 + */ + // 获取主键值的方法,外部可以通过调用该方法获取 id 字段的值 public Integer getId() { return id; } - /** - * 获取:主键 - */ - + * 获取:主键 + */ + // 设置主键值的方法,外部可以通过调用该方法设置 id 字段的值 public void setId(Integer id) { this.id = id; } + /** - * 设置:字段 - */ + * 设置:字段 + */ + // 获取字段代码值的方法,外部可以通过调用该方法获取 dicCode 字段的值 public String getDicCode() { return dicCode; } - /** - * 获取:字段 - */ - + * 获取:字段 + */ + // 设置字段代码值的方法,外部可以通过调用该方法设置 dicCode 字段的值 public void setDicCode(String dicCode) { this.dicCode = dicCode; } + /** - * 设置:字段名 - */ + * 设置:字段名 + */ + // 获取字段名称值的方法,外部可以通过调用该方法获取 dicName 字段的值 public String getDicName() { return dicName; } - /** - * 获取:字段名 - */ - + * 获取:字段名 + */ + // 设置字段名称值的方法,外部可以通过调用该方法设置 dicName 字段的值 public void setDicName(String dicName) { this.dicName = dicName; } + /** - * 设置:编码 - */ + * 设置:编码 + */ + // 获取编码值的方法,外部可以通过调用该方法获取 codeIndex 字段的值 public Integer getCodeIndex() { return codeIndex; } - /** - * 获取:编码 - */ - + * 获取:编码 + */ + // 设置编码值的方法,外部可以通过调用该方法设置 codeIndex 字段的值 public void setCodeIndex(Integer codeIndex) { this.codeIndex = codeIndex; } + /** - * 设置:编码名字 - */ + * 设置:编码名字 + */ + // 获取编码名称值的方法,外部可以通过调用该方法获取 indexName 字段的值 public String getIndexName() { return indexName; } - /** - * 获取:编码名字 - */ - + * 获取:编码名字 + */ + // 设置编码名称值的方法,外部可以通过调用该方法设置 indexName 字段的值 public void setIndexName(String indexName) { this.indexName = indexName; } + /** - * 设置:父字段id - */ + * 设置:父字段id + */ + // 获取父字段 ID 值的方法,外部可以通过调用该方法获取 superId 字段的值 public Integer getSuperId() { return superId; } - /** - * 获取:父字段id - */ - + * 获取:父字段id + */ + // 设置父字段 ID 值的方法,外部可以通过调用该方法设置 superId 字段的值 public void setSuperId(Integer superId) { this.superId = superId; } + /** - * 设置:备注 - */ + * 设置:备注 + */ + // 获取备注信息值的方法,外部可以通过调用该方法获取 beizhu 字段的值 public String getBeizhu() { return beizhu; } - /** - * 获取:备注 - */ - + * 获取:备注 + */ + // 设置备注信息值的方法,外部可以通过调用该方法设置 beizhu 字段的值 public void setBeizhu(String beizhu) { this.beizhu = beizhu; } + /** - * 设置:创建时间 - */ + * 设置:创建时间 + */ + // 获取创建时间值的方法,外部可以通过调用该方法获取 createTime 字段的值 public Date getCreateTime() { return createTime; } - /** - * 获取:创建时间 - */ - + * 获取:创建时间 + */ + // 设置创建时间值的方法,外部可以通过调用该方法设置 createTime 字段的值 public void setCreateTime(Date createTime) { this.createTime = createTime; } + // 重写 toString 方法,返回对象的字符串表示,方便调试和日志记录 @Override public String toString() { return "Dictionary{" + - "id=" + id + - ", dicCode=" + dicCode + - ", dicName=" + dicName + - ", codeIndex=" + codeIndex + - ", indexName=" + indexName + - ", superId=" + superId + - ", beizhu=" + beizhu + - ", createTime=" + createTime + - "}"; - } -} + "id=" + id + + ", dicCode=" + dicCode + + ", dicName=" + dicName + + ", codeIndex=" + codeIndex + + ", indexName=" + indexName + + ", superId=" + superId + + ", beizhu=" + beizhu + + ", createTime=" + createTime + + "}"; + } +} \ No newline at end of file diff --git a/src/main/java/com/entity/EIException.java b/src/main/java/com/entity/EIException.java index 2ebfb56..1245d2e 100644 --- a/src/main/java/com/entity/EIException.java +++ b/src/main/java/com/entity/EIException.java @@ -1,52 +1,64 @@ - package com.entity; /** * 自定义异常 */ +// 定义一个名为EIException的类,它继承自RuntimeException,表明这是一个运行时异常类 public class EIException extends RuntimeException { + // 定义序列化版本号,用于在序列化和反序列化过程中确保兼容性 private static final long serialVersionUID = 1L; - - private String msg; - private int code = 500; - - public EIException(String msg) { + + // 用于存储异常的详细信息,描述异常发生的情况 + private String msg; + // 用于存储异常的状态码,默认值为500,通常表示服务器内部错误 + private int code = 500; + + // 构造函数,接受一个字符串参数msg,将其设置为异常信息,并调用父类的构造函数传递异常信息 + public EIException(String msg) { super(msg); this.msg = msg; } - + + // 构造函数,接受一个字符串参数msg和一个Throwable对象e, + // 将msg设置为异常信息,调用父类的构造函数传递异常信息和异常原因 public EIException(String msg, Throwable e) { super(msg, e); this.msg = msg; } - + + // 构造函数,接受一个字符串参数msg和一个整数参数code, + // 将msg设置为异常信息,code设置为异常状态码,并调用父类的构造函数传递异常信息 public EIException(String msg, int code) { super(msg); this.msg = msg; this.code = code; } - + + // 构造函数,接受一个字符串参数msg、一个整数参数code和一个Throwable对象e, + // 将msg设置为异常信息,code设置为异常状态码,调用父类的构造函数传递异常信息和异常原因 public EIException(String msg, int code, Throwable e) { super(msg, e); this.msg = msg; this.code = code; } + // 获取异常信息的方法,返回存储的异常信息字符串 public String getMsg() { return msg; } + // 设置异常信息的方法,将传入的字符串设置为新的异常信息 public void setMsg(String msg) { this.msg = msg; } + // 获取异常状态码的方法,返回存储的异常状态码 public int getCode() { return code; } + // 设置异常状态码的方法,将传入的整数设置为新的异常状态码 public void setCode(int code) { this.code = code; } - - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/GuahaoEntity.java b/src/main/java/com/entity/GuahaoEntity.java index d2aec62..b7bba0b 100644 --- a/src/main/java/com/entity/GuahaoEntity.java +++ b/src/main/java/com/entity/GuahaoEntity.java @@ -1,299 +1,330 @@ package com.entity; +// 导入 MyBatis-Plus 用于指定主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入 MyBatis-Plus 用于指定数据库表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入 JSR 303 验证注解(在当前代码中未实际使用) import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; - +// 导入 Jackson 注解(在当前代码中未实际使用) import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入反射调用可能抛出的异常类 import java.lang.reflect.InvocationTargetException; - +// 导入序列化接口 import java.io.Serializable; +// 导入日期类 import java.util.Date; +// 导入列表集合类(在当前代码中未实际使用) import java.util.List; - +// 导入 Spring 框架用于日期格式化的注解 import org.springframework.format.annotation.DateTimeFormat; +// 导入 Jackson 用于 JSON 序列化时日期格式化的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入 Apache Commons BeanUtils 工具类,用于对象属性复制 import org.apache.commons.beanutils.BeanUtils; +// 导入 MyBatis-Plus 用于指定字段的注解 import com.baomidou.mybatisplus.annotations.TableField; +// 导入 MyBatis-Plus 字段填充策略枚举 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入 MyBatis-Plus 主键生成策略枚举 import com.baomidou.mybatisplus.enums.IdType; /** * 挂号 * - * @author + * @author * @email */ +// 使用 TableName 注解指定该类对应的数据库表名为 "guahao" @TableName("guahao") +// 定义泛型类 GuahaoEntity,实现 Serializable 接口,以便对象可以进行序列化和反序列化 public class GuahaoEntity implements Serializable { + // 定义序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性 private static final long serialVersionUID = 1L; + // 无参构造函数,用于创建 GuahaoEntity 对象 + public GuahaoEntity() { - public GuahaoEntity() { - - } - - public GuahaoEntity(T t) { - try { - BeanUtils.copyProperties(this, t); - } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } + } + // 带参构造函数,接受一个泛型对象 t,通过 BeanUtils.copyProperties 方法 + // 将对象 t 的属性复制到当前 GuahaoEntity 对象中 + public GuahaoEntity(T t) { + try { + BeanUtils.copyProperties(this, t); + } catch (IllegalAccessException | InvocationTargetException e) { + // 如果在复制属性过程中出现异常,打印异常堆栈信息 + e.printStackTrace(); + } + } /** * 主键 */ + // 使用 TableId 注解指定该字段为主键,主键生成策略为自动增长(AUTO) @TableId(type = IdType.AUTO) + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "id" @TableField(value = "id") - + // 存储挂号记录的主键值,用于唯一标识一条挂号记录 private Integer id; - /** * 医生 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "yisheng_id" @TableField(value = "yisheng_id") - + // 存储挂号对应的医生 ID,关联医生表 private Integer yishengId; - /** * 用户 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "yonghu_id" @TableField(value = "yonghu_id") - + // 存储挂号的用户 ID,关联用户表 private Integer yonghuId; - /** * 就诊识别码 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "guahao_uuin_number" @TableField(value = "guahao_uuin_number") - + // 存储就诊的唯一识别码,用于标识具体的就诊记录 private String guahaoUuinNumber; - /** * 挂号时间 */ - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd") - @DateTimeFormat + // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd") + // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象 + @DateTimeFormat + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "guahao_time" @TableField(value = "guahao_time") - + // 存储挂号的具体时间 private Date guahaoTime; - /** * 时间类型 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "guahao_types" @TableField(value = "guahao_types") - + // 存储挂号的时间类型,可能表示上午、下午、晚上等不同时间段,用整数标识 private Integer guahaoTypes; - /** * 挂号状态 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "guahao_status_types" @TableField(value = "guahao_status_types") - + // 存储挂号的状态,例如已挂号、已取消、已就诊等,用整数标识不同状态 private Integer guahaoStatusTypes; - /** * 挂号审核 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "guahao_yesno_types" @TableField(value = "guahao_yesno_types") - + // 存储挂号审核的结果,可能表示通过、不通过等,用整数标识 private Integer guahaoYesnoTypes; - /** * 审核结果 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "guahao_yesno_text" @TableField(value = "guahao_yesno_text") - + // 存储挂号审核结果的具体文本描述,例如不通过的原因等 private String guahaoYesnoText; - /** * 创建时间 */ - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat - @TableField(value = "create_time",fill = FieldFill.INSERT) - + // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象 + @DateTimeFormat + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "create_time", + // 并设置在插入数据时自动填充当前时间 + @TableField(value = "create_time", fill = FieldFill.INSERT) + // 存储挂号记录的创建时间,用于记录数据的创建时间戳 private Date createTime; - /** - * 设置:主键 - */ + * 设置:主键 + */ + // 获取主键值的方法,外部可以通过调用该方法获取 id 字段的值 public Integer getId() { return id; } - /** - * 获取:主键 - */ - + * 获取:主键 + */ + // 设置主键值的方法,外部可以通过调用该方法设置 id 字段的值 public void setId(Integer id) { this.id = id; } + /** - * 设置:医生 - */ + * 设置:医生 + */ + // 获取医生 ID 值的方法,外部可以通过调用该方法获取 yishengId 字段的值 public Integer getYishengId() { return yishengId; } - /** - * 获取:医生 - */ - + * 获取:医生 + */ + // 设置医生 ID 值的方法,外部可以通过调用该方法设置 yishengId 字段的值 public void setYishengId(Integer yishengId) { this.yishengId = yishengId; } + /** - * 设置:用户 - */ + * 设置:用户 + */ + // 获取用户 ID 值的方法,外部可以通过调用该方法获取 yonghuId 字段的值 public Integer getYonghuId() { return yonghuId; } - /** - * 获取:用户 - */ - + * 获取:用户 + */ + // 设置用户 ID 值的方法,外部可以通过调用该方法设置 yonghuId 字段的值 public void setYonghuId(Integer yonghuId) { this.yonghuId = yonghuId; } + /** - * 设置:就诊识别码 - */ + * 设置:就诊识别码 + */ + // 获取就诊识别码值的方法,外部可以通过调用该方法获取 guahaoUuinNumber 字段的值 public String getGuahaoUuinNumber() { return guahaoUuinNumber; } - /** - * 获取:就诊识别码 - */ - + * 获取:就诊识别码 + */ + // 设置就诊识别码值的方法,外部可以通过调用该方法设置 guahaoUuinNumber 字段的值 public void setGuahaoUuinNumber(String guahaoUuinNumber) { this.guahaoUuinNumber = guahaoUuinNumber; } + /** - * 设置:挂号时间 - */ + * 设置:挂号时间 + */ + // 获取挂号时间值的方法,外部可以通过调用该方法获取 guahaoTime 字段的值 public Date getGuahaoTime() { return guahaoTime; } - /** - * 获取:挂号时间 - */ - + * 获取:挂号时间 + */ + // 设置挂号时间值的方法,外部可以通过调用该方法设置 guahaoTime 字段的值 public void setGuahaoTime(Date guahaoTime) { this.guahaoTime = guahaoTime; } + /** - * 设置:时间类型 - */ + * 设置:时间类型 + */ + // 获取时间类型值的方法,外部可以通过调用该方法获取 guahaoTypes 字段的值 public Integer getGuahaoTypes() { return guahaoTypes; } - /** - * 获取:时间类型 - */ - + * 获取:时间类型 + */ + // 设置时间类型值的方法,外部可以通过调用该方法设置 guahaoTypes 字段的值 public void setGuahaoTypes(Integer guahaoTypes) { this.guahaoTypes = guahaoTypes; } + /** - * 设置:挂号状态 - */ + * 设置:挂号状态 + */ + // 获取挂号状态值的方法,外部可以通过调用该方法获取 guahaoStatusTypes 字段的值 public Integer getGuahaoStatusTypes() { return guahaoStatusTypes; } - /** - * 获取:挂号状态 - */ - + * 获取:挂号状态 + */ + // 设置挂号状态值的方法,外部可以通过调用该方法设置 guahaoStatusTypes 字段的值 public void setGuahaoStatusTypes(Integer guahaoStatusTypes) { this.guahaoStatusTypes = guahaoStatusTypes; } + /** - * 设置:挂号审核 - */ + * 设置:挂号审核 + */ + // 获取挂号审核值的方法,外部可以通过调用该方法获取 guahaoYesnoTypes 字段的值 public Integer getGuahaoYesnoTypes() { return guahaoYesnoTypes; } - /** - * 获取:挂号审核 - */ - + * 获取:挂号审核 + */ + // 设置挂号审核值的方法,外部可以通过调用该方法设置 guahaoYesnoTypes 字段的值 public void setGuahaoYesnoTypes(Integer guahaoYesnoTypes) { this.guahaoYesnoTypes = guahaoYesnoTypes; } + /** - * 设置:审核结果 - */ + * 设置:审核结果 + */ + // 获取审核结果值的方法,外部可以通过调用该方法获取 guahaoYesnoText 字段的值 public String getGuahaoYesnoText() { return guahaoYesnoText; } - /** - * 获取:审核结果 - */ - + * 获取:审核结果 + */ + // 设置审核结果值的方法,外部可以通过调用该方法设置 guahaoYesnoText 字段的值 public void setGuahaoYesnoText(String guahaoYesnoText) { this.guahaoYesnoText = guahaoYesnoText; } + /** - * 设置:创建时间 - */ + * 设置:创建时间 + */ + // 获取创建时间值的方法,外部可以通过调用该方法获取 createTime 字段的值 public Date getCreateTime() { return createTime; } - /** - * 获取:创建时间 - */ - + * 获取:创建时间 + */ + // 设置创建时间值的方法,外部可以通过调用该方法设置 createTime 字段的值 public void setCreateTime(Date createTime) { this.createTime = createTime; } + // 重写 toString 方法,返回对象的字符串表示,方便调试和日志记录 @Override public String toString() { return "Guahao{" + - "id=" + id + - ", yishengId=" + yishengId + - ", yonghuId=" + yonghuId + - ", guahaoUuinNumber=" + guahaoUuinNumber + - ", guahaoTime=" + guahaoTime + - ", guahaoTypes=" + guahaoTypes + - ", guahaoStatusTypes=" + guahaoStatusTypes + - ", guahaoYesnoTypes=" + guahaoYesnoTypes + - ", guahaoYesnoText=" + guahaoYesnoText + - ", createTime=" + createTime + - "}"; + "id=" + id + + ", yishengId=" + yishengId + + ", yonghuId=" + yonghuId + + ", guahaoUuinNumber=" + guahaoUuinNumber + + ", guahaoTime=" + guahaoTime + + ", guahaoTypes=" + guahaoTypes + + ", guahaoStatusTypes=" + guahaoStatusTypes + + ", guahaoYesnoTypes=" + guahaoYesnoTypes + + ", guahaoYesnoText=" + guahaoYesnoText + + ", createTime=" + createTime + + "}"; } -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/JiankangjiaoyuEntity.java b/src/main/java/com/entity/JiankangjiaoyuEntity.java index e4c4d78..ebe1515 100644 --- a/src/main/java/com/entity/JiankangjiaoyuEntity.java +++ b/src/main/java/com/entity/JiankangjiaoyuEntity.java @@ -1,251 +1,279 @@ package com.entity; +// 导入 MyBatis-Plus 用于指定主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入 MyBatis-Plus 用于指定数据库表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入 JSR 303 验证注解,可用于字段验证,当前代码未使用这些注解进行实际验证 import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; - +// 导入 Jackson 注解,可用于忽略 JSON 序列化和反序列化时的某些属性,当前代码未使用 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入反射调用可能抛出的异常类 import java.lang.reflect.InvocationTargetException; - +// 导入序列化接口,使该类的对象可以进行序列化和反序列化操作 import java.io.Serializable; +// 导入日期类 import java.util.Date; +// 导入列表集合类,当前代码未使用 import java.util.List; - +// 导入 Spring 框架用于日期格式化的注解,用于将字符串日期转换为 Date 对象 import org.springframework.format.annotation.DateTimeFormat; +// 导入 Jackson 用于 JSON 序列化时日期格式化的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入 Apache Commons BeanUtils 工具类,用于对象属性复制 import org.apache.commons.beanutils.BeanUtils; +// 导入 MyBatis-Plus 用于指定字段的注解 import com.baomidou.mybatisplus.annotations.TableField; +// 导入 MyBatis-Plus 字段填充策略枚举 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入 MyBatis-Plus 主键生成策略枚举 import com.baomidou.mybatisplus.enums.IdType; /** * 健康教育 * - * @author + * @author * @email */ +// 指定该类对应数据库中的 jiankangjiaoyu 表 @TableName("jiankangjiaoyu") +// 定义泛型类,实现 Serializable 接口 public class JiankangjiaoyuEntity implements Serializable { + // 序列化版本号,确保序列化和反序列化的兼容性 private static final long serialVersionUID = 1L; + // 无参构造函数,方便创建 JiankangjiaoyuEntity 类的实例 + public JiankangjiaoyuEntity() { - public JiankangjiaoyuEntity() { - - } - - public JiankangjiaoyuEntity(T t) { - try { - BeanUtils.copyProperties(this, t); - } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } + } + // 带参构造函数,接收一个泛型对象 t,将其属性复制到当前 JiankangjiaoyuEntity 对象 + public JiankangjiaoyuEntity(T t) { + try { + // 使用 BeanUtils 工具类复制属性 + BeanUtils.copyProperties(this, t); + } catch (IllegalAccessException | InvocationTargetException e) { + // 若复制属性过程中出现异常,打印异常堆栈信息 + e.printStackTrace(); + } + } /** * 主键 */ + // 指定该字段为主键,且主键生成策略为自增 @TableId(type = IdType.AUTO) + // 指定该字段对应数据库表中的 id 字段 @TableField(value = "id") - + // 主键,用于唯一标识一条健康教育记录 private Integer id; - /** * 健康教育标题 */ + // 指定该字段对应数据库表中的 jiankangjiaoyu_name 字段 @TableField(value = "jiankangjiaoyu_name") - + // 健康教育的标题 private String jiankangjiaoyuName; - /** * 健康教育类型 */ + // 指定该字段对应数据库表中的 jiankangjiaoyu_types 字段 @TableField(value = "jiankangjiaoyu_types") - + // 健康教育的类型,用整数表示不同类型 private Integer jiankangjiaoyuTypes; - /** * 健康教育图片 */ + // 指定该字段对应数据库表中的 jiankangjiaoyu_photo 字段 @TableField(value = "jiankangjiaoyu_photo") - + // 健康教育相关图片的存储路径 private String jiankangjiaoyuPhoto; - /** * 健康教育时间 */ - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat - @TableField(value = "insert_time",fill = FieldFill.INSERT) - + // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象 + @DateTimeFormat + // 指定该字段对应数据库表中的 insert_time 字段,且在插入数据时自动填充 + @TableField(value = "insert_time", fill = FieldFill.INSERT) + // 健康教育的时间 private Date insertTime; - /** * 健康教育详情 */ + // 指定该字段对应数据库表中的 jiankangjiaoyu_content 字段 @TableField(value = "jiankangjiaoyu_content") - + // 健康教育的详细内容 private String jiankangjiaoyuContent; - /** * 假删 */ + // 指定该字段对应数据库表中的 jiankangjiaoyu_delete 字段 @TableField(value = "jiankangjiaoyu_delete") - + // 假删除标记,用整数表示是否删除,如 0 表示未删除,1 表示已删除 private Integer jiankangjiaoyuDelete; - /** * 创建时间 */ - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat - @TableField(value = "create_time",fill = FieldFill.INSERT) - + // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象 + @DateTimeFormat + // 指定该字段对应数据库表中的 create_time 字段,且在插入数据时自动填充 + @TableField(value = "create_time", fill = FieldFill.INSERT) + // 该条健康教育记录的创建时间 private Date createTime; - /** - * 设置:主键 - */ + * 设置:主键 + */ + // 获取主键的方法 public Integer getId() { return id; } - /** - * 获取:主键 - */ - + * 获取:主键 + */ + // 设置主键的方法 public void setId(Integer id) { this.id = id; } + /** - * 设置:健康教育标题 - */ + * 设置:健康教育标题 + */ + // 获取健康教育标题的方法 public String getJiankangjiaoyuName() { return jiankangjiaoyuName; } - /** - * 获取:健康教育标题 - */ - + * 获取:健康教育标题 + */ + // 设置健康教育标题的方法 public void setJiankangjiaoyuName(String jiankangjiaoyuName) { this.jiankangjiaoyuName = jiankangjiaoyuName; } + /** - * 设置:健康教育类型 - */ + * 设置:健康教育类型 + */ + // 获取健康教育类型的方法 public Integer getJiankangjiaoyuTypes() { return jiankangjiaoyuTypes; } - /** - * 获取:健康教育类型 - */ - + * 获取:健康教育类型 + */ + // 设置健康教育类型的方法 public void setJiankangjiaoyuTypes(Integer jiankangjiaoyuTypes) { this.jiankangjiaoyuTypes = jiankangjiaoyuTypes; } + /** - * 设置:健康教育图片 - */ + * 设置:健康教育图片 + */ + // 获取健康教育图片路径的方法 public String getJiankangjiaoyuPhoto() { return jiankangjiaoyuPhoto; } - /** - * 获取:健康教育图片 - */ - + * 获取:健康教育图片 + */ + // 设置健康教育图片路径的方法 public void setJiankangjiaoyuPhoto(String jiankangjiaoyuPhoto) { this.jiankangjiaoyuPhoto = jiankangjiaoyuPhoto; } + /** - * 设置:健康教育时间 - */ + * 设置:健康教育时间 + */ + // 获取健康教育时间的方法 public Date getInsertTime() { return insertTime; } - /** - * 获取:健康教育时间 - */ - + * 获取:健康教育时间 + */ + // 设置健康教育时间的方法 public void setInsertTime(Date insertTime) { this.insertTime = insertTime; } + /** - * 设置:健康教育详情 - */ + * 设置:健康教育详情 + */ + // 获取健康教育详情的方法 public String getJiankangjiaoyuContent() { return jiankangjiaoyuContent; } - /** - * 获取:健康教育详情 - */ - + * 获取:健康教育详情 + */ + // 设置健康教育详情的方法 public void setJiankangjiaoyuContent(String jiankangjiaoyuContent) { this.jiankangjiaoyuContent = jiankangjiaoyuContent; } + /** - * 设置:假删 - */ + * 设置:假删 + */ + // 获取假删除标记的方法 public Integer getJiankangjiaoyuDelete() { return jiankangjiaoyuDelete; } - /** - * 获取:假删 - */ - + * 获取:假删 + */ + // 设置假删除标记的方法 public void setJiankangjiaoyuDelete(Integer jiankangjiaoyuDelete) { this.jiankangjiaoyuDelete = jiankangjiaoyuDelete; } + /** - * 设置:创建时间 - */ + * 设置:创建时间 + */ + // 获取创建时间的方法 public Date getCreateTime() { return createTime; } - /** - * 获取:创建时间 - */ - + * 获取:创建时间 + */ + // 设置创建时间的方法 public void setCreateTime(Date createTime) { this.createTime = createTime; } + // 重写 toString 方法,方便打印对象信息 @Override public String toString() { return "Jiankangjiaoyu{" + - "id=" + id + - ", jiankangjiaoyuName=" + jiankangjiaoyuName + - ", jiankangjiaoyuTypes=" + jiankangjiaoyuTypes + - ", jiankangjiaoyuPhoto=" + jiankangjiaoyuPhoto + - ", insertTime=" + insertTime + - ", jiankangjiaoyuContent=" + jiankangjiaoyuContent + - ", jiankangjiaoyuDelete=" + jiankangjiaoyuDelete + - ", createTime=" + createTime + - "}"; - } -} + "id=" + id + + ", jiankangjiaoyuName=" + jiankangjiaoyuName + + ", jiankangjiaoyuTypes=" + jiankangjiaoyuTypes + + ", jiankangjiaoyuPhoto=" + jiankangjiaoyuPhoto + + ", insertTime=" + insertTime + + ", jiankangjiaoyuContent=" + jiankangjiaoyuContent + + ", jiankangjiaoyuDelete=" + jiankangjiaoyuDelete + + ", createTime=" + createTime + + "}"; + } +} \ No newline at end of file diff --git a/src/main/java/com/entity/NewsEntity.java b/src/main/java/com/entity/NewsEntity.java index 50e42be..7c61650 100644 --- a/src/main/java/com/entity/NewsEntity.java +++ b/src/main/java/com/entity/NewsEntity.java @@ -1,227 +1,256 @@ package com.entity; +// 导入 MyBatis-Plus 用于指定主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入 MyBatis-Plus 用于指定数据库表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入 JSR 303 验证注解(当前未实际使用) import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; - +// 导入 Jackson 用于忽略属性的注解(当前未实际使用) import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入反射调用可能抛出的异常类 import java.lang.reflect.InvocationTargetException; - +// 导入序列化接口 import java.io.Serializable; +// 导入日期类 import java.util.Date; +// 导入列表类(当前未实际使用) import java.util.List; - +// 导入 Spring 用于日期格式化的注解 import org.springframework.format.annotation.DateTimeFormat; +// 导入 Jackson 用于 JSON 序列化时日期格式化的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入 Apache Commons BeanUtils 工具类,用于对象属性复制 import org.apache.commons.beanutils.BeanUtils; +// 导入 MyBatis-Plus 用于指定字段的注解 import com.baomidou.mybatisplus.annotations.TableField; +// 导入 MyBatis-Plus 字段填充策略枚举 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入 MyBatis-Plus 主键生成策略枚举 import com.baomidou.mybatisplus.enums.IdType; /** * 公告信息 * - * @author + * @author * @email */ +// 使用 TableName 注解指定该类对应的数据库表名为 "news" @TableName("news") +// 定义泛型类 NewsEntity,实现 Serializable 接口,用于对象的序列化和反序列化 public class NewsEntity implements Serializable { + // 定义序列化版本号,保证序列化和反序列化的兼容性 private static final long serialVersionUID = 1L; + // 无参构造函数,用于创建 NewsEntity 对象 + public NewsEntity() { - public NewsEntity() { - - } - - public NewsEntity(T t) { - try { - BeanUtils.copyProperties(this, t); - } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } + } + // 带参构造函数,接受一个泛型对象 t,通过 BeanUtils.copyProperties 方法 + // 将对象 t 的属性复制到当前 NewsEntity 对象中 + public NewsEntity(T t) { + try { + BeanUtils.copyProperties(this, t); + } catch (IllegalAccessException | InvocationTargetException e) { + // 如果在复制属性过程中出现异常,打印异常堆栈信息 + e.printStackTrace(); + } + } /** * 主键 */ + // 使用 TableId 注解指定该字段为主键,主键生成策略为自动增长(IdType.AUTO) @TableId(type = IdType.AUTO) + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "id" @TableField(value = "id") - + // 存储公告信息记录的主键值,用于唯一标识一条公告记录 private Integer id; - /** * 公告名称 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "news_name" @TableField(value = "news_name") - + // 存储公告的名称 private String newsName; - /** * 公告图片 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "news_photo" @TableField(value = "news_photo") - + // 存储公告相关图片的路径或标识 private String newsPhoto; - /** * 公告类型 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "news_types" @TableField(value = "news_types") - + // 存储公告的类型,用整数表示不同的公告类型,如通知、公告等 private Integer newsTypes; - /** * 公告发布时间 */ - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat - @TableField(value = "insert_time",fill = FieldFill.INSERT) - + // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象 + @DateTimeFormat + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "insert_time", + // 并设置在插入数据时自动填充当前时间 + @TableField(value = "insert_time", fill = FieldFill.INSERT) + // 存储公告的发布时间 private Date insertTime; - /** * 公告详情 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "news_content" @TableField(value = "news_content") - + // 存储公告的详细内容 private String newsContent; - /** * 创建时间 */ - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat - @TableField(value = "create_time",fill = FieldFill.INSERT) - + // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象 + @DateTimeFormat + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "create_time", + // 并设置在插入数据时自动填充当前时间 + @TableField(value = "create_time", fill = FieldFill.INSERT) + // 存储公告记录的创建时间,用于记录数据的创建时间戳 private Date createTime; - /** - * 设置:主键 - */ + * 设置:主键 + */ + // 获取主键值的方法 public Integer getId() { return id; } - /** - * 获取:主键 - */ - + * 获取:主键 + */ + // 设置主键值的方法 public void setId(Integer id) { this.id = id; } + /** - * 设置:公告名称 - */ + * 设置:公告名称 + */ + // 获取公告名称值的方法 public String getNewsName() { return newsName; } - /** - * 获取:公告名称 - */ - + * 获取:公告名称 + */ + // 设置公告名称值的方法 public void setNewsName(String newsName) { this.newsName = newsName; } + /** - * 设置:公告图片 - */ + * 设置:公告图片 + */ + // 获取公告图片路径值的方法 public String getNewsPhoto() { return newsPhoto; } - /** - * 获取:公告图片 - */ - + * 获取:公告图片 + */ + // 设置公告图片路径值的方法 public void setNewsPhoto(String newsPhoto) { this.newsPhoto = newsPhoto; } + /** - * 设置:公告类型 - */ + * 设置:公告类型 + */ + // 获取公告类型值的方法 public Integer getNewsTypes() { return newsTypes; } - /** - * 获取:公告类型 - */ - + * 获取:公告类型 + */ + // 设置公告类型值的方法 public void setNewsTypes(Integer newsTypes) { this.newsTypes = newsTypes; } + /** - * 设置:公告发布时间 - */ + * 设置:公告发布时间 + */ + // 获取公告发布时间值的方法 public Date getInsertTime() { return insertTime; } - /** - * 获取:公告发布时间 - */ - + * 获取:公告发布时间 + */ + // 设置公告发布时间值的方法 public void setInsertTime(Date insertTime) { this.insertTime = insertTime; } + /** - * 设置:公告详情 - */ + * 设置:公告详情 + */ + // 获取公告详情值的方法 public String getNewsContent() { return newsContent; } - /** - * 获取:公告详情 - */ - + * 获取:公告详情 + */ + // 设置公告详情值的方法 public void setNewsContent(String newsContent) { this.newsContent = newsContent; } + /** - * 设置:创建时间 - */ + * 设置:创建时间 + */ + // 获取创建时间值的方法 public Date getCreateTime() { return createTime; } - /** - * 获取:创建时间 - */ - + * 获取:创建时间 + */ + // 设置创建时间值的方法 public void setCreateTime(Date createTime) { this.createTime = createTime; } + // 重写 toString 方法,返回对象的字符串表示,方便调试和日志记录 @Override public String toString() { return "News{" + - "id=" + id + - ", newsName=" + newsName + - ", newsPhoto=" + newsPhoto + - ", newsTypes=" + newsTypes + - ", insertTime=" + insertTime + - ", newsContent=" + newsContent + - ", createTime=" + createTime + - "}"; - } -} + "id=" + id + + ", newsName=" + newsName + + ", newsPhoto=" + newsPhoto + + ", newsTypes=" + newsTypes + + ", insertTime=" + insertTime + + ", newsContent=" + newsContent + + ", createTime=" + createTime + + "}"; + } +} \ No newline at end of file diff --git a/src/main/java/com/entity/TokenEntity.java b/src/main/java/com/entity/TokenEntity.java index bdc0824..4f95c1d 100644 --- a/src/main/java/com/entity/TokenEntity.java +++ b/src/main/java/com/entity/TokenEntity.java @@ -1,122 +1,156 @@ package com.entity; +// 导入序列化接口,使该类的对象可以进行序列化和反序列化 import java.io.Serializable; +// 导入日期类,用于处理日期相关的操作 import java.util.Date; +// 导入 MyBatis-Plus 用于指定主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入 MyBatis-Plus 用于指定数据库表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入 MyBatis-Plus 主键生成策略枚举 import com.baomidou.mybatisplus.enums.IdType; -/** +/** * token表 */ +// 使用 TableName 注解指定该类对应的数据库表名为 "token" @TableName("token") +//定义 TokenEntity 类,实现 Serializable 接口,以支持对象的序列化和反序列化 public class TokenEntity implements Serializable { + // 定义序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性 private static final long serialVersionUID = 1L; - + + // 使用 TableId 注解指定该字段为主键,主键生成策略为自动增长(AUTO) @TableId(type = IdType.AUTO) + // 存储记录的主键值,用于唯一标识一条 token 记录 private Integer id; - + /** * 用户id */ + // 存储与该 token 相关联的用户 ID private Integer userid; - + /** * 用户名 */ + // 存储与该 token 相关联的用户名 private String username; - + /** * 表名 */ + // 存储与该 token 相关的表名(具体用途可能根据业务需求而定) private String tablename; - + /** * 角色 */ + // 存储用户的角色信息,用于权限控制等 private String role; - + /** * token */ + // 存储具体的 token 值,用于身份验证和授权 private String token; - + /** * 过期时间 */ + // 存储该 token 的过期时间,用于判断 token 是否有效 private Date expiratedtime; - + /** * 新增时间 */ + // 存储该 token 记录的创建时间,用于记录数据的生成时间戳 private Date addtime; + // 获取主键值的方法 public Integer getId() { return id; } + // 设置主键值的方法 public void setId(Integer id) { this.id = id; } + // 获取用户 ID 的方法 public Integer getUserid() { return userid; } + // 设置用户 ID 的方法 public void setUserid(Integer userid) { this.userid = userid; } + // 获取角色信息的方法 public String getRole() { return role; } + // 设置角色信息的方法 public void setRole(String role) { this.role = role; } + // 获取 token 值的方法 public String getToken() { return token; } + // 获取表名的方法 public String getTablename() { return tablename; } + // 设置表名的方法 public void setTablename(String tablename) { this.tablename = tablename; } + // 设置 token 值的方法 public void setToken(String token) { this.token = token; } + // 获取过期时间的方法 public Date getExpiratedtime() { return expiratedtime; } + // 设置过期时间的方法 public void setExpiratedtime(Date expiratedtime) { this.expiratedtime = expiratedtime; } + // 获取新增时间的方法 public Date getAddtime() { return addtime; } + // 设置新增时间的方法 public void setAddtime(Date addtime) { this.addtime = addtime; } + // 获取用户名的方法 public String getUsername() { return username; } + // 设置用户名的方法 public void setUsername(String username) { this.username = username; } - public TokenEntity(Integer userid, String username, String tablename,String role, String token, Date expiratedtime) { + // 带参数的构造函数,用于初始化 TokenEntity 对象的部分属性 + public TokenEntity(Integer userid, String username, String tablename, String role, String token, Date expiratedtime) { super(); this.userid = userid; this.username = username; @@ -125,8 +159,8 @@ public class TokenEntity implements Serializable { this.token = token; this.expiratedtime = expiratedtime; } - + + // 无参构造函数,用于创建 TokenEntity 对象的实例 public TokenEntity() { } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/UsersEntity.java b/src/main/java/com/entity/UsersEntity.java index 99617d9..d77a5f7 100644 --- a/src/main/java/com/entity/UsersEntity.java +++ b/src/main/java/com/entity/UsersEntity.java @@ -1,77 +1,100 @@ package com.entity; +// 导入序列化接口,使该类的对象可以进行序列化和反序列化操作 import java.io.Serializable; +// 导入日期类,用于处理与日期相关的操作 import java.util.Date; +// 导入 MyBatis-Plus 用于指定主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入 MyBatis-Plus 用于指定数据库表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入 MyBatis-Plus 主键生成策略枚举 import com.baomidou.mybatisplus.enums.IdType; -/** +/** * 用户 */ +// 使用 TableName 注解指定该类对应的数据库表名为 "users" @TableName("users") +// 定义 UsersEntity 类,实现 Serializable 接口,以支持对象的序列化和反序列化 public class UsersEntity implements Serializable { + // 定义序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性 private static final long serialVersionUID = 1L; - + + // 使用 TableId 注解指定该字段为主键,主键生成策略为自动增长(AUTO) @TableId(type = IdType.AUTO) + // 存储用户记录的主键值,用于唯一标识一条用户记录 private Integer id; - + /** * 用户账号 */ + // 存储用户的账号信息,用于登录等操作 private String username; - + /** * 密码 */ + // 存储用户的密码信息,用于验证用户身份 private String password; - + /** * 用户类型 */ + // 存储用户的类型信息,例如普通用户、管理员等,用于权限控制等 private String role; - + + // 存储用户记录的创建时间,用于记录数据的生成时间戳 private Date addtime; + // 获取用户账号的方法 public String getUsername() { return username; } + // 设置用户账号的方法 public void setUsername(String username) { this.username = username; } + // 获取用户密码的方法 public String getPassword() { return password; } + // 设置用户密码的方法 public void setPassword(String password) { this.password = password; } + // 获取用户类型的方法 public String getRole() { return role; } + // 设置用户类型的方法 public void setRole(String role) { this.role = role; } + // 获取用户记录创建时间的方法 public Date getAddtime() { return addtime; } + // 设置用户记录创建时间的方法 public void setAddtime(Date addtime) { this.addtime = addtime; } + // 获取用户记录主键的方法 public Integer getId() { return id; } + // 设置用户记录主键的方法 public void setId(Integer id) { this.id = id; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/YishengEntity.java b/src/main/java/com/entity/YishengEntity.java index aabc27f..6a73b45 100644 --- a/src/main/java/com/entity/YishengEntity.java +++ b/src/main/java/com/entity/YishengEntity.java @@ -1,417 +1,451 @@ package com.entity; +// 导入 MyBatis-Plus 用于指定主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入 MyBatis-Plus 用于指定数据库表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入 JSR 303 验证注解(在当前代码中未实际使用) import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; - +// 导入 Jackson 注解(在当前代码中未实际使用) import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入反射调用可能抛出的异常类 import java.lang.reflect.InvocationTargetException; - +// 导入序列化接口 import java.io.Serializable; +// 导入日期类 import java.util.Date; +// 导入列表集合类(在当前代码中未实际使用) import java.util.List; - +// 导入 Spring 框架用于日期格式化的注解 import org.springframework.format.annotation.DateTimeFormat; +// 导入 Jackson 用于 JSON 序列化时日期格式化的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入 Apache Commons BeanUtils 工具类,用于对象属性复制 import org.apache.commons.beanutils.BeanUtils; +// 导入 MyBatis-Plus 用于指定字段的注解 import com.baomidou.mybatisplus.annotations.TableField; +// 导入 MyBatis-Plus 字段填充策略枚举 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入 MyBatis-Plus 主键生成策略枚举 import com.baomidou.mybatisplus.enums.IdType; /** * 医生 * - * @author + * @author * @email */ +// 使用 TableName 注解指定该类对应的数据库表名为 "yisheng" @TableName("yisheng") +// 定义泛型类 YishengEntity,实现 Serializable 接口,以便对象可以进行序列化和反序列化 public class YishengEntity implements Serializable { + // 定义序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性 private static final long serialVersionUID = 1L; + // 无参构造函数,用于创建 YishengEntity 对象 + public YishengEntity() { - public YishengEntity() { - - } - - public YishengEntity(T t) { - try { - BeanUtils.copyProperties(this, t); - } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } + } + // 带参构造函数,接受一个泛型对象 t,通过 BeanUtils.copyProperties 方法 + // 将对象 t 的属性复制到当前 YishengEntity 对象中 + public YishengEntity(T t) { + try { + BeanUtils.copyProperties(this, t); + } catch (IllegalAccessException | InvocationTargetException e) { + // 如果在复制属性过程中出现异常,打印异常堆栈信息 + e.printStackTrace(); + } + } /** * 主键 */ + // 使用 TableId 注解指定该字段为主键,主键生成策略为自动增长(AUTO) @TableId(type = IdType.AUTO) + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "id" @TableField(value = "id") - + // 存储医生记录的主键值,用于唯一标识一条医生记录 private Integer id; - /** * 医生工号 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "yisheng_uuid_number" @TableField(value = "yisheng_uuid_number") - + // 存储医生的唯一工号,用于标识医生个体 private String yishengUuidNumber; - /** * 账户 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "username" @TableField(value = "username") - + // 存储医生的登录账户名 private String username; - /** * 密码 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "password" @TableField(value = "password") - + // 存储医生账户的密码 private String password; - /** * 医生名称 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "yisheng_name" @TableField(value = "yisheng_name") - + // 存储医生的真实姓名 private String yishengName; - /** * 科室 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "yisheng_types" @TableField(value = "yisheng_types") - + // 存储医生所属的科室,用整数表示不同科室类别 private Integer yishengTypes; - /** * 职位 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "zhiwei_types" @TableField(value = "zhiwei_types") - + // 存储医生的职位,用整数表示不同职位类别 private Integer zhiweiTypes; - /** * 职称 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "yisheng_zhichneg" @TableField(value = "yisheng_zhichneg") - + // 存储医生的职称信息,如主任医师、副主任医师等 private String yishengZhichneg; - /** * 医生头像 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "yisheng_photo" @TableField(value = "yisheng_photo") - + // 存储医生头像的路径或标识 private String yishengPhoto; - /** * 联系方式 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "yisheng_phone" @TableField(value = "yisheng_phone") - + // 存储医生的联系方式,如电话号码 private String yishengPhone; - /** * 挂号须知 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "yisheng_guahao" @TableField(value = "yisheng_guahao") - + // 存储医生的挂号须知内容,告知患者相关注意事项 private String yishengGuahao; - /** * 邮箱 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "yisheng_email" @TableField(value = "yisheng_email") - + // 存储医生的电子邮箱地址 private String yishengEmail; - /** * 挂号价格 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "yisheng_new_money" @TableField(value = "yisheng_new_money") - + // 存储医生的挂号价格 private Double yishengNewMoney; - /** * 履历介绍 */ + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "yisheng_content" @TableField(value = "yisheng_content") - + // 存储医生的履历介绍,展示医生的教育背景、工作经历等信息 private String yishengContent; - /** * 创建时间 */ - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat - @TableField(value = "create_time",fill = FieldFill.INSERT) - + // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象 + @DateTimeFormat + // 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "create_time", + // 并设置在插入数据时自动填充当前时间 + @TableField(value = "create_time", fill = FieldFill.INSERT) + // 存储医生记录的创建时间,用于记录数据的创建时间戳 private Date createTime; - /** - * 设置:主键 - */ + * 设置:主键 + */ + // 获取主键值的方法 public Integer getId() { return id; } - /** - * 获取:主键 - */ - + * 获取:主键 + */ + // 设置主键值的方法 public void setId(Integer id) { this.id = id; } + /** - * 设置:医生工号 - */ + * 设置:医生工号 + */ + // 获取医生工号值的方法 public String getYishengUuidNumber() { return yishengUuidNumber; } - /** - * 获取:医生工号 - */ - + * 获取:医生工号 + */ + // 设置医生工号值的方法 public void setYishengUuidNumber(String yishengUuidNumber) { this.yishengUuidNumber = yishengUuidNumber; } + /** - * 设置:账户 - */ + * 设置:账户 + */ + // 获取账户名值的方法 public String getUsername() { return username; } - /** - * 获取:账户 - */ - + * 获取:账户 + */ + // 设置账户名值的方法 public void setUsername(String username) { this.username = username; } + /** - * 设置:密码 - */ + * 设置:密码 + */ + // 获取密码值的方法 public String getPassword() { return password; } - /** - * 获取:密码 - */ - + * 获取:密码 + */ + // 设置密码值的方法 public void setPassword(String password) { this.password = password; } + /** - * 设置:医生名称 - */ + * 设置:医生名称 + */ + // 获取医生名称值的方法 public String getYishengName() { return yishengName; } - /** - * 获取:医生名称 - */ - + * 获取:医生名称 + */ + // 设置医生名称值的方法 public void setYishengName(String yishengName) { this.yishengName = yishengName; } + /** - * 设置:科室 - */ + * 设置:科室 + */ + // 获取科室值的方法 public Integer getYishengTypes() { return yishengTypes; } - /** - * 获取:科室 - */ - + * 获取:科室 + */ + // 设置科室值的方法 public void setYishengTypes(Integer yishengTypes) { this.yishengTypes = yishengTypes; } + /** - * 设置:职位 - */ + * 设置:职位 + */ + // 获取职位值的方法 public Integer getZhiweiTypes() { return zhiweiTypes; } - /** - * 获取:职位 - */ - + * 获取:职位 + */ + // 设置职位值的方法 public void setZhiweiTypes(Integer zhiweiTypes) { this.zhiweiTypes = zhiweiTypes; } + /** - * 设置:职称 - */ + * 设置:职称 + */ + // 获取职称值的方法 public String getYishengZhichneg() { return yishengZhichneg; } - /** - * 获取:职称 - */ - + * 获取:职称 + */ + // 设置职称值的方法 public void setYishengZhichneg(String yishengZhichneg) { this.yishengZhichneg = yishengZhichneg; } + /** - * 设置:医生头像 - */ + * 设置:医生头像 + */ + // 获取医生头像路径值的方法 public String getYishengPhoto() { return yishengPhoto; } - /** - * 获取:医生头像 - */ - + * 获取:医生头像 + */ + // 设置医生头像路径值的方法 public void setYishengPhoto(String yishengPhoto) { this.yishengPhoto = yishengPhoto; } + /** - * 设置:联系方式 - */ + * 设置:联系方式 + */ + // 获取联系方式值的方法 public String getYishengPhone() { return yishengPhone; } - /** - * 获取:联系方式 - */ - + * 获取:联系方式 + */ + // 设置联系方式值的方法 public void setYishengPhone(String yishengPhone) { this.yishengPhone = yishengPhone; } + /** - * 设置:挂号须知 - */ + * 设置:挂号须知 + */ + // 获取挂号须知值的方法 public String getYishengGuahao() { return yishengGuahao; } - /** - * 获取:挂号须知 - */ - + * 获取:挂号须知 + */ + // 设置挂号须知值的方法 public void setYishengGuahao(String yishengGuahao) { this.yishengGuahao = yishengGuahao; } + /** - * 设置:邮箱 - */ + * 设置:邮箱 + */ + // 获取邮箱值的方法 public String getYishengEmail() { return yishengEmail; } - /** - * 获取:邮箱 - */ - + * 获取:邮箱 + */ + // 设置邮箱值的方法 public void setYishengEmail(String yishengEmail) { this.yishengEmail = yishengEmail; } + /** - * 设置:挂号价格 - */ + * 设置:挂号价格 + */ + // 获取挂号价格值的方法 public Double getYishengNewMoney() { return yishengNewMoney; } - /** - * 获取:挂号价格 - */ - + * 获取:挂号价格 + */ + // 设置挂号价格值的方法 public void setYishengNewMoney(Double yishengNewMoney) { this.yishengNewMoney = yishengNewMoney; } + /** - * 设置:履历介绍 - */ + * 设置:履历介绍 + */ + // 获取履历介绍值的方法 public String getYishengContent() { return yishengContent; } - /** - * 获取:履历介绍 - */ - + * 获取:履历介绍 + */ + // 设置履历介绍值的方法 public void setYishengContent(String yishengContent) { this.yishengContent = yishengContent; } + /** - * 设置:创建时间 - */ + * 设置:创建时间 + */ + // 获取创建时间值的方法 public Date getCreateTime() { return createTime; } - /** - * 获取:创建时间 - */ - + * 获取:创建时间 + */ + // 设置创建时间值的方法 public void setCreateTime(Date createTime) { this.createTime = createTime; } + // 重写 toString 方法,返回对象的字符串表示,方便调试和日志记录 @Override public String toString() { return "Yisheng{" + - "id=" + id + - ", yishengUuidNumber=" + yishengUuidNumber + - ", username=" + username + - ", password=" + password + - ", yishengName=" + yishengName + - ", yishengTypes=" + yishengTypes + - ", zhiweiTypes=" + zhiweiTypes + - ", yishengZhichneg=" + yishengZhichneg + - ", yishengPhoto=" + yishengPhoto + - ", yishengPhone=" + yishengPhone + - ", yishengGuahao=" + yishengGuahao + - ", yishengEmail=" + yishengEmail + - ", yishengNewMoney=" + yishengNewMoney + - ", yishengContent=" + yishengContent + - ", createTime=" + createTime + - "}"; - } -} + "id=" + id + + ", yishengUuidNumber=" + yishengUuidNumber + + ", username=" + username + + ", password=" + password + + ", yishengName=" + yishengName + + ", yishengTypes=" + yishengTypes + + ", zhiweiTypes=" + zhiweiTypes + + ", yishengZhichneg=" + yishengZhichneg + + ", yishengPhoto=" + yishengPhoto + + ", yishengPhone=" + yishengPhone + + ", yishengGuahao=" + yishengGuahao + + ", yishengEmail=" + yishengEmail + + ", yishengNewMoney=" + yishengNewMoney + + ", yishengContent=" + yishengContent + + ", createTime=" + createTime + + "}"; + } +} \ No newline at end of file diff --git a/src/main/java/com/entity/YonghuEntity.java b/src/main/java/com/entity/YonghuEntity.java index 178b360..351390e 100644 --- a/src/main/java/com/entity/YonghuEntity.java +++ b/src/main/java/com/entity/YonghuEntity.java @@ -1,345 +1,375 @@ package com.entity; +// 导入 MyBatis-Plus 用于指定主键的注解 import com.baomidou.mybatisplus.annotations.TableId; +// 导入 MyBatis-Plus 用于指定数据库表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入 JSR 303 验证注解,用于字段验证,当前代码未实际使用这些注解 import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; - +// 导入 Jackson 注解,用于忽略 JSON 序列化和反序列化时的某些属性,当前代码未实际使用 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +// 导入反射调用可能抛出的异常类 import java.lang.reflect.InvocationTargetException; - +// 导入序列化接口,使该类的对象可以进行序列化和反序列化操作 import java.io.Serializable; +// 导入日期类,用于处理日期相关的操作 import java.util.Date; +// 导入列表集合类,当前代码未使用 import java.util.List; - +// 导入 Spring 框架用于日期格式化的注解,用于将字符串日期转换为 Date 对象 import org.springframework.format.annotation.DateTimeFormat; +// 导入 Jackson 用于 JSON 序列化时日期格式化的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入 Apache Commons BeanUtils 工具类,用于对象属性复制 import org.apache.commons.beanutils.BeanUtils; +// 导入 MyBatis-Plus 用于指定字段的注解 import com.baomidou.mybatisplus.annotations.TableField; +// 导入 MyBatis-Plus 字段填充策略枚举 import com.baomidou.mybatisplus.enums.FieldFill; +// 导入 MyBatis-Plus 主键生成策略枚举 import com.baomidou.mybatisplus.enums.IdType; /** * 用户 * - * @author + * @author * @email */ +// 指定该类对应数据库中的 yonghu 表 @TableName("yonghu") +// 定义泛型类,实现 Serializable 接口 public class YonghuEntity implements Serializable { + // 序列化版本号,确保序列化和反序列化的兼容性 private static final long serialVersionUID = 1L; + // 无参构造函数,方便创建 YonghuEntity 类的实例 + public YonghuEntity() { - public YonghuEntity() { - - } - - public YonghuEntity(T t) { - try { - BeanUtils.copyProperties(this, t); - } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } + } + // 带参构造函数,接收一个泛型对象 t,将其属性复制到当前 YonghuEntity 对象 + public YonghuEntity(T t) { + try { + // 使用 BeanUtils 工具类复制属性 + BeanUtils.copyProperties(this, t); + } catch (IllegalAccessException | InvocationTargetException e) { + // 若复制属性过程中出现异常,打印异常堆栈信息 + e.printStackTrace(); + } + } /** * 主键 */ + // 指定该字段为主键,且主键生成策略为自增 @TableId(type = IdType.AUTO) + // 指定该字段对应数据库表中的 id 字段 @TableField(value = "id") - + // 主键,用于唯一标识一条用户记录 private Integer id; - /** * 账户 */ + // 指定该字段对应数据库表中的 username 字段 @TableField(value = "username") - + // 用户的登录账户名 private String username; - /** * 密码 */ + // 指定该字段对应数据库表中的 password 字段 @TableField(value = "password") - + // 用户登录账户的密码 private String password; - /** * 用户姓名 */ + // 指定该字段对应数据库表中的 yonghu_name 字段 @TableField(value = "yonghu_name") - + // 用户的真实姓名 private String yonghuName; - /** * 头像 */ + // 指定该字段对应数据库表中的 yonghu_photo 字段 @TableField(value = "yonghu_photo") - + // 用户头像的存储路径 private String yonghuPhoto; - /** * 用户手机号 */ + // 指定该字段对应数据库表中的 yonghu_phone 字段 @TableField(value = "yonghu_phone") - + // 用户的手机号码 private String yonghuPhone; - /** * 用户身份证号 */ + // 指定该字段对应数据库表中的 yonghu_id_number 字段 @TableField(value = "yonghu_id_number") - + // 用户的身份证号码 private String yonghuIdNumber; - /** * 邮箱 */ + // 指定该字段对应数据库表中的 yonghu_email 字段 @TableField(value = "yonghu_email") - + // 用户的电子邮箱地址 private String yonghuEmail; - /** * 性别 */ + // 指定该字段对应数据库表中的 sex_types 字段 @TableField(value = "sex_types") - + // 用户的性别,用整数表示不同性别,如 1 表示男性,2 表示女性等 private Integer sexTypes; - /** * 余额 */ + // 指定该字段对应数据库表中的 new_money 字段 @TableField(value = "new_money") - + // 用户账户的余额 private Double newMoney; - /** * 假删 */ + // 指定该字段对应数据库表中的 yonghu_delete 字段 @TableField(value = "yonghu_delete") - + // 假删除标记,用整数表示是否删除,如 0 表示未删除,1 表示已删除 private Integer yonghuDelete; - /** * 创建时间 */ - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat - @TableField(value = "create_time",fill = FieldFill.INSERT) - + // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象 + @DateTimeFormat + // 指定该字段对应数据库表中的 create_time 字段,且在插入数据时自动填充 + @TableField(value = "create_time", fill = FieldFill.INSERT) + // 该条用户记录的创建时间 private Date createTime; - /** - * 设置:主键 - */ + * 设置:主键 + */ + // 获取主键的方法 public Integer getId() { return id; } - /** - * 获取:主键 - */ - + * 获取:主键 + */ + // 设置主键的方法 public void setId(Integer id) { this.id = id; } + /** - * 设置:账户 - */ + * 设置:账户 + */ + // 获取账户名的方法 public String getUsername() { return username; } - /** - * 获取:账户 - */ - + * 获取:账户 + */ + // 设置账户名的方法 public void setUsername(String username) { this.username = username; } + /** - * 设置:密码 - */ + * 设置:密码 + */ + // 获取密码的方法 public String getPassword() { return password; } - /** - * 获取:密码 - */ - + * 获取:密码 + */ + // 设置密码的方法 public void setPassword(String password) { this.password = password; } + /** - * 设置:用户姓名 - */ + * 设置:用户姓名 + */ + // 获取用户姓名的方法 public String getYonghuName() { return yonghuName; } - /** - * 获取:用户姓名 - */ - + * 获取:用户姓名 + */ + // 设置用户姓名的方法 public void setYonghuName(String yonghuName) { this.yonghuName = yonghuName; } + /** - * 设置:头像 - */ + * 设置:头像 + */ + // 获取头像路径的方法 public String getYonghuPhoto() { return yonghuPhoto; } - /** - * 获取:头像 - */ - + * 获取:头像 + */ + // 设置头像路径的方法 public void setYonghuPhoto(String yonghuPhoto) { this.yonghuPhoto = yonghuPhoto; } + /** - * 设置:用户手机号 - */ + * 设置:用户手机号 + */ + // 获取用户手机号码的方法 public String getYonghuPhone() { return yonghuPhone; } - /** - * 获取:用户手机号 - */ - + * 获取:用户手机号 + */ + // 设置用户手机号码的方法 public void setYonghuPhone(String yonghuPhone) { this.yonghuPhone = yonghuPhone; } + /** - * 设置:用户身份证号 - */ + * 设置:用户身份证号 + */ + // 获取用户身份证号码的方法 public String getYonghuIdNumber() { return yonghuIdNumber; } - /** - * 获取:用户身份证号 - */ - + * 获取:用户身份证号 + */ + // 设置用户身份证号码的方法 public void setYonghuIdNumber(String yonghuIdNumber) { this.yonghuIdNumber = yonghuIdNumber; } + /** - * 设置:邮箱 - */ + * 设置:邮箱 + */ + // 获取邮箱地址的方法 public String getYonghuEmail() { return yonghuEmail; } - /** - * 获取:邮箱 - */ - + * 获取:邮箱 + */ + // 设置邮箱地址的方法 public void setYonghuEmail(String yonghuEmail) { this.yonghuEmail = yonghuEmail; } + /** - * 设置:性别 - */ + * 设置:性别 + */ + // 获取性别标识的方法 public Integer getSexTypes() { return sexTypes; } - /** - * 获取:性别 - */ - + * 获取:性别 + */ + // 设置性别标识的方法 public void setSexTypes(Integer sexTypes) { this.sexTypes = sexTypes; } + /** - * 设置:余额 - */ + * 设置:余额 + */ + // 获取余额的方法 public Double getNewMoney() { return newMoney; } - /** - * 获取:余额 - */ - + * 获取:余额 + */ + // 设置余额的方法 public void setNewMoney(Double newMoney) { this.newMoney = newMoney; } + /** - * 设置:假删 - */ + * 设置:假删 + */ + // 获取假删除标记的方法 public Integer getYonghuDelete() { return yonghuDelete; } - /** - * 获取:假删 - */ - + * 获取:假删 + */ + // 设置假删除标记的方法 public void setYonghuDelete(Integer yonghuDelete) { this.yonghuDelete = yonghuDelete; } + /** - * 设置:创建时间 - */ + * 设置:创建时间 + */ + // 获取创建时间的方法 public Date getCreateTime() { return createTime; } - /** - * 获取:创建时间 - */ - + * 获取:创建时间 + */ + // 设置创建时间的方法 public void setCreateTime(Date createTime) { this.createTime = createTime; } + // 重写 toString 方法,方便打印对象信息 @Override public String toString() { return "Yonghu{" + - "id=" + id + - ", username=" + username + - ", password=" + password + - ", yonghuName=" + yonghuName + - ", yonghuPhoto=" + yonghuPhoto + - ", yonghuPhone=" + yonghuPhone + - ", yonghuIdNumber=" + yonghuIdNumber + - ", yonghuEmail=" + yonghuEmail + - ", sexTypes=" + sexTypes + - ", newMoney=" + newMoney + - ", yonghuDelete=" + yonghuDelete + - ", createTime=" + createTime + - "}"; + "id=" + id + + ", username=" + username + + ", password=" + password + + ", yonghuName=" + yonghuName + + ", yonghuPhoto=" + yonghuPhoto + + ", yonghuPhone=" + yonghuPhone + + ", yonghuIdNumber=" + yonghuIdNumber + + ", yonghuEmail=" + yonghuEmail + + ", sexTypes=" + sexTypes + + ", newMoney=" + newMoney + + ", yonghuDelete=" + yonghuDelete + + ", createTime=" + createTime + + "}"; } -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/model/ChatModel.java b/src/main/java/com/entity/model/ChatModel.java index c37be72..d71e147 100644 --- a/src/main/java/com/entity/model/ChatModel.java +++ b/src/main/java/com/entity/model/ChatModel.java @@ -8,7 +8,6 @@ import java.util.Date; import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; - /** * 在线咨询 * 接收传参的实体类 @@ -16,196 +15,216 @@ import java.io.Serializable; * 取自ModelAndView 的model名称 */ public class ChatModel implements Serializable { + // 序列化版本号,用于保证序列化和反序列化的兼容性 private static final long serialVersionUID = 1L; - - - /** * 主键 */ + // 用于唯一标识一条在线咨询记录的主键 private Integer id; - /** * 提问用户 */ + // 发起咨询问题的用户的ID private Integer yonghuId; - /** * 问题 */ + // 用户提出的咨询问题内容 private String chatIssue; - /** * 问题时间 */ + // 设置JSON序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + // 用于Spring MVC接收表单数据时将日期字符串转换为Date对象 + @DateTimeFormat + // 用户提出问题的具体时间 private Date issueTime; - /** * 回复 */ + // 针对用户咨询问题给出的回复内容 private String chatReply; - /** * 回复时间 */ + // 设置JSON序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + // 用于Spring MVC接收表单数据时将日期字符串转换为Date对象 + @DateTimeFormat + // 给出回复的具体时间 private Date replyTime; - /** * 状态 */ + // 表示该在线咨询记录的状态,使用整数类型表示不同状态 private Integer zhuangtaiTypes; - /** * 数据类型 */ + // 表示该在线咨询记录的数据类型,使用整数类型表示不同类型 private Integer chatTypes; - /** * 创建时间 */ + // 设置JSON序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + // 用于Spring MVC接收表单数据时将日期字符串转换为Date对象 + @DateTimeFormat + // 该在线咨询记录的创建时间 private Date insertTime; - /** - * 获取:主键 - */ + * 获取:主键 + */ + // 获取主键ID的方法 public Integer getId() { return id; } - /** - * 设置:主键 - */ + * 设置:主键 + */ + // 设置主键ID的方法 public void setId(Integer id) { this.id = id; } + /** - * 获取:提问用户 - */ + * 获取:提问用户 + */ + // 获取提问用户ID的方法 public Integer getYonghuId() { return yonghuId; } - /** - * 设置:提问用户 - */ + * 设置:提问用户 + */ + // 设置提问用户ID的方法 public void setYonghuId(Integer yonghuId) { this.yonghuId = yonghuId; } + /** - * 获取:问题 - */ + * 获取:问题 + */ + // 获取咨询问题内容的方法 public String getChatIssue() { return chatIssue; } - /** - * 设置:问题 - */ + * 设置:问题 + */ + // 设置咨询问题内容的方法 public void setChatIssue(String chatIssue) { this.chatIssue = chatIssue; } + /** - * 获取:问题时间 - */ + * 获取:问题时间 + */ + // 获取用户提出问题时间的方法 public Date getIssueTime() { return issueTime; } - /** - * 设置:问题时间 - */ + * 设置:问题时间 + */ + // 设置用户提出问题时间的方法 public void setIssueTime(Date issueTime) { this.issueTime = issueTime; } + /** - * 获取:回复 - */ + * 获取:回复 + */ + // 获取咨询问题回复内容的方法 public String getChatReply() { return chatReply; } - /** - * 设置:回复 - */ + * 设置:回复 + */ + // 设置咨询问题回复内容的方法 public void setChatReply(String chatReply) { this.chatReply = chatReply; } + /** - * 获取:回复时间 - */ + * 获取:回复时间 + */ + // 获取给出回复时间的方法 public Date getReplyTime() { return replyTime; } - /** - * 设置:回复时间 - */ + * 设置:回复时间 + */ + // 设置给出回复时间的方法 public void setReplyTime(Date replyTime) { this.replyTime = replyTime; } + /** - * 获取:状态 - */ + * 获取:状态 + */ + // 获取咨询记录状态的方法 public Integer getZhuangtaiTypes() { return zhuangtaiTypes; } - /** - * 设置:状态 - */ + * 设置:状态 + */ + // 设置咨询记录状态的方法 public void setZhuangtaiTypes(Integer zhuangtaiTypes) { this.zhuangtaiTypes = zhuangtaiTypes; } + /** - * 获取:数据类型 - */ + * 获取:数据类型 + */ + // 获取咨询记录数据类型的方法 public Integer getChatTypes() { return chatTypes; } - /** - * 设置:数据类型 - */ + * 设置:数据类型 + */ + // 设置咨询记录数据类型的方法 public void setChatTypes(Integer chatTypes) { this.chatTypes = chatTypes; } + /** - * 获取:创建时间 - */ + * 获取:创建时间 + */ + // 获取咨询记录创建时间的方法 public Date getInsertTime() { return insertTime; } - /** - * 设置:创建时间 - */ + * 设置:创建时间 + */ + // 设置咨询记录创建时间的方法 public void setInsertTime(Date insertTime) { this.insertTime = insertTime; } - - } +} \ No newline at end of file diff --git a/src/main/java/com/entity/model/DictionaryModel.java b/src/main/java/com/entity/model/DictionaryModel.java index 36483ac..4846868 100644 --- a/src/main/java/com/entity/model/DictionaryModel.java +++ b/src/main/java/com/entity/model/DictionaryModel.java @@ -1,187 +1,206 @@ package com.entity.model; +// 引入字典表实体类,可能用于与数据库实体交互或类型转换等操作 import com.entity.DictionaryEntity; +// 该注解用于指定实体类对应的数据库表名,不过在当前代码中未实际使用该功能 import com.baomidou.mybatisplus.annotations.TableName; +// 用于在将对象序列化为JSON时,对日期类型的字段进行格式化处理 import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; +// 用于在Spring MVC中,将前端传递的日期字符串绑定到Java对象的日期字段时进行格式化 import org.springframework.format.annotation.DateTimeFormat; +// 实现该接口意味着这个类的对象可以被序列化和反序列化,方便在网络传输或存储时使用 import java.io.Serializable; - /** * 字典表 * 接收传参的实体类 *(实际开发中配合移动端接口开发手动去掉些没用的字段, 后端一般用entity就够用了) * 取自ModelAndView 的model名称 */ +// 定义一个名为DictionaryModel的类,实现Serializable接口,用于接收字典表相关的参数 public class DictionaryModel implements Serializable { + // 序列化版本号,用于在反序列化时验证版本一致性,避免不同版本类之间反序列化出错 private static final long serialVersionUID = 1L; - - - /** * 主键 */ + // 用于唯一标识字典表中的每一条记录,在数据库操作中常作为主键使用 private Integer id; - /** * 字段 */ + // 表示字典表中的某个字段,可能用于存储特定的数据标识 private String dicCode; - /** * 字段名 */ + // 该字段的名称,用于更直观地描述dicCode所代表的含义 private String dicName; - /** * 编码 */ + // 可能是对该字段的一种编码表示,方便数据的分类和查询 private Integer codeIndex; - /** * 编码名字 */ + // 编码对应的名称,用于更清晰地展示编码的具体含义 private String indexName; - /** * 父字段id */ + // 用于关联父字段,可能用于构建字典表的层级结构 private Integer superId; - /** * 备注 */ + // 对该条字典记录的额外说明信息,可用于记录一些特殊情况或备注 private String beizhu; - /** * 创建时间 */ + // 对日期进行JSON序列化时,指定日期的格式、语言环境和时区 @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + // 用于在Spring MVC中,将前端传递的日期字符串转换为Date类型时指定格式 + @DateTimeFormat + // 记录该条字典记录的创建时间 private Date createTime; - /** - * 获取:主键 - */ + * 获取:主键 + */ + // 定义一个公共的获取主键的方法,供外部调用获取id的值 public Integer getId() { return id; } - /** - * 设置:主键 - */ + * 设置:主键 + */ + // 定义一个公共的设置主键的方法,供外部调用设置id的值 public void setId(Integer id) { this.id = id; } + /** - * 获取:字段 - */ + * 获取:字段 + */ + // 定义一个公共的获取字段标识的方法,供外部调用获取dicCode的值 public String getDicCode() { return dicCode; } - /** - * 设置:字段 - */ + * 设置:字段 + */ + // 定义一个公共的设置字段标识的方法,供外部调用设置dicCode的值 public void setDicCode(String dicCode) { this.dicCode = dicCode; } + /** - * 获取:字段名 - */ + * 获取:字段名 + */ + // 定义一个公共的获取字段名称的方法,供外部调用获取dicName的值 public String getDicName() { return dicName; } - /** - * 设置:字段名 - */ + * 设置:字段名 + */ + // 定义一个公共的设置字段名称的方法,供外部调用设置dicName的值 public void setDicName(String dicName) { this.dicName = dicName; } + /** - * 获取:编码 - */ + * 获取:编码 + */ + // 定义一个公共的获取编码的方法,供外部调用获取codeIndex的值 public Integer getCodeIndex() { return codeIndex; } - /** - * 设置:编码 - */ + * 设置:编码 + */ + // 定义一个公共的设置编码的方法,供外部调用设置codeIndex的值 public void setCodeIndex(Integer codeIndex) { this.codeIndex = codeIndex; } + /** - * 获取:编码名字 - */ + * 获取:编码名字 + */ + // 定义一个公共的获取编码名称的方法,供外部调用获取indexName的值 public String getIndexName() { return indexName; } - /** - * 设置:编码名字 - */ + * 设置:编码名字 + */ + // 定义一个公共的设置编码名称的方法,供外部调用设置indexName的值 public void setIndexName(String indexName) { this.indexName = indexName; } + /** - * 获取:父字段id - */ + * 获取:父字段id + */ + // 定义一个公共的获取父字段ID的方法,供外部调用获取superId的值 public Integer getSuperId() { return superId; } - /** - * 设置:父字段id - */ + * 设置:父字段id + */ + // 定义一个公共的设置父字段ID的方法,供外部调用设置superId的值 public void setSuperId(Integer superId) { this.superId = superId; } + /** - * 获取:备注 - */ + * 获取:备注 + */ + // 定义一个公共的获取备注信息的方法,供外部调用获取beizhu的值 public String getBeizhu() { return beizhu; } - /** - * 设置:备注 - */ + * 设置:备注 + */ + // 定义一个公共的设置备注信息的方法,供外部调用设置beizhu的值 public void setBeizhu(String beizhu) { this.beizhu = beizhu; } + /** - * 获取:创建时间 - */ + * 获取:创建时间 + */ + // 定义一个公共的获取创建时间的方法,供外部调用获取createTime的值 public Date getCreateTime() { return createTime; } - /** - * 设置:创建时间 - */ + * 设置:创建时间 + */ + // 定义一个公共的设置创建时间的方法,供外部调用设置createTime的值 public void setCreateTime(Date createTime) { this.createTime = createTime; } - - } +} \ No newline at end of file diff --git a/src/main/java/com/entity/model/GuahaoModel.java b/src/main/java/com/entity/model/GuahaoModel.java index 52938cd..198f3a1 100644 --- a/src/main/java/com/entity/model/GuahaoModel.java +++ b/src/main/java/com/entity/model/GuahaoModel.java @@ -1,229 +1,253 @@ package com.entity.model; +// 导入GuahaoEntity类,可能用于实体之间的转换或关联操作 import com.entity.GuahaoEntity; +// 导入MyBatis-Plus的TableName注解,这里可能用于指定数据库表名(但代码中未实际使用) import com.baomidou.mybatisplus.annotations.TableName; +// 导入Jackson的JsonFormat注解,用于在JSON序列化和反序列化时格式化日期类型字段 import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; +// 导入Spring的DateTimeFormat注解,用于在处理表单数据时格式化日期类型字段 import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; - /** * 挂号 * 接收传参的实体类 *(实际开发中配合移动端接口开发手动去掉些没用的字段, 后端一般用entity就够用了) * 取自ModelAndView 的model名称 */ +// 定义一个名为GuahaoModel的类,实现Serializable接口,使其对象可序列化 public class GuahaoModel implements Serializable { + // 定义序列化版本号,确保在不同版本的类之间进行序列化和反序列化时的兼容性 private static final long serialVersionUID = 1L; - - - /** * 主键 */ + // 用于唯一标识挂号记录的主键,在数据库操作中通常作为唯一标识 private Integer id; - /** * 医生 */ + // 表示进行挂号的医生的ID,用于关联医生信息 private Integer yishengId; - /** * 用户 */ + // 表示进行挂号的用户的ID,用于关联用户信息 private Integer yonghuId; - /** * 就诊识别码 */ + // 可能是用于识别就诊记录的唯一编码,具体用途可能根据业务需求而定 private Integer guahaoUuinNumber; - /** * 挂号时间 */ + // 设置JSON序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + // 用于Spring MVC接收表单数据时将日期字符串转换为Date对象 + @DateTimeFormat + // 记录挂号操作的具体时间 private Date guahaoTime; - /** * 时间类型 */ + // 可能用于区分不同类型的挂号时间,例如预约时间、实际挂号时间等 private Integer guahaoTypes; - /** * 挂号状态 */ + // 用于表示挂号的当前状态,例如已挂号、已取消、已就诊等 private Integer guahaoStatusTypes; - /** * 挂号审核 */ + // 用于表示挂号是否经过审核,可能是0(未审核)、1(审核通过)、2(审核不通过)等 private Integer guahaoYesnoTypes; - /** * 审核结果 */ + // 当挂号经过审核后,记录审核的具体结果信息,例如审核不通过的原因等 private String guahaoYesnoText; - /** * 创建时间 */ + // 设置JSON序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + // 用于Spring MVC接收表单数据时将日期字符串转换为Date对象 + @DateTimeFormat + // 记录该挂号记录的创建时间 private Date createTime; - /** - * 获取:主键 - */ + * 获取:主键 + */ + // 获取主键ID的方法,供外部调用以获取该挂号记录的唯一标识 public Integer getId() { return id; } - /** - * 设置:主键 - */ + * 设置:主键 + */ + // 设置主键ID的方法,供外部调用以设置该挂号记录的唯一标识 public void setId(Integer id) { this.id = id; } + /** - * 获取:医生 - */ + * 获取:医生 + */ + // 获取进行挂号的医生ID的方法,供外部调用以获取医生的标识 public Integer getYishengId() { return yishengId; } - /** - * 设置:医生 - */ + * 设置:医生 + */ + // 设置进行挂号的医生ID的方法,供外部调用以设置医生的标识 public void setYishengId(Integer yishengId) { this.yishengId = yishengId; } + /** - * 获取:用户 - */ + * 获取:用户 + */ + // 获取进行挂号的用户ID的方法,供外部调用以获取用户的标识 public Integer getYonghuId() { return yonghuId; } - /** - * 设置:用户 - */ + * 设置:用户 + */ + // 设置进行挂号的用户ID的方法,供外部调用以设置用户的标识 public void setYonghuId(Integer yonghuId) { this.yonghuId = yonghuId; } + /** - * 获取:就诊识别码 - */ + * 获取:就诊识别码 + */ + // 获取就诊识别码的方法,供外部调用以获取该挂号记录的识别编码 public Integer getGuahaoUuinNumber() { return guahaoUuinNumber; } - /** - * 设置:就诊识别码 - */ + * 设置:就诊识别码 + */ + // 设置就诊识别码的方法,供外部调用以设置该挂号记录的识别编码 public void setGuahaoUuinNumber(Integer guahaoUuinNumber) { this.guahaoUuinNumber = guahaoUuinNumber; } + /** - * 获取:挂号时间 - */ + * 获取:挂号时间 + */ + // 获取挂号时间的方法,供外部调用以获取挂号操作的具体时间 public Date getGuahaoTime() { return guahaoTime; } - /** - * 设置:挂号时间 - */ + * 设置:挂号时间 + */ + // 设置挂号时间的方法,供外部调用以设置挂号操作的具体时间 public void setGuahaoTime(Date guahaoTime) { this.guahaoTime = guahaoTime; } + /** - * 获取:时间类型 - */ + * 获取:时间类型 + */ + // 获取时间类型的方法,供外部调用以获取该挂号记录的时间类型 public Integer getGuahaoTypes() { return guahaoTypes; } - /** - * 设置:时间类型 - */ + * 设置:时间类型 + */ + // 设置时间类型的方法,供外部调用以设置该挂号记录的时间类型 public void setGuahaoTypes(Integer guahaoTypes) { this.guahaoTypes = guahaoTypes; } + /** - * 获取:挂号状态 - */ + * 获取:挂号状态 + */ + // 获取挂号状态的方法,供外部调用以获取该挂号记录的当前状态 public Integer getGuahaoStatusTypes() { return guahaoStatusTypes; } - /** - * 设置:挂号状态 - */ + * 设置:挂号状态 + */ + // 设置挂号状态的方法,供外部调用以设置该挂号记录的当前状态 public void setGuahaoStatusTypes(Integer guahaoStatusTypes) { this.guahaoStatusTypes = guahaoStatusTypes; } + /** - * 获取:挂号审核 - */ + * 获取:挂号审核 + */ + // 获取挂号审核状态的方法,供外部调用以获取该挂号记录的审核状态 public Integer getGuahaoYesnoTypes() { return guahaoYesnoTypes; } - /** - * 设置:挂号审核 - */ + * 设置:挂号审核 + */ + // 设置挂号审核状态的方法,供外部调用以设置该挂号记录的审核状态 public void setGuahaoYesnoTypes(Integer guahaoYesnoTypes) { this.guahaoYesnoTypes = guahaoYesnoTypes; } + /** - * 获取:审核结果 - */ + * 获取:审核结果 + */ + // 获取审核结果的方法,供外部调用以获取该挂号记录的审核具体结果信息 public String getGuahaoYesnoText() { return guahaoYesnoText; } - /** - * 设置:审核结果 - */ + * 设置:审核结果 + */ + // 设置审核结果的方法,供外部调用以设置该挂号记录的审核具体结果信息 public void setGuahaoYesnoText(String guahaoYesnoText) { this.guahaoYesnoText = guahaoYesnoText; } + /** - * 获取:创建时间 - */ + * 获取:创建时间 + */ + // 获取创建时间的方法,供外部调用以获取该挂号记录的创建时间 public Date getCreateTime() { return createTime; } - /** - * 设置:创建时间 - */ + * 设置:创建时间 + */ + // 设置创建时间的方法,供外部调用以设置该挂号记录的创建时间 public void setCreateTime(Date createTime) { this.createTime = createTime; } - - } +} \ No newline at end of file diff --git a/src/main/java/com/entity/model/JiankangjiaoyuModel.java b/src/main/java/com/entity/model/JiankangjiaoyuModel.java index 3c79b61..530aa3e 100644 --- a/src/main/java/com/entity/model/JiankangjiaoyuModel.java +++ b/src/main/java/com/entity/model/JiankangjiaoyuModel.java @@ -1,189 +1,209 @@ package com.entity.model; +// 导入JiankangjiaoyuEntity类,可能用于与数据库实体进行交互或数据转换等操作 import com.entity.JiankangjiaoyuEntity; +// 导入MyBatis-Plus的TableName注解,通常用于指定数据库表名(但在当前代码中未实际使用该注解) import com.baomidou.mybatisplus.annotations.TableName; +// 导入Jackson的JsonFormat注解,用于在JSON序列化和反序列化时对日期类型字段进行格式化处理 import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; +// 导入Spring的DateTimeFormat注解,用于在处理表单数据时对日期类型字段进行格式化 import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; - /** * 健康教育 * 接收传参的实体类 *(实际开发中配合移动端接口开发手动去掉些没用的字段, 后端一般用entity就够用了) * 取自ModelAndView 的model名称 */ +// 定义一个名为JiankangjiaoyuModel的类,实现Serializable接口,使该类的对象可以被序列化和反序列化 public class JiankangjiaoyuModel implements Serializable { + // 定义序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性 private static final long serialVersionUID = 1L; - - - /** * 主键 */ + // 用于唯一标识健康教育记录的主键,在数据库操作中通常作为唯一标识字段 private Integer id; - /** * 健康教育标题 */ + // 存储健康教育内容的标题,用于展示和区分不同的健康教育信息 private String jiankangjiaoyuName; - /** * 健康教育类型 */ + // 表示健康教育的具体类型,可能是如疾病预防、健康生活方式等不同分类,以整数类型存储 private Integer jiankangjiaoyuTypes; - /** * 健康教育图片 */ + // 存储健康教育相关的图片路径或标识,用于展示相关的图片内容 private String jiankangjiaoyuPhoto; - /** * 健康教育时间 */ + // 设置JSON序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + // 用于Spring MVC接收表单数据时将日期字符串转换为Date对象 + @DateTimeFormat + // 记录健康教育内容的插入时间,即该记录创建或添加到系统的时间 private Date insertTime; - /** * 健康教育详情 */ + // 存储健康教育的详细内容,如具体的健康知识、建议等文本信息 private String jiankangjiaoyuContent; - /** * 假删 */ + // 用于实现逻辑删除的字段,可能0表示未删除,1表示已删除(假删),以整数类型存储 private Integer jiankangjiaoyuDelete; - /** * 创建时间 show1 show2 nameShow */ + // 设置JSON序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + // 用于Spring MVC接收表单数据时将日期字符串转换为Date对象 + @DateTimeFormat + // 记录该健康教育记录的实际创建时间,可能与插入时间有所区别 private Date createTime; - /** - * 获取:主键 - */ + * 获取:主键 + */ + // 获取主键ID的方法,供外部调用以获取该健康教育记录的唯一标识 public Integer getId() { return id; } - /** - * 设置:主键 - */ + * 设置:主键 + */ + // 设置主键ID的方法,供外部调用以设置该健康教育记录的唯一标识 public void setId(Integer id) { this.id = id; } + /** - * 获取:健康教育标题 - */ + * 获取:健康教育标题 + */ + // 获取健康教育标题的方法,供外部调用以获取该记录的标题信息 public String getJiankangjiaoyuName() { return jiankangjiaoyuName; } - /** - * 设置:健康教育标题 - */ + * 设置:健康教育标题 + */ + // 设置健康教育标题的方法,供外部调用以修改该记录的标题信息 public void setJiankangjiaoyuName(String jiankangjiaoyuName) { this.jiankangjiaoyuName = jiankangjiaoyuName; } + /** - * 获取:健康教育类型 - */ + * 获取:健康教育类型 + */ + // 获取健康教育类型的方法,供外部调用以获取该记录的类型信息 public Integer getJiankangjiaoyuTypes() { return jiankangjiaoyuTypes; } - /** - * 设置:健康教育类型 - */ + * 设置:健康教育类型 + */ + // 设置健康教育类型的方法,供外部调用以修改该记录的类型信息 public void setJiankangjiaoyuTypes(Integer jiankangjiaoyuTypes) { this.jiankangjiaoyuTypes = jiankangjiaoyuTypes; } + /** - * 获取:健康教育图片 - */ + * 获取:健康教育图片 + */ + // 获取健康教育图片相关信息的方法,供外部调用以获取图片路径或标识 public String getJiankangjiaoyuPhoto() { return jiankangjiaoyuPhoto; } - /** - * 设置:健康教育图片 - */ + * 设置:健康教育图片 + */ + // 设置健康教育图片相关信息的方法,供外部调用以修改图片路径或标识 public void setJiankangjiaoyuPhoto(String jiankangjiaoyuPhoto) { this.jiankangjiaoyuPhoto = jiankangjiaoyuPhoto; } + /** - * 获取:健康教育时间 - */ + * 获取:健康教育时间 + */ + // 获取健康教育内容插入时间的方法,供外部调用以获取该记录的插入时间 public Date getInsertTime() { return insertTime; } - /** - * 设置:健康教育时间 - */ + * 设置:健康教育时间 + */ + // 设置健康教育内容插入时间的方法,供外部调用以修改该记录的插入时间 public void setInsertTime(Date insertTime) { this.insertTime = insertTime; } + /** - * 获取:健康教育详情 - */ + * 获取:健康教育详情 + */ + // 获取健康教育详细内容的方法,供外部调用以获取该记录的详细文本信息 public String getJiankangjiaoyuContent() { return jiankangjiaoyuContent; } - /** - * 设置:健康教育详情 - */ + * 设置:健康教育详情 + */ + // 设置健康教育详细内容的方法,供外部调用以修改该记录的详细文本信息 public void setJiankangjiaoyuContent(String jiankangjiaoyuContent) { this.jiankangjiaoyuContent = jiankangjiaoyuContent; } + /** - * 获取:假删 - */ + * 获取:假删 + */ + // 获取逻辑删除标识的方法,供外部调用以获取该记录的假删状态 public Integer getJiankangjiaoyuDelete() { return jiankangjiaoyuDelete; } - /** - * 设置:假删 - */ + * 设置:假删 + */ + // 设置逻辑删除标识的方法,供外部调用以修改该记录的假删状态 public void setJiankangjiaoyuDelete(Integer jiankangjiaoyuDelete) { this.jiankangjiaoyuDelete = jiankangjiaoyuDelete; } + /** - * 获取:创建时间 show1 show2 nameShow - */ + * 获取:创建时间 show1 show2 nameShow + */ + // 获取健康教育记录创建时间的方法,供外部调用以获取该记录的实际创建时间 public Date getCreateTime() { return createTime; } - /** - * 设置:创建时间 show1 show2 nameShow - */ + * 设置:创建时间 show1 show2 nameShow + */ + // 设置健康教育记录创建时间的方法,供外部调用以修改该记录的实际创建时间 public void setCreateTime(Date createTime) { this.createTime = createTime; } - - } +} \ No newline at end of file diff --git a/src/main/java/com/entity/model/NewsModel.java b/src/main/java/com/entity/model/NewsModel.java index 9d37e08..f683a9f 100644 --- a/src/main/java/com/entity/model/NewsModel.java +++ b/src/main/java/com/entity/model/NewsModel.java @@ -1,169 +1,188 @@ package com.entity.model; +// 导入NewsEntity类,可能用于与数据库实体交互或进行数据转换 import com.entity.NewsEntity; +// 导入MyBatis-Plus的TableName注解,通常用于指定实体类对应的数据库表名,但此代码未实际使用 import com.baomidou.mybatisplus.annotations.TableName; +// 导入Jackson的JsonFormat注解,用于在JSON序列化和反序列化时对日期类型字段进行格式化 import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; +// 导入Spring的DateTimeFormat注解,用于在处理表单数据时对日期类型字段进行格式化 import org.springframework.format.annotation.DateTimeFormat; +// 导入Serializable接口,实现该接口意味着该类的对象可以被序列化和反序列化 import java.io.Serializable; - /** * 公告信息 * 接收传参的实体类 *(实际开发中配合移动端接口开发手动去掉些没用的字段, 后端一般用entity就够用了) * 取自ModelAndView 的model名称 */ +// 定义一个名为NewsModel的类,实现Serializable接口 public class NewsModel implements Serializable { + // 序列化版本号,用于保证序列化和反序列化过程中类的兼容性 private static final long serialVersionUID = 1L; - - - /** * 主键 */ + // 用于唯一标识每条公告信息的主键 private Integer id; - /** * 公告名称 */ + // 存储公告的名称,用于在列表等地方显示公告的标题 private String newsName; - /** * 公告图片 */ + // 存储公告相关图片的路径或标识 private String newsPhoto; - /** * 公告类型 */ + // 用整数表示公告的类型,不同的数值可能代表不同的公告分类 private Integer newsTypes; - /** * 公告发布时间 */ + // 设置JSON序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + // 用于Spring MVC接收表单数据时将日期字符串转换为Date对象 + @DateTimeFormat + // 记录公告发布的具体时间 private Date insertTime; - /** * 公告详情 */ + // 存储公告的详细内容,如具体的通知信息等 private String newsContent; - /** * 创建时间 show1 show2 nameShow */ + // 设置JSON序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + // 用于Spring MVC接收表单数据时将日期字符串转换为Date对象 + @DateTimeFormat + // 记录该公告信息在系统中创建的时间 private Date createTime; - /** - * 获取:主键 - */ + * 获取:主键 + */ + // 获取主键ID的公共方法,供外部调用获取公告的唯一标识 public Integer getId() { return id; } - /** - * 设置:主键 - */ + * 设置:主键 + */ + // 设置主键ID的公共方法,供外部调用设置公告的唯一标识 public void setId(Integer id) { this.id = id; } + /** - * 获取:公告名称 - */ + * 获取:公告名称 + */ + // 获取公告名称的公共方法,供外部调用获取公告的标题 public String getNewsName() { return newsName; } - /** - * 设置:公告名称 - */ + * 设置:公告名称 + */ + // 设置公告名称的公共方法,供外部调用修改公告的标题 public void setNewsName(String newsName) { this.newsName = newsName; } + /** - * 获取:公告图片 - */ + * 获取:公告图片 + */ + // 获取公告图片路径或标识的公共方法,供外部调用获取公告的图片信息 public String getNewsPhoto() { return newsPhoto; } - /** - * 设置:公告图片 - */ + * 设置:公告图片 + */ + // 设置公告图片路径或标识的公共方法,供外部调用修改公告的图片信息 public void setNewsPhoto(String newsPhoto) { this.newsPhoto = newsPhoto; } + /** - * 获取:公告类型 - */ + * 获取:公告类型 + */ + // 获取公告类型的公共方法,供外部调用获取公告的分类信息 public Integer getNewsTypes() { return newsTypes; } - /** - * 设置:公告类型 - */ + * 设置:公告类型 + */ + // 设置公告类型的公共方法,供外部调用修改公告的分类信息 public void setNewsTypes(Integer newsTypes) { this.newsTypes = newsTypes; } + /** - * 获取:公告发布时间 - */ + * 获取:公告发布时间 + */ + // 获取公告发布时间的公共方法,供外部调用获取公告的发布时间 public Date getInsertTime() { return insertTime; } - /** - * 设置:公告发布时间 - */ + * 设置:公告发布时间 + */ + // 设置公告发布时间的公共方法,供外部调用修改公告的发布时间 public void setInsertTime(Date insertTime) { this.insertTime = insertTime; } + /** - * 获取:公告详情 - */ + * 获取:公告详情 + */ + // 获取公告详细内容的公共方法,供外部调用获取公告的具体信息 public String getNewsContent() { return newsContent; } - /** - * 设置:公告详情 - */ + * 设置:公告详情 + */ + // 设置公告详细内容的公共方法,供外部调用修改公告的具体信息 public void setNewsContent(String newsContent) { this.newsContent = newsContent; } + /** - * 获取:创建时间 show1 show2 nameShow - */ + * 获取:创建时间 show1 show2 nameShow + */ + // 获取公告创建时间的公共方法,供外部调用获取公告在系统中的创建时间 public Date getCreateTime() { return createTime; } - /** - * 设置:创建时间 show1 show2 nameShow - */ + * 设置:创建时间 show1 show2 nameShow + */ + // 设置公告创建时间的公共方法,供外部调用修改公告在系统中的创建时间 public void setCreateTime(Date createTime) { this.createTime = createTime; } - - } +} \ No newline at end of file diff --git a/src/main/java/com/entity/model/YishengModel.java b/src/main/java/com/entity/model/YishengModel.java index 9d4ea1b..c2e0a2c 100644 --- a/src/main/java/com/entity/model/YishengModel.java +++ b/src/main/java/com/entity/model/YishengModel.java @@ -1,14 +1,17 @@ package com.entity.model; +// 导入YishengEntity类,后续可能用于与该实体进行数据转换、关联查询等操作 import com.entity.YishengEntity; - +// 导入MyBatis-Plus的TableName注解,通常用于指定数据库表名,不过在当前代码中未实际使用该注解功能 import com.baomidou.mybatisplus.annotations.TableName; +// 导入Jackson的JsonFormat注解,用于在将对象序列化为JSON格式时,对日期类型的字段进行格式化处理 import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; +// 导入Spring的DateTimeFormat注解,用于在Spring MVC接收前端传递的日期数据时,对日期字符串进行格式化转换 import org.springframework.format.annotation.DateTimeFormat; +// 实现Serializable接口,使得该类的对象可以在网络传输或存储时进行序列化和反序列化操作 import java.io.Serializable; - /** * 医生 * 接收传参的实体类 @@ -16,312 +19,340 @@ import java.io.Serializable; * 取自ModelAndView 的model名称 */ public class YishengModel implements Serializable { + // 序列化版本号,用于确保在不同版本的类之间进行序列化和反序列化时的兼容性,固定值1L private static final long serialVersionUID = 1L; - - - /** * 主键 */ + // 用于唯一标识数据库中该医生记录的主键字段,在数据的增删改查操作中起关键作用 private Integer id; - /** * 医生工号 */ + // 医生在系统中的唯一工作编号,可用于内部管理和识别不同医生 private String yishengUuidNumber; - /** * 账户 */ + // 医生用于登录系统的用户名,用于身份验证和权限管理 private String username; - /** * 密码 */ + // 与账户对应的登录密码,必须与用户名匹配才能成功登录系统,注意密码安全存储 private String password; - /** * 医生名称 */ + // 医生的真实姓名或者对外展示的名称,用于标识和显示医生身份 private String yishengName; - /** * 科室 */ + // 用整数表示医生所属的科室,不同整数值对应不同的科室,方便对医生进行分类管理 private Integer yishengTypes; - /** * 职位 */ + // 用整数标识医生在医院中的职位,如主任医师、主治医师等不同职位分类,反映医生的职责和级别 private Integer zhiweiTypes; - /** * 职称 */ + // 存储医生的专业技术职称信息,如“副主任医师”等,体现医生的专业水平和能力 private String yishengZhichneg; - /** * 医生头像 */ + // 存储医生头像图片的路径或者相关标识,用于在界面上展示医生的头像,增强用户体验 private String yishengPhoto; - /** * 联系方式 */ + // 记录医生的联系电话或者其他可联系的方式,方便患者或其他人员与医生取得联系 private String yishengPhone; - /** * 挂号须知 */ + // 包含了关于该医生挂号的各种注意事项和规定等信息,为患者提供挂号指导 private String yishengGuahao; - /** * 邮箱 */ + // 医生的电子邮箱地址,可用于接收系统通知、患者咨询邮件等 private String yishengEmail; - /** * 挂号价格 */ + // 记录该医生的挂号费用金额,以Double类型存储,单位可能是元,用于收费和展示 private Double yishengNewMoney; - /** * 履历介绍 */ + // 存储医生的个人履历、教育背景、工作经历、专业技能等详细信息,帮助患者了解医生的专业能力 private String yishengContent; - /** * 创建时间 show1 show2 photoShow */ - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + // 设置JSON序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 用于Spring MVC接收前端传递的日期数据时,对日期字符串进行格式化转换 + @DateTimeFormat + // 记录该医生信息在系统中创建的具体时间,可用于审计和数据追溯等 private Date createTime; - /** - * 获取:主键 - */ + * 获取:主键 + */ + // 获取该医生记录的主键ID值,外部调用该方法可获取唯一标识该记录的ID public Integer getId() { return id; } - /** - * 设置:主键 - */ + * 设置:主键 + */ + // 设置该医生记录的主键ID值,一般在数据插入等操作时由系统或者特定逻辑来设置 public void setId(Integer id) { this.id = id; } + /** - * 获取:医生工号 - */ + * 获取:医生工号 + */ + // 获取医生的工号信息,外部可通过调用该方法获取医生的唯一工作编号 public String getYishengUuidNumber() { return yishengUuidNumber; } - /** - * 设置:医生工号 - */ + * 设置:医生工号 + */ + // 设置医生的工号信息,可用于修改或者初始化医生的工号 public void setYishengUuidNumber(String yishengUuidNumber) { this.yishengUuidNumber = yishengUuidNumber; } + /** - * 获取:账户 - */ + * 获取:账户 + */ + // 获取医生用于登录系统的账户名,外部调用可获取该医生的登录账户 public String getUsername() { return username; } - /** - * 设置:账户 - */ + * 设置:账户 + */ + // 设置医生的登录账户名,可用于修改医生的登录账户信息 public void setUsername(String username) { this.username = username; } + /** - * 获取:密码 - */ + * 获取:密码 + */ + // 获取医生的登录密码,注意在实际应用中,密码的获取和使用需要遵循安全规范 public String getPassword() { return password; } - /** - * 设置:密码 - */ + * 设置:密码 + */ + // 设置医生的登录密码,设置密码时需要考虑密码的强度和安全性要求 public void setPassword(String password) { this.password = password; } + /** - * 获取:医生名称 - */ + * 获取:医生名称 + */ + // 获取医生的姓名信息,外部调用可获取医生的真实姓名或者展示名称 public String getYishengName() { return yishengName; } - /** - * 设置:医生名称 - */ + * 设置:医生名称 + */ + // 设置医生的姓名信息,可用于修改医生的显示名称等情况 public void setYishengName(String yishengName) { this.yishengName = yishengName; } + /** - * 获取:科室 - */ + * 获取:科室 + */ + // 获取医生所属的科室编号,通过该编号可查询对应的科室信息,了解医生的专业领域 public Integer getYishengTypes() { return yishengTypes; } - /** - * 设置:科室 - */ + * 设置:科室 + */ + // 设置医生所属的科室编号,可用于调整医生的科室归属等操作 public void setYishengTypes(Integer yishengTypes) { this.yishengTypes = yishengTypes; } + /** - * 获取:职位 - */ + * 获取:职位 + */ + // 获取医生在医院中的职位编号,根据编号可确定医生的职位信息和职责范围 public Integer getZhiweiTypes() { return zhiweiTypes; } - /** - * 设置:职位 - */ + * 设置:职位 + */ + // 设置医生在医院中的职位编号,可用于更新医生的职位信息 public void setZhiweiTypes(Integer zhiweiTypes) { this.zhiweiTypes = zhiweiTypes; } + /** - * 获取:职称 - */ + * 获取:职称 + */ + // 获取医生的专业技术职称信息,外部调用可获取医生的职称描述 public String getYishengZhichneg() { return yishengZhichneg; } - /** - * 设置:职称 - */ + * 设置:职称 + */ + // 设置医生的专业技术职称信息,可用于修改医生的职称信息 public void setYishengZhichneg(String yishengZhichneg) { this.yishengZhichneg = yishengZhichneg; } + /** - * 获取:医生头像 - */ + * 获取:医生头像 + */ + // 获取医生头像的路径或者标识信息,用于在界面上加载和展示医生的头像图片 public String getYishengPhoto() { return yishengPhoto; } - /** - * 设置:医生头像 - */ + * 设置:医生头像 + */ + // 设置医生头像的路径或者标识信息,可用于更新医生的头像展示 public void setYishengPhoto(String yishengPhoto) { this.yishengPhoto = yishengPhoto; } + /** - * 获取:联系方式 - */ + * 获取:联系方式 + */ + // 获取医生的联系电话或者其他联系方式,方便与医生进行沟通和联系 public String getYishengPhone() { return yishengPhone; } - /** - * 设置:联系方式 - */ + * 设置:联系方式 + */ + // 设置医生的联系电话或者其他联系方式,可用于修改医生的联系信息 public void setYishengPhone(String yishengPhone) { this.yishengPhone = yishengPhone; } + /** - * 获取:挂号须知 - */ + * 获取:挂号须知 + */ + // 获取关于该医生挂号的注意事项和规定等信息,为患者提供挂号相关的指导 public String getYishengGuahao() { return yishengGuahao; } - /** - * 设置:挂号须知 - */ + * 设置:挂号须知 + */ + // 设置关于该医生挂号的注意事项和规定等信息,可用于更新挂号须知内容 public void setYishengGuahao(String yishengGuahao) { this.yishengGuahao = yishengGuahao; } + /** - * 获取:邮箱 - */ + * 获取:邮箱 + */ + // 获取医生的电子邮箱地址,可用于向医生发送邮件通知或者接收患者的邮件咨询 public String getYishengEmail() { return yishengEmail; } - /** - * 设置:邮箱 - */ + * 设置:邮箱 + */ + // 设置医生的电子邮箱地址,可用于修改医生的邮箱信息 public void setYishengEmail(String yishengEmail) { this.yishengEmail = yishengEmail; } + /** - * 获取:挂号价格 - */ + * 获取:挂号价格 + */ + // 获取该医生的挂号费用金额,外部调用可获取医生的挂号价格信息 public Double getYishengNewMoney() { return yishengNewMoney; } - /** - * 设置:挂号价格 - */ + * 设置:挂号价格 + */ + // 设置该医生的挂号费用金额,可用于调整医生的挂号价格 public void setYishengNewMoney(Double yishengNewMoney) { this.yishengNewMoney = yishengNewMoney; } + /** - * 获取:履历介绍 - */ + * 获取:履历介绍 + */ + // 获取医生的个人履历和专业介绍等信息,帮助了解医生的背景和专业能力 public String getYishengContent() { return yishengContent; } - /** - * 设置:履历介绍 - */ + * 设置:履历介绍 + */ + // 设置医生的个人履历和专业介绍等信息,可用于更新医生的履历内容 public void setYishengContent(String yishengContent) { this.yishengContent = yishengContent; } + /** - * 获取:创建时间 show1 show2 photoShow - */ + * 获取:创建时间 show1 show2 photoShow + */ + // 获取该医生信息记录的创建时间,可用于了解记录的生成时间,进行数据管理和分析 public Date getCreateTime() { return createTime; } - /** - * 设置:创建时间 show1 show2 photoShow - */ + * 设置:创建时间 show1 show2 photoShow + */ + // 设置该医生信息记录的创建时间,一般由系统在创建记录时自动生成,特殊情况可进行设置 public void setCreateTime(Date createTime) { this.createTime = createTime; } - - } +} \ No newline at end of file diff --git a/src/main/java/com/entity/model/YonghuModel.java b/src/main/java/com/entity/model/YonghuModel.java index 88ee48a..0d4f8ee 100644 --- a/src/main/java/com/entity/model/YonghuModel.java +++ b/src/main/java/com/entity/model/YonghuModel.java @@ -1,13 +1,20 @@ package com.entity.model; +// 导入YonghuEntity类,可能用于与数据库实体进行交互或数据转换等操作 import com.entity.YonghuEntity; +// 导入MyBatis-Plus的TableName注解,通常用于指定数据库表名(但在当前代码中未实际使用该注解) import com.baomidou.mybatisplus.annotations.TableName; + +// 导入Jackson的JsonFormat注解,用于在JSON序列化和反序列化时对日期类型字段进行格式化处理 import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; + +// 导入Spring的DateTimeFormat注解,用于在处理表单数据时对日期类型字段进行格式化 import org.springframework.format.annotation.DateTimeFormat; -import java.io.Serializable; +// 实现Serializable接口,使该类的对象可以被序列化和反序列化,便于在网络传输或存储中使用 +import java.io.Serializable; /** * 用户 @@ -16,252 +23,274 @@ import java.io.Serializable; * 取自ModelAndView 的model名称 */ public class YonghuModel implements Serializable { + // 定义序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性 private static final long serialVersionUID = 1L; - - - /** * 主键 */ + // 用于唯一标识用户记录的主键,在数据库操作中通常作为唯一标识字段 private Integer id; - /** * 账户 */ + // 用户用于登录系统的账户名,用于身份验证和权限管理 private String username; - /** * 密码 */ + // 与账户对应的登录密码,用于验证用户身份,确保账户安全 private String password; - /** * 用户姓名 */ + // 存储用户的真实姓名或显示名称,用于标识和显示用户身份 private String yonghuName; - /** * 头像 */ + // 存储用户头像图片的路径或标识,用于在系统中展示用户的头像 private String yonghuPhoto; - /** * 用户手机号 */ + // 存储用户的手机号码,可用于联系用户、验证身份等 private String yonghuPhone; - /** * 用户身份证号 */ + // 存储用户的身份证号码,用于身份验证和相关业务处理 private String yonghuIdNumber; - /** * 邮箱 */ + // 存储用户的电子邮箱地址,可用于接收系统通知、找回密码等 private String yonghuEmail; - /** * 性别 */ + // 用整数表示用户的性别,例如0表示男,1表示女等,方便进行统计和分类 private Integer sexTypes; - /** * 余额 */ + // 存储用户账户的余额,以Double类型表示金额,用于相关支付和消费操作 private Double newMoney; - /** * 假删 */ + // 用于实现逻辑删除的字段,0表示未删除,1表示已删除(假删),避免物理删除数据 private Integer yonghuDelete; - /** * 创建时间 */ - @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") - @DateTimeFormat + // 设置JSON序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss" + @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + // 用于Spring MVC接收表单数据时将日期字符串转换为Date对象 + @DateTimeFormat + // 记录该用户信息记录的实际创建时间 private Date createTime; - /** - * 获取:主键 - */ + * 获取:主键 + */ + // 获取主键ID的方法,供外部调用以获取该用户信息记录的唯一标识 public Integer getId() { return id; } - /** - * 设置:主键 - */ + * 设置:主键 + */ + // 设置主键ID的方法,供外部调用以设置该用户信息记录的唯一标识 public void setId(Integer id) { this.id = id; } + /** - * 获取:账户 - */ + * 获取:账户 + */ + // 获取用户账户名的方法,供外部调用以获取用户的登录账户信息 public String getUsername() { return username; } - /** - * 设置:账户 - */ + * 设置:账户 + */ + // 设置用户账户名的方法,供外部调用以修改用户的登录账户信息 public void setUsername(String username) { this.username = username; } + /** - * 获取:密码 - */ + * 获取:密码 + */ + // 获取用户密码的方法,实际应用中需注意密码安全,防止泄露 public String getPassword() { return password; } - /** - * 设置:密码 - */ + * 设置:密码 + */ + // 设置用户密码的方法,设置时需遵循一定的密码强度规则 public void setPassword(String password) { this.password = password; } + /** - * 获取:用户姓名 - */ + * 获取:用户姓名 + */ + // 获取用户姓名的方法,供外部调用以获取用户的名称信息 public String getYonghuName() { return yonghuName; } - /** - * 设置:用户姓名 - */ + * 设置:用户姓名 + */ + // 设置用户姓名的方法,供外部调用以修改用户的显示名称 public void setYonghuName(String yonghuName) { this.yonghuName = yonghuName; } + /** - * 获取:头像 - */ + * 获取:头像 + */ + // 获取用户头像路径或标识的方法,供外部调用以获取用户的头像信息 public String getYonghuPhoto() { return yonghuPhoto; } - /** - * 设置:头像 - */ + * 设置:头像 + */ + // 设置用户头像路径或标识的方法,供外部调用以修改用户的头像展示 public void setYonghuPhoto(String yonghuPhoto) { this.yonghuPhoto = yonghuPhoto; } + /** - * 获取:用户手机号 - */ + * 获取:用户手机号 + */ + // 获取用户手机号码的方法,供外部调用以获取用户的联系方式 public String getYonghuPhone() { return yonghuPhone; } - /** - * 设置:用户手机号 - */ + * 设置:用户手机号 + */ + // 设置用户手机号码的方法,供外部调用以修改用户的联系电话 public void setYonghuPhone(String yonghuPhone) { this.yonghuPhone = yonghuPhone; } + /** - * 获取:用户身份证号 - */ + * 获取:用户身份证号 + */ + // 获取用户身份证号码的方法,供外部调用以获取用户的身份信息 public String getYonghuIdNumber() { return yonghuIdNumber; } - /** - * 设置:用户身份证号 - */ + * 设置:用户身份证号 + */ + // 设置用户身份证号码的方法,设置时需保证号码的合法性和准确性 public void setYonghuIdNumber(String yonghuIdNumber) { this.yonghuIdNumber = yonghuIdNumber; } + /** - * 获取:邮箱 - */ + * 获取:邮箱 + */ + // 获取用户电子邮箱地址的方法,供外部调用以获取用户的邮箱信息 public String getYonghuEmail() { return yonghuEmail; } - /** - * 设置:邮箱 - */ + * 设置:邮箱 + */ + // 设置用户电子邮箱地址的方法,供外部调用以修改用户的邮箱信息 public void setYonghuEmail(String yonghuEmail) { this.yonghuEmail = yonghuEmail; } + /** - * 获取:性别 - */ + * 获取:性别 + */ + // 获取用户性别的方法,供外部调用以获取用户的性别标识 public Integer getSexTypes() { return sexTypes; } - /** - * 设置:性别 - */ + * 设置:性别 + */ + // 设置用户性别的方法,供外部调用以修改用户的性别标识 public void setSexTypes(Integer sexTypes) { this.sexTypes = sexTypes; } + /** - * 获取:余额 - */ + * 获取:余额 + */ + // 获取用户账户余额的方法,供外部调用以获取用户的账户金额信息 public Double getNewMoney() { return newMoney; } - /** - * 设置:余额 - */ + * 设置:余额 + */ + // 设置用户账户余额的方法,供外部调用以修改用户的账户金额 public void setNewMoney(Double newMoney) { this.newMoney = newMoney; } + /** - * 获取:假删 - */ + * 获取:假删 + */ + // 获取用户记录假删状态的方法,供外部调用以获取用户记录的删除标识 public Integer getYonghuDelete() { return yonghuDelete; } - /** - * 设置:假删 - */ + * 设置:假删 + */ + // 设置用户记录假删状态的方法,供外部调用以修改用户记录的删除标识 public void setYonghuDelete(Integer yonghuDelete) { this.yonghuDelete = yonghuDelete; } + /** - * 获取:创建时间 - */ + * 获取:创建时间 + */ + // 获取用户信息记录创建时间的方法,供外部调用以获取该记录的实际创建时间 public Date getCreateTime() { return createTime; } - /** - * 设置:创建时间 - */ + * 设置:创建时间 + */ + // 设置用户信息记录创建时间的方法,一般由系统自动生成,特殊情况可进行设置 public void setCreateTime(Date createTime) { this.createTime = createTime; } - - } +} \ No newline at end of file diff --git a/src/main/java/com/entity/view/ChatView.java b/src/main/java/com/entity/view/ChatView.java index a6d3eea..2f88b67 100644 --- a/src/main/java/com/entity/view/ChatView.java +++ b/src/main/java/com/entity/view/ChatView.java @@ -14,191 +14,226 @@ import java.util.Date; * 后端返回视图实体辅助类 * (通常后端关联的表或者自定义的字段需要返回使用) */ +// 使用TableName注解指定该类对应的数据库表名为 "chat" @TableName("chat") +// ChatView类继承自ChatEntity类,并实现了Serializable接口,以便对象可以被序列化和反序列化 public class ChatView extends ChatEntity implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 状态的值 - */ - private String zhuangtaiValue; - /** - * 数据类型的值 - */ - private String chatValue; - - - - //级联表 yonghu - /** - * 用户姓名 - */ - private String yonghuName; - /** - * 头像 - */ - private String yonghuPhoto; - /** - * 用户手机号 - */ - private String yonghuPhone; - /** - * 用户身份证号 - */ - private String yonghuIdNumber; - /** - * 邮箱 - */ - private String yonghuEmail; - /** - * 余额 - */ - private Double newMoney; - /** - * 假删 - */ - private Integer yonghuDelete; - + // 序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性 + private static final long serialVersionUID = 1L; + + /** + * 状态的值 + */ + // 用于存储在线咨询相关的状态值,可能表示咨询的状态(如进行中、已结束等) + private String zhuangtaiValue; + + /** + * 数据类型的值 + */ + // 用于存储在线咨询的数据类型相关的值,具体含义可能根据业务需求而定 + private String chatValue; + + // 级联表 yonghu + /** + * 用户姓名 + */ + // 存储与在线咨询相关联的用户的姓名信息 + private String yonghuName; + + /** + * 头像 + */ + // 存储与在线咨询相关联的用户的头像路径或标识 + private String yonghuPhoto; + + /** + * 用户手机号 + */ + // 存储与在线咨询相关联的用户的手机号码,用于联系用户 + private String yonghuPhone; + + /** + * 用户身份证号 + */ + // 存储与在线咨询相关联的用户的身份证号码,用于身份验证等业务 + private String yonghuIdNumber; + + /** + * 邮箱 + */ + // 存储与在线咨询相关联的用户的电子邮箱地址,可用于发送通知等 + private String yonghuEmail; + + /** + * 余额 + */ + // 存储与在线咨询相关联的用户的账户余额,可能与咨询费用等相关 + private Double newMoney; + + /** + * 假删 + */ + // 用于标识与在线咨询相关联的用户记录是否被逻辑删除(假删),0表示未删除,1表示已删除 + private Integer yonghuDelete; + + // 无参构造函数,用于创建ChatView对象 public ChatView() { } + // 构造函数,接受一个ChatEntity对象作为参数,通过BeanUtils.copyProperties方法 + // 将ChatEntity对象的属性值复制到当前ChatView对象中 public ChatView(ChatEntity chatEntity) { try { BeanUtils.copyProperties(this, chatEntity); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 如果在复制属性过程中出现异常,打印异常堆栈信息 e.printStackTrace(); } } + /** + * 获取: 状态的值 + */ + // 获取状态值的方法,外部可以通过调用该方法获取zhuangtaiValue属性的值 + public String getZhuangtaiValue() { + return zhuangtaiValue; + } + + /** + * 设置: 状态的值 + */ + // 设置状态值的方法,外部可以通过调用该方法设置zhuangtaiValue属性的值 + public void setZhuangtaiValue(String zhuangtaiValue) { + this.zhuangtaiValue = zhuangtaiValue; + } + + /** + * 获取: 数据类型的值 + */ + // 获取数据类型值的方法,外部可以通过调用该方法获取chatValue属性的值 + public String getChatValue() { + return chatValue; + } + + /** + * 设置: 数据类型的值 + */ + // 设置数据类型值的方法,外部可以通过调用该方法设置chatValue属性的值 + public void setChatValue(String chatValue) { + this.chatValue = chatValue; + } + + // 级联表的get和set yonghu + /** + * 获取: 用户姓名 + */ + // 获取用户姓名的方法,外部可以通过调用该方法获取yonghuName属性的值 + public String getYonghuName() { + return yonghuName; + } + + /** + * 设置: 用户姓名 + */ + // 设置用户姓名的方法,外部可以通过调用该方法设置yonghuName属性的值 + public void setYonghuName(String yonghuName) { + this.yonghuName = yonghuName; + } + + /** + * 获取: 头像 + */ + // 获取用户头像的方法,外部可以通过调用该方法获取yonghuPhoto属性的值 + public String getYonghuPhoto() { + return yonghuPhoto; + } + + /** + * 设置: 头像 + */ + // 设置用户头像的方法,外部可以通过调用该方法设置yonghuPhoto属性的值 + public void setYonghuPhoto(String yonghuPhoto) { + this.yonghuPhoto = yonghuPhoto; + } + + /** + * 获取: 用户手机号 + */ + // 获取用户手机号的方法,外部可以通过调用该方法获取yonghuPhone属性的值 + public String getYonghuPhone() { + return yonghuPhone; + } + /** + * 设置: 用户手机号 + */ + // 设置用户手机号的方法,外部可以通过调用该方法设置yonghuPhone属性的值 + public void setYonghuPhone(String yonghuPhone) { + this.yonghuPhone = yonghuPhone; + } - /** - * 获取: 状态的值 - */ - public String getZhuangtaiValue() { - return zhuangtaiValue; - } - /** - * 设置: 状态的值 - */ - public void setZhuangtaiValue(String zhuangtaiValue) { - this.zhuangtaiValue = zhuangtaiValue; - } - /** - * 获取: 数据类型的值 - */ - public String getChatValue() { - return chatValue; - } - /** - * 设置: 数据类型的值 - */ - public void setChatValue(String chatValue) { - this.chatValue = chatValue; - } - - - - - - - - - - - - - - - - - //级联表的get和set yonghu - /** - * 获取: 用户姓名 - */ - public String getYonghuName() { - return yonghuName; - } - /** - * 设置: 用户姓名 - */ - public void setYonghuName(String yonghuName) { - this.yonghuName = yonghuName; - } - /** - * 获取: 头像 - */ - public String getYonghuPhoto() { - return yonghuPhoto; - } - /** - * 设置: 头像 - */ - public void setYonghuPhoto(String yonghuPhoto) { - this.yonghuPhoto = yonghuPhoto; - } - /** - * 获取: 用户手机号 - */ - public String getYonghuPhone() { - return yonghuPhone; - } - /** - * 设置: 用户手机号 - */ - public void setYonghuPhone(String yonghuPhone) { - this.yonghuPhone = yonghuPhone; - } - /** - * 获取: 用户身份证号 - */ - public String getYonghuIdNumber() { - return yonghuIdNumber; - } - /** - * 设置: 用户身份证号 - */ - public void setYonghuIdNumber(String yonghuIdNumber) { - this.yonghuIdNumber = yonghuIdNumber; - } - /** - * 获取: 邮箱 - */ - public String getYonghuEmail() { - return yonghuEmail; - } - /** - * 设置: 邮箱 - */ - public void setYonghuEmail(String yonghuEmail) { - this.yonghuEmail = yonghuEmail; - } - /** - * 获取: 余额 - */ - public Double getNewMoney() { - return newMoney; - } - /** - * 设置: 余额 - */ - public void setNewMoney(Double newMoney) { - this.newMoney = newMoney; - } - /** - * 获取: 假删 - */ - public Integer getYonghuDelete() { - return yonghuDelete; - } - /** - * 设置: 假删 - */ - public void setYonghuDelete(Integer yonghuDelete) { - this.yonghuDelete = yonghuDelete; - } - - -} + /** + * 获取: 用户身份证号 + */ + // 获取用户身份证号的方法,外部可以通过调用该方法获取yonghuIdNumber属性的值 + public String getYonghuIdNumber() { + return yonghuIdNumber; + } + + /** + * 设置: 用户身份证号 + */ + // 设置用户身份证号的方法,外部可以通过调用该方法设置yonghuIdNumber属性的值 + public void setYonghuIdNumber(String yonghuIdNumber) { + this.yonghuIdNumber = yonghuIdNumber; + } + + /** + * 获取: 邮箱 + */ + // 获取用户邮箱的方法,外部可以通过调用该方法获取yonghuEmail属性的值 + public String getYonghuEmail() { + return yonghuEmail; + } + + /** + * 设置: 邮箱 + */ + // 设置用户邮箱的方法,外部可以通过调用该方法设置yonghuEmail属性的值 + public void setYonghuEmail(String yonghuEmail) { + this.yonghuEmail = yonghuEmail; + } + + /** + * 获取: 余额 + */ + // 获取用户余额的方法,外部可以通过调用该方法获取newMoney属性的值 + public Double getNewMoney() { + return newMoney; + } + + /** + * 设置: 余额 + */ + // 设置用户余额的方法,外部可以通过调用该方法设置newMoney属性的值 + public void setNewMoney(Double newMoney) { + this.newMoney = newMoney; + } + + /** + * 获取: 假删 + */ + // 获取用户假删状态的方法,外部可以通过调用该方法获取yonghuDelete属性的值 + public Integer getYonghuDelete() { + return yonghuDelete; + } + + /** + * 设置: 假删 + */ + // 设置用户假删状态的方法,外部可以通过调用该方法设置yonghuDelete属性的值 + public void setYonghuDelete(Integer yonghuDelete) { + this.yonghuDelete = yonghuDelete; + } +} \ No newline at end of file diff --git a/src/main/java/com/entity/view/DictionaryView.java b/src/main/java/com/entity/view/DictionaryView.java index 4f51785..825f709 100644 --- a/src/main/java/com/entity/view/DictionaryView.java +++ b/src/main/java/com/entity/view/DictionaryView.java @@ -14,44 +14,29 @@ import java.util.Date; * 后端返回视图实体辅助类 * (通常后端关联的表或者自定义的字段需要返回使用) */ +// 使用TableName注解指定该类对应的数据库表名为 "dictionary" @TableName("dictionary") +// DictionaryView类继承自DictionaryEntity类,并实现了Serializable接口, +// 使得该类的对象可以被序列化和反序列化,方便在网络传输或存储中使用 public class DictionaryView extends DictionaryEntity implements Serializable { - private static final long serialVersionUID = 1L; - - - + // 序列化版本号,用于确保在不同版本的类之间进行序列化和反序列化时的兼容性 + private static final long serialVersionUID = 1L; + // 无参构造函数,用于创建DictionaryView对象,在不需要初始化特定属性时使用 public DictionaryView() { } + // 构造函数,接受一个DictionaryEntity对象作为参数 + // 通过BeanUtils.copyProperties方法将DictionaryEntity对象的属性值复制到当前DictionaryView对象中 + // 这样可以方便地从Entity对象转换为View对象,减少手动赋值的工作量 public DictionaryView(DictionaryEntity dictionaryEntity) { try { BeanUtils.copyProperties(this, dictionaryEntity); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 如果在复制属性过程中发生异常(例如属性访问权限问题或反射调用目标方法失败) + // 打印异常堆栈信息,以便开发人员调试和定位问题 e.printStackTrace(); } } - - - - - - - - - - - - - - - - - - - - - -} +} \ No newline at end of file diff --git a/src/main/java/com/entity/view/GuahaoView.java b/src/main/java/com/entity/view/GuahaoView.java index d5db2b2..6549895 100644 --- a/src/main/java/com/entity/view/GuahaoView.java +++ b/src/main/java/com/entity/view/GuahaoView.java @@ -14,430 +14,499 @@ import java.util.Date; * 后端返回视图实体辅助类 * (通常后端关联的表或者自定义的字段需要返回使用) */ +// 使用TableName注解指定该类对应的数据库表名为 "guahao" @TableName("guahao") +// GuahaoView类继承自GuahaoEntity类,并实现了Serializable接口, +// 使得该类的对象可以被序列化和反序列化,便于在网络传输或存储中使用 public class GuahaoView extends GuahaoEntity implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 时间类型的值 - */ - private String guahaoValue; - /** - * 挂号状态的值 - */ - private String guahaoStatusValue; - /** - * 挂号审核的值 - */ - private String guahaoYesnoValue; - - - - //级联表 yisheng - /** - * 医生工号 - */ - private String yishengUuidNumber; - /** - * 医生名称 - */ - private String yishengName; - /** - * 科室 - */ - private Integer yishengTypes; - /** - * 科室的值 - */ - private String yishengValue; - /** - * 职位 - */ - private Integer zhiweiTypes; - /** - * 职位的值 - */ - private String zhiweiValue; - /** - * 职称 - */ - private String yishengZhichneg; - /** - * 医生头像 - */ - private String yishengPhoto; - /** - * 联系方式 - */ - private String yishengPhone; - /** - * 挂号须知 - */ - private String yishengGuahao; - /** - * 邮箱 - */ - private String yishengEmail; - /** - * 挂号价格 - */ - private Double yishengNewMoney; - /** - * 履历介绍 - */ - private String yishengContent; - - //级联表 yonghu - /** - * 用户姓名 - */ - private String yonghuName; - /** - * 头像 - */ - private String yonghuPhoto; - /** - * 用户手机号 - */ - private String yonghuPhone; - /** - * 用户身份证号 - */ - private String yonghuIdNumber; - /** - * 邮箱 - */ - private String yonghuEmail; - /** - * 余额 - */ - private Double newMoney; - /** - * 假删 - */ - private Integer yonghuDelete; - + // 序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性 + private static final long serialVersionUID = 1L; + + /** + * 时间类型的值 + */ + // 用于存储挂号相关的时间类型的值,可能表示不同的挂号时间分类等 + private String guahaoValue; + + /** + * 挂号状态的值 + */ + // 用于存储挂号状态的具体值,例如已挂号、已取消、已就诊等状态的描述 + private String guahaoStatusValue; + + /** + * 挂号审核的值 + */ + // 用于存储挂号审核结果的具体值,例如审核通过、审核不通过等描述 + private String guahaoYesnoValue; + + // 级联表 yisheng + /** + * 医生工号 + */ + // 存储与该挂号记录关联的医生的工号,用于唯一标识医生 + private String yishengUuidNumber; + + /** + * 医生名称 + */ + // 存储与该挂号记录关联的医生的姓名 + private String yishengName; + + /** + * 科室 + */ + // 用整数表示与该挂号记录关联的医生所属的科室 + private Integer yishengTypes; + + /** + * 科室的值 + */ + // 存储科室的具体描述值,可能是科室的名称等,与yishengTypes配合使用 + private String yishengValue; + + /** + * 职位 + */ + // 用整数表示与该挂号记录关联的医生的职位 + private Integer zhiweiTypes; + + /** + * 职位的值 + */ + // 存储职位的具体描述值,可能是职位的名称等,与zhiweiTypes配合使用 + private String zhiweiValue; + + /** + * 职称 + */ + // 存储与该挂号记录关联的医生的职称信息 + private String yishengZhichneg; + + /** + * 医生头像 + */ + // 存储与该挂号记录关联的医生的头像路径或标识 + private String yishengPhoto; + + /** + * 联系方式 + */ + // 存储与该挂号记录关联的医生的联系电话或其他联系方式 + private String yishengPhone; + + /** + * 挂号须知 + */ + // 存储与该医生相关的挂号注意事项和规定等信息 + private String yishengGuahao; + + /** + * 邮箱 + */ + // 存储与该挂号记录关联的医生的电子邮箱地址 + private String yishengEmail; + + /** + * 挂号价格 + */ + // 存储该医生的挂号费用金额,以Double类型表示 + private Double yishengNewMoney; + + /** + * 履历介绍 + */ + // 存储与该挂号记录关联的医生的个人履历和专业介绍等信息 + private String yishengContent; + + // 级联表 yonghu + /** + * 用户姓名 + */ + // 存储与该挂号记录关联的用户的姓名 + private String yonghuName; + + /** + * 头像 + */ + // 存储与该挂号记录关联的用户的头像路径或标识 + private String yonghuPhoto; + + /** + * 用户手机号 + */ + // 存储与该挂号记录关联的用户的手机号码,用于联系用户 + private String yonghuPhone; + + /** + * 用户身份证号 + */ + // 存储与该挂号记录关联的用户的身份证号码,用于身份验证等业务 + private String yonghuIdNumber; + + /** + * 邮箱 + */ + // 存储与该挂号记录关联的用户的电子邮箱地址,可用于发送通知等 + private String yonghuEmail; + + /** + * 余额 + */ + // 存储与该挂号记录关联的用户的账户余额,可能与挂号费用支付等相关 + private Double newMoney; + + /** + * 假删 + */ + // 用于标识与该挂号记录关联的用户记录是否被逻辑删除(假删),0表示未删除,1表示已删除 + private Integer yonghuDelete; + + // 无参构造函数,用于创建GuahaoView对象 public GuahaoView() { } + // 构造函数,接受一个GuahaoEntity对象作为参数, + // 通过BeanUtils.copyProperties方法将GuahaoEntity对象的属性值复制到当前GuahaoView对象中 public GuahaoView(GuahaoEntity guahaoEntity) { try { BeanUtils.copyProperties(this, guahaoEntity); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 如果在复制属性过程中出现异常,打印异常堆栈信息 e.printStackTrace(); } } + /** + * 获取: 时间类型的值 + */ + // 获取时间类型值的方法,外部可以通过调用该方法获取guahaoValue属性的值 + public String getGuahaoValue() { + return guahaoValue; + } + + /** + * 设置: 时间类型的值 + */ + // 设置时间类型值的方法,外部可以通过调用该方法设置guahaoValue属性的值 + public void setGuahaoValue(String guahaoValue) { + this.guahaoValue = guahaoValue; + } + + /** + * 获取: 挂号状态的值 + */ + // 获取挂号状态值的方法,外部可以通过调用该方法获取guahaoStatusValue属性的值 + public String getGuahaoStatusValue() { + return guahaoStatusValue; + } + + /** + * 设置: 挂号状态的值 + */ + // 设置挂号状态值的方法,外部可以通过调用该方法设置guahaoStatusValue属性的值 + public void setGuahaoStatusValue(String guahaoStatusValue) { + this.guahaoStatusValue = guahaoStatusValue; + } + + /** + * 获取: 挂号审核的值 + */ + // 获取挂号审核值的方法,外部可以通过调用该方法获取guahaoYesnoValue属性的值 + public String getGuahaoYesnoValue() { + return guahaoYesnoValue; + } + + /** + * 设置: 挂号审核的值 + */ + // 设置挂号审核值的方法,外部可以通过调用该方法设置guahaoYesnoValue属性的值 + public void setGuahaoYesnoValue(String guahaoYesnoValue) { + this.guahaoYesnoValue = guahaoYesnoValue; + } + + // 级联表的get和set yisheng + /** + * 获取: 医生工号 + */ + // 获取医生工号的方法,外部可以通过调用该方法获取yishengUuidNumber属性的值 + public String getYishengUuidNumber() { + return yishengUuidNumber; + } + + /** + * 设置: 医生工号 + */ + // 设置医生工号的方法,外部可以通过调用该方法设置yishengUuidNumber属性的值 + public void setYishengUuidNumber(String yishengUuidNumber) { + this.yishengUuidNumber = yishengUuidNumber; + } + + /** + * 获取: 医生名称 + */ + // 获取医生名称的方法,外部可以通过调用该方法获取yishengName属性的值 + public String getYishengName() { + return yishengName; + } + + /** + * 设置: 医生名称 + */ + // 设置医生名称的方法,外部可以通过调用该方法设置yishengName属性的值 + public void setYishengName(String yishengName) { + this.yishengName = yishengName; + } + + /** + * 获取: 科室 + */ + // 获取科室编号的方法,外部可以通过调用该方法获取yishengTypes属性的值 + public Integer getYishengTypes() { + return yishengTypes; + } + + /** + * 设置: 科室 + */ + // 设置科室编号的方法,外部可以通过调用该方法设置yishengTypes属性的值 + public void setYishengTypes(Integer yishengTypes) { + this.yishengTypes = yishengTypes; + } + + /** + * 获取: 科室的值 + */ + // 获取科室描述值的方法,外部可以通过调用该方法获取yishengValue属性的值 + public String getYishengValue() { + return yishengValue; + } + + /** + * 设置: 科室的值 + */ + // 设置科室描述值的方法,外部可以通过调用该方法设置yishengValue属性的值 + public void setYishengValue(String yishengValue) { + this.yishengValue = yishengValue; + } + + /** + * 获取: 职位 + */ + // 获取职位编号的方法,外部可以通过调用该方法获取zhiweiTypes属性的值 + public Integer getZhiweiTypes() { + return zhiweiTypes; + } + + /** + * 设置: 职位 + */ + // 设置职位编号的方法,外部可以通过调用该方法设置zhiweiTypes属性的值 + public void setZhiweiTypes(Integer zhiweiTypes) { + this.zhiweiTypes = zhiweiTypes; + } + + /** + * 获取: 职位的值 + */ + // 获取职位描述值的方法,外部可以通过调用该方法获取zhiweiValue属性的值 + public String getZhiweiValue() { + return zhiweiValue; + } + + /** + * 设置: 职位的值 + */ + // 设置职位描述值的方法,外部可以通过调用该方法设置zhiweiValue属性的值 + public void setZhiweiValue(String zhiweiValue) { + this.zhiweiValue = zhiweiValue; + } + + /** + * 获取: 职称 + */ + // 获取职称信息的方法,外部可以通过调用该方法获取yishengZhichneg属性的值 + public String getYishengZhichneg() { + return yishengZhichneg; + } + + /** + * 设置: 职称 + */ + // 设置职称信息的方法,外部可以通过调用该方法设置yishengZhichneg属性的值 + public void setYishengZhichneg(String yishengZhichneg) { + this.yishengZhichneg = yishengZhichneg; + } + + /** + * 获取: 医生头像 + */ + // 获取医生头像路径或标识的方法,外部可以通过调用该方法获取yishengPhoto属性的值 + public String getYishengPhoto() { + return yishengPhoto; + } + + /** + * 设置: 医生头像 + */ + // 设置医生头像路径或标识的方法,外部可以通过调用该方法设置yishengPhoto属性的值 + public void setYishengPhoto(String yishengPhoto) { + this.yishengPhoto = yishengPhoto; + } + /** + * 获取: 联系方式 + */ + // 获取医生联系方式的方法,外部可以通过调用该方法获取yishengPhone属性的值 + public String getYishengPhone() { + return yishengPhone; + } + + /** + * 设置: 联系方式 + */ + // 设置医生联系方式的方法,外部可以通过调用该方法设置yishengPhone属性的值 + public void setYishengPhone(String yishengPhone) { + this.yishengPhone = yishengPhone; + } - /** - * 获取: 时间类型的值 - */ - public String getGuahaoValue() { - return guahaoValue; - } - /** - * 设置: 时间类型的值 - */ - public void setGuahaoValue(String guahaoValue) { - this.guahaoValue = guahaoValue; - } - /** - * 获取: 挂号状态的值 - */ - public String getGuahaoStatusValue() { - return guahaoStatusValue; - } - /** - * 设置: 挂号状态的值 - */ - public void setGuahaoStatusValue(String guahaoStatusValue) { - this.guahaoStatusValue = guahaoStatusValue; - } - /** - * 获取: 挂号审核的值 - */ - public String getGuahaoYesnoValue() { - return guahaoYesnoValue; - } - /** - * 设置: 挂号审核的值 - */ - public void setGuahaoYesnoValue(String guahaoYesnoValue) { - this.guahaoYesnoValue = guahaoYesnoValue; - } - - - - - - - - - - - - - - - - - - - - //级联表的get和set yisheng - /** - * 获取: 医生工号 - */ - public String getYishengUuidNumber() { - return yishengUuidNumber; - } - /** - * 设置: 医生工号 - */ - public void setYishengUuidNumber(String yishengUuidNumber) { - this.yishengUuidNumber = yishengUuidNumber; - } - /** - * 获取: 医生名称 - */ - public String getYishengName() { - return yishengName; - } - /** - * 设置: 医生名称 - */ - public void setYishengName(String yishengName) { - this.yishengName = yishengName; - } - /** - * 获取: 科室 - */ - public Integer getYishengTypes() { - return yishengTypes; - } - /** - * 设置: 科室 - */ - public void setYishengTypes(Integer yishengTypes) { - this.yishengTypes = yishengTypes; - } - - - /** - * 获取: 科室的值 - */ - public String getYishengValue() { - return yishengValue; - } - /** - * 设置: 科室的值 - */ - public void setYishengValue(String yishengValue) { - this.yishengValue = yishengValue; - } - /** - * 获取: 职位 - */ - public Integer getZhiweiTypes() { - return zhiweiTypes; - } - /** - * 设置: 职位 - */ - public void setZhiweiTypes(Integer zhiweiTypes) { - this.zhiweiTypes = zhiweiTypes; - } - - - /** - * 获取: 职位的值 - */ - public String getZhiweiValue() { - return zhiweiValue; - } - /** - * 设置: 职位的值 - */ - public void setZhiweiValue(String zhiweiValue) { - this.zhiweiValue = zhiweiValue; - } - /** - * 获取: 职称 - */ - public String getYishengZhichneg() { - return yishengZhichneg; - } - /** - * 设置: 职称 - */ - public void setYishengZhichneg(String yishengZhichneg) { - this.yishengZhichneg = yishengZhichneg; - } - /** - * 获取: 医生头像 - */ - public String getYishengPhoto() { - return yishengPhoto; - } - /** - * 设置: 医生头像 - */ - public void setYishengPhoto(String yishengPhoto) { - this.yishengPhoto = yishengPhoto; - } - /** - * 获取: 联系方式 - */ - public String getYishengPhone() { - return yishengPhone; - } - /** - * 设置: 联系方式 - */ - public void setYishengPhone(String yishengPhone) { - this.yishengPhone = yishengPhone; - } - /** - * 获取: 挂号须知 - */ - public String getYishengGuahao() { - return yishengGuahao; - } - /** - * 设置: 挂号须知 - */ - public void setYishengGuahao(String yishengGuahao) { - this.yishengGuahao = yishengGuahao; - } - /** - * 获取: 邮箱 - */ - public String getYishengEmail() { - return yishengEmail; - } - /** - * 设置: 邮箱 - */ - public void setYishengEmail(String yishengEmail) { - this.yishengEmail = yishengEmail; - } - /** - * 获取: 挂号价格 - */ - public Double getYishengNewMoney() { - return yishengNewMoney; - } - /** - * 设置: 挂号价格 - */ - public void setYishengNewMoney(Double yishengNewMoney) { - this.yishengNewMoney = yishengNewMoney; - } - /** - * 获取: 履历介绍 - */ - public String getYishengContent() { - return yishengContent; - } - /** - * 设置: 履历介绍 - */ - public void setYishengContent(String yishengContent) { - this.yishengContent = yishengContent; - } - - - - - //级联表的get和set yonghu - /** - * 获取: 用户姓名 - */ - public String getYonghuName() { - return yonghuName; - } - /** - * 设置: 用户姓名 - */ - public void setYonghuName(String yonghuName) { - this.yonghuName = yonghuName; - } - /** - * 获取: 头像 - */ - public String getYonghuPhoto() { - return yonghuPhoto; - } - /** - * 设置: 头像 - */ - public void setYonghuPhoto(String yonghuPhoto) { - this.yonghuPhoto = yonghuPhoto; - } - /** - * 获取: 用户手机号 - */ - public String getYonghuPhone() { - return yonghuPhone; - } - /** - * 设置: 用户手机号 - */ - public void setYonghuPhone(String yonghuPhone) { - this.yonghuPhone = yonghuPhone; - } - /** - * 获取: 用户身份证号 - */ - public String getYonghuIdNumber() { - return yonghuIdNumber; - } - /** - * 设置: 用户身份证号 - */ - public void setYonghuIdNumber(String yonghuIdNumber) { - this.yonghuIdNumber = yonghuIdNumber; - } - /** - * 获取: 邮箱 - */ - public String getYonghuEmail() { - return yonghuEmail; - } - /** - * 设置: 邮箱 - */ - public void setYonghuEmail(String yonghuEmail) { - this.yonghuEmail = yonghuEmail; - } - /** - * 获取: 余额 - */ - public Double getNewMoney() { - return newMoney; - } - /** - * 设置: 余额 - */ - public void setNewMoney(Double newMoney) { - this.newMoney = newMoney; - } - /** - * 获取: 假删 - */ - public Integer getYonghuDelete() { - return yonghuDelete; - } - /** - * 设置: 假删 - */ - public void setYonghuDelete(Integer yonghuDelete) { - this.yonghuDelete = yonghuDelete; - } - - - -} + /** + * 获取: 挂号须知 + */ + // 获取挂号须知信息的方法,外部可以通过调用该方法获取yishengGuahao属性的值 + public String getYishengGuahao() { + return yishengGuahao; + } + + /** + * 设置: 挂号须知 + */ + // 设置挂号须知信息的方法,外部可以通过调用该方法设置yishengGuahao属性的值 + public void setYishengGuahao(String yishengGuahao) { + this.yishengGuahao = yishengGuahao; + } + + /** + * 获取: 邮箱 + */ + // 获取医生邮箱地址的方法,外部可以通过调用该方法获取yishengEmail属性的值 + public String getYishengEmail() { + return yishengEmail; + } + + /** + * 设置: 邮箱 + */ + // 设置医生邮箱地址的方法,外部可以通过调用该方法设置yishengEmail属性的值 + public void setYishengEmail(String yishengEmail) { + this.yishengEmail = yishengEmail; + } + + /** + * 获取: 挂号价格 + */ + // 获取挂号价格信息的方法,外部可以通过调用该方法获取yishengNewMoney属性的值 + public Double getYishengNewMoney() { + return yishengNewMoney; + } + + /** + * 设置: 挂号价格 + */ + // 设置挂号价格信息的方法,外部可以通过调用该方法设置yishengNewMoney属性的值 + public void setYishengNewMoney(Double yishengNewMoney) { + this.yishengNewMoney = yishengNewMoney; + } + + /** + * 获取: 履历介绍 + */ + // 获取医生履历介绍信息的方法,外部可以通过调用该方法获取yishengContent属性的值 + public String getYishengContent() { + return yishengContent; + } + + /** + * 设置: 履历介绍 + */ + // 设置医生履历介绍信息的方法,外部可以通过调用该方法设置yishengContent属性的值 + public void setYishengContent(String yishengContent) { + this.yishengContent = yishengContent; + } + + // 级联表的get和set yonghu + /** + * 获取: 用户姓名 + */ + // 获取用户姓名的方法,外部可以通过调用该方法获取yonghuName属性的值 + public String getYonghuName() { + return yonghuName; + } + + /** + * 设置: 用户姓名 + */ + // 设置用户姓名的方法,外部可以通过调用该方法设置yonghuName属性的值 + public void setYonghuName(String yonghuName) { + this.yonghuName = yonghuName; + } + + /** + * 获取: 头像 + */ + // 获取用户头像路径或标识的方法,外部可以通过调用该方法获取yonghuPhoto属性的值 + public String getYonghuPhoto() { + return yonghuPhoto; + } + + /** + * 设置: 头像 + */ + // 设置用户头像路径或标识的方法,外部可以通过调用该方法设置yonghuPhoto属性的值 + public void setYonghuPhoto(String yonghuPhoto) { + this.yonghuPhoto = yonghuPhoto; + } + + /** + * 获取: 用户手机号 + */ + // 获取用户手机号的方法,外部可以通过调用该方法获取yonghuPhone属性的值 + public String getYonghuPhone() { + return yonghuPhone; + } + + /** + * 设置: 用户手机号 + */ + // 设置用户手机号的方法,外部可以通过调用该方法设置yonghuPhone属性的值 + public void setYonghuPhone(String yonghuPhone) { + this.yonghuPhone = yonghuPhone; + } + + /** + * 获取: 用户身份证号 + */ + // 获取用户身份证号的方法,外部可以通过调用该方法获取yonghuIdNumber属性的值 + public String getYonghuIdNumber() { + return yonghuIdNumber; + } + + /** + * 设置: 用户身份证号 + */ + // 设置用户身份证号的方法,外部可以通过调用该方法设置yonghuIdNumber属性的值 + public void setYonghuIdNumber(String yonghuIdNumber) { + this.yonghuIdNumber = yonghuIdNumber; + } + + /** + * 获取: 邮箱 + */ + // 获取用户邮箱地址的方法,外部可以通过调用该方法获取yonghuEmail属性的值 + public String getYonghuEmail() { + return yonghuEmail; + } + +/** + * \ No newline at end of file diff --git a/src/main/java/com/entity/view/JiankangjiaoyuView.java b/src/main/java/com/entity/view/JiankangjiaoyuView.java index a6f2161..d5a1310 100644 --- a/src/main/java/com/entity/view/JiankangjiaoyuView.java +++ b/src/main/java/com/entity/view/JiankangjiaoyuView.java @@ -14,52 +14,51 @@ import java.util.Date; * 后端返回视图实体辅助类 * (通常后端关联的表或者自定义的字段需要返回使用) */ +// 使用TableName注解指定该类对应的数据库表名为 "jiankangjiaoyu" @TableName("jiankangjiaoyu") +// JiankangjiaoyuView类继承自JiankangjiaoyuEntity类,并实现了Serializable接口, +// 使得该类的对象可以被序列化和反序列化,方便在网络传输或存储中使用 public class JiankangjiaoyuView extends JiankangjiaoyuEntity implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 健康教育类型的值 - */ - private String jiankangjiaoyuValue; - + // 序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性 + private static final long serialVersionUID = 1L; + /** + * 健康教育类型的值 + */ + // 用于存储健康教育相关的类型值,可能表示不同的健康教育分类,如疾病预防、健康生活方式等 + private String jiankangjiaoyuValue; + // 无参构造函数,用于创建JiankangjiaoyuView对象,在不需要初始化特定属性时使用 public JiankangjiaoyuView() { } + // 构造函数,接受一个JiankangjiaoyuEntity对象作为参数, + // 通过BeanUtils.copyProperties方法将JiankangjiaoyuEntity对象的属性值复制到当前JiankangjiaoyuView对象中, + // 这样可以方便地从Entity对象转换为View对象,减少手动赋值的工作量 public JiankangjiaoyuView(JiankangjiaoyuEntity jiankangjiaoyuEntity) { try { BeanUtils.copyProperties(this, jiankangjiaoyuEntity); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 如果在复制属性过程中发生异常(例如属性访问权限问题或反射调用目标方法失败), + // 打印异常堆栈信息,以便开发人员调试和定位问题 e.printStackTrace(); } } + /** + * 获取: 健康教育类型的值 + */ + // 获取健康教育类型值的方法,外部可以通过调用该方法获取jiankangjiaoyuValue属性的值 + public String getJiankangjiaoyuValue() { + return jiankangjiaoyuValue; + } - - /** - * 获取: 健康教育类型的值 - */ - public String getJiankangjiaoyuValue() { - return jiankangjiaoyuValue; - } - /** - * 设置: 健康教育类型的值 - */ - public void setJiankangjiaoyuValue(String jiankangjiaoyuValue) { - this.jiankangjiaoyuValue = jiankangjiaoyuValue; - } - - - - - - - - - - -} + /** + * 设置: 健康教育类型的值 + */ + // 设置健康教育类型值的方法,外部可以通过调用该方法设置jiankangjiaoyuValue属性的值 + public void setJiankangjiaoyuValue(String jiankangjiaoyuValue) { + this.jiankangjiaoyuValue = jiankangjiaoyuValue; + } +} \ No newline at end of file diff --git a/src/main/java/com/entity/view/NewsView.java b/src/main/java/com/entity/view/NewsView.java index 521f42d..d0f14e1 100644 --- a/src/main/java/com/entity/view/NewsView.java +++ b/src/main/java/com/entity/view/NewsView.java @@ -1,12 +1,20 @@ package com.entity.view; +// 导入公告信息实体类,NewsView 会继承该类 import com.entity.NewsEntity; +// 导入 MyBatis-Plus 用于指定数据库表名的注解 import com.baomidou.mybatisplus.annotations.TableName; +// 导入 Apache Commons BeanUtils 工具类,用于对象属性复制 import org.apache.commons.beanutils.BeanUtils; +// 导入反射调用可能抛出的异常类 import java.lang.reflect.InvocationTargetException; +// 导入 Spring 框架用于日期格式化的注解 import org.springframework.format.annotation.DateTimeFormat; +// 导入 Jackson 用于 JSON 序列化时日期格式化的注解 import com.fasterxml.jackson.annotation.JsonFormat; +// 导入序列化接口 import java.io.Serializable; +// 导入日期类 import java.util.Date; /** @@ -14,52 +22,48 @@ import java.util.Date; * 后端返回视图实体辅助类 * (通常后端关联的表或者自定义的字段需要返回使用) */ +// 指定该类对应数据库中的 news 表 @TableName("news") +// NewsView 类继承自 NewsEntity 类,并实现 Serializable 接口,可进行序列化操作 public class NewsView extends NewsEntity implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 公告类型的值 - */ - private String newsValue; - + // 序列化版本号,确保序列化和反序列化的兼容性 + private static final long serialVersionUID = 1L; + /** + * 公告类型的值 + */ + // 存储公告类型的具体描述值,例如“紧急通知”“普通公告”等 + private String newsValue; + // 无参构造函数,方便创建 NewsView 类的实例 public NewsView() { } + // 带参构造函数,接收一个 NewsEntity 对象,将其属性复制到当前 NewsView 对象 public NewsView(NewsEntity newsEntity) { try { + // 使用 BeanUtils 工具类复制属性 BeanUtils.copyProperties(this, newsEntity); } catch (IllegalAccessException | InvocationTargetException e) { - // TODO Auto-generated catch block + // 若复制属性过程中出现异常,打印异常堆栈信息 e.printStackTrace(); } } + /** + * 获取: 公告类型的值 + */ + // 获取公告类型值的方法 + public String getNewsValue() { + return newsValue; + } - - /** - * 获取: 公告类型的值 - */ - public String getNewsValue() { - return newsValue; - } - /** - * 设置: 公告类型的值 - */ - public void setNewsValue(String newsValue) { - this.newsValue = newsValue; - } - - - - - - - - - - -} + /** + * 设置: 公告类型的值 + */ + // 设置公告类型值的方法 + public void setNewsValue(String newsValue) { + this.newsValue = newsValue; + } +} \ No newline at end of file diff --git a/src/main/java/com/interceptor/AuthorizationInterceptor.java b/src/main/java/com/interceptor/AuthorizationInterceptor.java index 723834b..ff46fa7 100644 --- a/src/main/java/com/interceptor/AuthorizationInterceptor.java +++ b/src/main/java/com/interceptor/AuthorizationInterceptor.java @@ -29,19 +29,18 @@ public class AuthorizationInterceptor implements HandlerInterceptor { public static final String LOGIN_TOKEN_KEY = "Token"; @Autowired - private TokenService tokenService; - - @Override + private TokenService tokenService; // 注入 TokenService + @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - String servletPath = request.getServletPath(); - if("/dictionary/page".equals(request.getServletPath()) || "/file/upload".equals(request.getServletPath()) || "/yonghu/register".equals(request.getServletPath()) ){//请求路径是字典表或者文件上传 直接放行 + if ("/dictionary/page".equals(request.getServletPath()) || "/file/upload".equals(request.getServletPath()) || "/yonghu/register".equals(request.getServletPath())) { + // 请求路径是字典表或者文件上传 直接放行 return true; } - //支持跨域请求 - response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); + // 支持跨域请求 + response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Credentials", "true"); response.setHeader("Access-Control-Allow-Headers", "x-requested-with,request-source,Token, Origin,imgType, Content-Type, cache-control,postman-token,Cookie, Accept,authorization"); @@ -54,41 +53,41 @@ public class AuthorizationInterceptor implements HandlerInterceptor { return true; } - //从header中获取token + // 从header中获取token String token = request.getHeader(LOGIN_TOKEN_KEY); - + /** * 不需要验证权限的方法直接放过 */ - if(annotation!=null) { - return true; + if (annotation != null) { + return true; } - + TokenEntity tokenEntity = null; - if(StringUtils.isNotBlank(token)) { - tokenEntity = tokenService.getTokenEntity(token); + if (StringUtils.isNotBlank(token)) { + tokenEntity = tokenService.getTokenEntity(token); } - - if(tokenEntity != null) { - request.getSession().setAttribute("userId", tokenEntity.getUserid()); - request.getSession().setAttribute("role", tokenEntity.getRole()); - request.getSession().setAttribute("tableName", tokenEntity.getTablename()); - request.getSession().setAttribute("username", tokenEntity.getUsername()); - return true; + + if (tokenEntity != null) { + request.getSession().setAttribute("userId", tokenEntity.getUserid()); + request.getSession().setAttribute("role", tokenEntity.getRole()); + request.getSession().setAttribute("tableName", tokenEntity.getTablename()); + request.getSession().setAttribute("username", tokenEntity.getUsername()); + return true; + } + + PrintWriter writer = null; + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/json; charset=utf-8"); + try { + writer = response.getWriter(); + writer.print(JSONObject.toJSONString(R.error(401, "请先登录"))); + } finally { + if (writer != null) { + writer.close(); + } } - - PrintWriter writer = null; - response.setCharacterEncoding("UTF-8"); - response.setContentType("application/json; charset=utf-8"); - try { - writer = response.getWriter(); - writer.print(JSONObject.toJSONString(R.error(401, "请先登录"))); - } finally { - if(writer != null){ - writer.close(); - } - } -// throw new EIException("请先登录", 401); - return false; +// throw new EIException("请先登录", 401); + return false; } -} +} \ No newline at end of file diff --git a/src/main/java/com/model/enums/TypeEnum.java b/src/main/java/com/model/enums/TypeEnum.java index 39061d8..e9c9de1 100644 --- a/src/main/java/com/model/enums/TypeEnum.java +++ b/src/main/java/com/model/enums/TypeEnum.java @@ -1,31 +1,39 @@ package com.model.enums; +// 导入序列化接口,使枚举对象可以进行序列化和反序列化操作 import java.io.Serializable; - +// 导入 MyBatis-Plus 的枚举接口,用于将枚举值映射到数据库字段 import com.baomidou.mybatisplus.enums.IEnum; /** * 必须现在 IEnum 配置 该包扫描自动注入,查看文件 spring-mybatis.xml 参数 typeEnumsPackage + * 这个枚举类用于表示某种状态,包含两种状态:禁用和正常 */ public enum TypeEnum implements IEnum { + // 定义枚举常量,分别表示禁用状态和正常状态 DISABLED(0, "禁用"), NORMAL(1, "正常"); + // 用于存储枚举值对应的整数值,通常与数据库中的字段值对应 private final int value; + // 用于存储枚举值对应的中文描述,方便在代码中使用和展示 private final String desc; + // 枚举类的构造函数,用于初始化枚举常量的 value 和 desc 属性 TypeEnum(final int value, final String desc) { this.value = value; this.desc = desc; } + // 实现 IEnum 接口的方法,返回枚举值对应的整数值,用于与数据库字段进行映射 @Override public Serializable getValue() { return this.value; } - // Jackson 注解为 JsonValue 返回中文 json 描述 + // 该方法用于获取枚举值的中文描述,使用 Jackson 注解时,可将该描述作为 JSON 序列化时的值 + // 这样在进行 JSON 序列化时,会返回枚举值的中文描述而不是枚举名称 public String getDesc() { return this.desc; } -} +} \ No newline at end of file diff --git a/src/main/resources/front/front/js/validate.js b/src/main/resources/front/front/js/validate.js index 6677b45..9f9bc10 100644 --- a/src/main/resources/front/front/js/validate.js +++ b/src/main/resources/front/front/js/validate.js @@ -1,74 +1,90 @@ /** - * 邮箱 - * @param {*} s + * 验证输入的字符串是否为有效的邮箱地址 + * @param {*} s - 要验证的字符串,预期为邮箱地址 + * @returns {boolean} - 如果字符串是有效的邮箱地址,返回 true;否则返回 false。当传入的 s 为 null 或 undefined 时,直接返回 true */ function isEmail(s) { - if(s){ - return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(s) + if (s) { + // 使用正则表达式匹配邮箱地址的格式 + return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(s); } return true; } /** - * 手机号码 - * @param {*} s + * 验证输入的字符串是否为有效的手机号码 + * @param {*} s - 要验证的字符串,预期为手机号码 + * @returns {boolean} - 如果字符串是有效的手机号码,返回 true;否则返回 false。当传入的 s 为 null 或 undefined 时,直接返回 true */ function isMobile(s) { - if(s){ - return /^1[0-9]{10}$/.test(s) + if (s) { + // 使用正则表达式匹配手机号码的格式(以 1 开头,后面跟着 10 位数字) + return /^1[0-9]{10}$/.test(s); } return true; } /** - * 电话号码 - * @param {*} s + * 验证输入的字符串是否为有效的电话号码 + * @param {*} s - 要验证的字符串,预期为电话号码 + * @returns {boolean} - 如果字符串是有效的电话号码,返回 true;否则返回 false。当传入的 s 为 null 或 undefined 时,直接返回 true */ function isPhone(s) { - if(s){ - return /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(s) + if (s) { + // 使用正则表达式匹配电话号码的格式(可以有 3 到 4 位区号,后面跟着 7 到 8 位号码,区号和号码之间用 - 分隔) + return /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(s); } return true; } /** - * URL地址 - * @param {*} s + * 验证输入的字符串是否为有效的 URL 地址 + * @param {*} s - 要验证的字符串,预期为 URL 地址 + * @returns {boolean} - 如果字符串是有效的 URL 地址,返回 true;否则返回 false。当传入的 s 为 null 或 undefined 时,直接返回 true */ function isURL(s) { - if(s){ - return /^http[s]?:\/\/.*/.test(s) + if (s) { + // 使用正则表达式匹配 URL 地址的格式(以 http 或 https 开头) + return /^http[s]?:\/\/.*/.test(s); } return true; } /** - * 匹配数字,可以是小数,不可以是负数,可以为空 - * @param {*} s + * 验证输入的字符串是否为有效的数字(可以是小数,不能是负数,可以为空) + * @param {*} s - 要验证的字符串,预期为数字 + * @returns {boolean} - 如果字符串是有效的数字(符合指定格式),返回 true;否则返回 false。当传入的 s 为 null 或 undefined 时,直接返回 true */ function isNumber(s) { - if(s){ + if (s) { + // 使用正则表达式匹配数字的格式,包括小数和科学计数法形式,不允许负数 return /(^-?[+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?[0-9]+)?$)|(^$)/.test(s); } return true; } + /** - * 匹配整数,可以为空 - * @param {*} s + * 验证输入的字符串是否为有效的整数(可以为空) + * @param {*} s - 要验证的字符串,预期为整数 + * @returns {boolean} - 如果字符串是有效的整数(符合指定格式),返回 true;否则返回 false。当传入的 s 为 null 或 undefined 时,直接返回 true */ function isIntNumer(s) { - if(s){ + if (s) { + // 使用正则表达式匹配整数的格式,包括正负整数和空字符串 return /(^-?\d+$)|(^$)/.test(s); } return true; } + /** - * 身份证校验 + * 验证输入的字符串是否为有效的身份证号码 + * @param {string} idcard - 要验证的字符串,预期为身份证号码 + * @returns {boolean} - 如果字符串是有效的身份证号码(符合 15 位、18 位或 17 位加最后一位为 X 或 x 的格式),返回 true;否则返回 false。当传入的 idcard 为 null 或 undefined 时,直接返回 true */ function isIdentity(idcard) { const regIdCard = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; - if(idcard){ + if (idcard) { return regIdCard.test(idcard); } return true; -} +} \ No newline at end of file From 42e51e2755b876b6a7302de1b35c45cf5c318e96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=A0=C3=A7=C2=9Acqq?= <你的2870787453@qq.com> Date: Tue, 29 Apr 2025 19:03:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=9D=E5=A7=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/controller/CommonController.java | 657 +++++++++++++----- 1 file changed, 497 insertions(+), 160 deletions(-) diff --git a/src/main/java/com/controller/CommonController.java b/src/main/java/com/controller/CommonController.java index 9592370..7ad285c 100644 --- a/src/main/java/com/controller/CommonController.java +++ b/src/main/java/com/controller/CommonController.java @@ -1,364 +1,701 @@ package com.controller; -// 导入处理文件操作的类 import java.io.File; -// 导入文件未找到异常类 import java.io.FileNotFoundException; -// 导入输入输出异常类 import java.io.IOException; -// 导入用于格式化日期的类 import java.text.SimpleDateFormat; -// 导入常用的集合类 import java.util.*; -// 导入Servlet请求相关类 import javax.servlet.http.HttpServletRequest; -// 导入阿里巴巴的JSON处理类 import com.alibaba.fastjson.JSON; -// 导入自定义的字符串工具类 import com.utils.StringUtil; -// 导入Apache Commons提供的字符串工具类 import org.apache.commons.lang3.StringUtils; -// 导入JSON对象类 import org.json.JSONObject; -// 导入日志记录器接口 import org.slf4j.Logger; -// 导入日志记录器工厂类 import org.slf4j.LoggerFactory; -// 导入Spring的自动注入注解 import org.springframework.beans.factory.annotation.Autowired; -// 导入Spring用于获取资源的工具类 import org.springframework.util.ResourceUtils; -// 导入Spring的路径变量注解 import org.springframework.web.bind.annotation.PathVariable; -// 导入Spring的请求体注解 import org.springframework.web.bind.annotation.RequestBody; -// 导入Spring的请求映射注解 import org.springframework.web.bind.annotation.RequestMapping; -// 导入Spring的请求参数注解 import org.springframework.web.bind.annotation.RequestParam; -// 导入Spring的RESTful控制器注解 import org.springframework.web.bind.annotation.RestController; -// 导入自定义的忽略权限注解类 import com.annotation.IgnoreAuth; -// 导入百度AI开放平台的人脸识别客户端类 import com.baidu.aip.face.AipFace; -// 导入百度AI开放平台的人脸比对请求类 import com.baidu.aip.face.MatchRequest; -// 导入百度AI开放平台的Base64编码工具类 import com.baidu.aip.util.Base64Util; -// 导入MyBatis-Plus的实体包装器类 import com.baomidou.mybatisplus.mapper.EntityWrapper; -// 导入MyBatis-Plus的查询包装器接口 import com.baomidou.mybatisplus.mapper.Wrapper; -// 导入自定义的配置实体类 import com.entity.ConfigEntity; -// 导入自定义的通用服务类 import com.service.CommonService; -// 导入自定义的配置服务类 import com.service.ConfigService; -// 导入自定义的百度工具类 import com.utils.BaiduUtil; -// 导入自定义的文件工具类 import com.utils.FileUtil; -// 导入自定义的响应结果类 import com.utils.R; + /** * 通用接口 */ @RestController -public class CommonController { - // 日志记录器,用于记录当前控制器类的日志信息 +public class CommonController{ private static final Logger logger = LoggerFactory.getLogger(CommonController.class); - // 自动注入通用服务类,用于处理通用业务逻辑 @Autowired private CommonService commonService; - // 自动注入配置服务类,用于处理配置相关业务逻辑 @Autowired private ConfigService configService; - // 静态变量,存储百度人脸识别客户端实例,初始化为null private static AipFace client = null; - // 静态变量,存储百度地图API的AK(应用密钥),初始化为null private static String BAIDU_DITU_AK = null; - // 处理获取位置信息的请求,根据经纬度获取城市信息 @RequestMapping("/location") - public R location(String lng, String lat) { - // 如果BAIDU_DITU_AK尚未初始化 - if (BAIDU_DITU_AK == null) { - // 从配置表中查询名称为"baidu_ditu_ak"的配置项的值 + public R location(String lng,String lat) { + if(BAIDU_DITU_AK==null) { BAIDU_DITU_AK = configService.selectOne(new EntityWrapper().eq("name", "baidu_ditu_ak")).getValue(); - // 如果查询结果为空,返回错误响应 - if (BAIDU_DITU_AK == null) { + if(BAIDU_DITU_AK==null) { return R.error("请在配置管理中正确配置baidu_ditu_ak"); } } - // 调用百度工具类的方法,根据AK、经度和纬度获取城市信息 Map map = BaiduUtil.getCityByLonLat(BAIDU_DITU_AK, lng, lat); - // 返回成功响应,并将获取到的城市信息封装在"data"属性中 return R.ok().put("data", map); } /** * 人脸比对 - * @param face1 人脸1的相关信息(可能是文件名等) - * @param face2 人脸2的相关信息(可能是文件名等) - * @return 响应结果对象,包含比对结果数据 + * @param face1 人脸1 + * @param face2 人脸2 + * @return */ @RequestMapping("/matchFace") public R matchFace(String face1, String face2, HttpServletRequest request) { - // 如果百度人脸识别客户端尚未初始化 - if (client == null) { + if(client==null) { /*String AppID = configService.selectOne(new EntityWrapper().eq("name", "AppID")).getValue();*/ - // 从配置表中查询名称为"APIKey"的配置项的值 String APIKey = configService.selectOne(new EntityWrapper().eq("name", "APIKey")).getValue(); - // 从配置表中查询名称为"SecretKey"的配置项的值 String SecretKey = configService.selectOne(new EntityWrapper().eq("name", "SecretKey")).getValue(); - // 使用APIKey和SecretKey获取访问令牌 String token = BaiduUtil.getAuth(APIKey, SecretKey); - // 如果获取令牌失败,返回错误响应 - if (token == null) { + if(token==null) { return R.error("请在配置管理中正确配置APIKey和SecretKey"); } - // 初始化百度人脸识别客户端 client = new AipFace(null, APIKey, SecretKey); - // 设置连接超时时间为2000毫秒 client.setConnectionTimeoutInMillis(2000); - // 设置套接字超时时间为60000毫秒 client.setSocketTimeoutInMillis(60000); } - // 用于存储人脸比对结果的JSONObject对象,初始化为null JSONObject res = null; try { - // 根据请求中的face1信息,构建人脸1的文件对象 - File file1 = new File(request.getSession().getServletContext().getRealPath("/upload") + "/" + face1); - // 根据请求中的face2信息,构建人脸2的文件对象 - File file2 = new File(request.getSession().getServletContext().getRealPath("/upload") + "/" + face2); - // 将人脸1的文件内容转换为Base64编码的字符串 + File file1 = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+face1); + File file2 = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+face2); String img1 = Base64Util.encode(FileUtil.FileToByte(file1)); - // 将人脸2的文件内容转换为Base64编码的字符串 String img2 = Base64Util.encode(FileUtil.FileToByte(file2)); - // 创建人脸1的比对请求对象 MatchRequest req1 = new MatchRequest(img1, "BASE64"); - // 创建人脸2的比对请求对象 MatchRequest req2 = new MatchRequest(img2, "BASE64"); - // 创建存储比对请求的ArrayList ArrayList requests = new ArrayList(); - // 将人脸1的请求添加到请求列表中 requests.add(req1); - // 将人脸2的请求添加到请求列表中 requests.add(req2); - // 调用百度人脸识别客户端的match方法进行人脸比对,并获取结果 res = client.match(requests); - // 打印比对结果中的"result"部分(可能是比对的详细信息) System.out.println(res.get("result")); } catch (FileNotFoundException e) { - // 捕获文件未找到异常,打印异常堆栈信息 e.printStackTrace(); - // 返回错误响应,提示文件不存在 return R.error("文件不存在"); } catch (IOException e) { - // 捕获输入输出异常,打印异常堆栈信息 e.printStackTrace(); } - // 将比对结果中的"result"部分解析为JSON对象,并封装在响应结果中返回 return R.ok().put("data", com.alibaba.fastjson.JSONObject.parse(res.get("result").toString())); } + /** * 获取table表中的column列表(联动接口) - * @return 响应结果对象,包含获取到的列数据列表 + * @return */ @RequestMapping("/option/{tableName}/{columnName}") - @IgnoreAuth // 忽略权限验证的注解 - public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, String level, String parent) { - // 创建用于存储请求参数的Map对象 + @IgnoreAuth + public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,String level,String parent) { Map params = new HashMap(); - // 将表名添加到参数Map中 params.put("table", tableName); - // 将列名添加到参数Map中 params.put("column", columnName); - // 如果level参数不为空,将其添加到参数Map中 - if (StringUtils.isNotBlank(level)) { + if(StringUtils.isNotBlank(level)) { params.put("level", level); } - // 如果parent参数不为空,将其添加到参数Map中 - if (StringUtils.isNotBlank(parent)) { + if(StringUtils.isNotBlank(parent)) { params.put("parent", parent); } - // 调用通用服务类的方法,根据参数获取列数据列表 List data = commonService.getOption(params); - // 返回成功响应,并将获取到的列数据列表封装在"data"属性中 return R.ok().put("data", data); } + /** * 根据table中的column获取单条记录 - * @return 响应结果对象,包含获取到的单条记录数据 + * @return */ @RequestMapping("/follow/{tableName}/{columnName}") - @IgnoreAuth // 忽略权限验证的注解 + @IgnoreAuth public R getFollowByOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, @RequestParam String columnValue) { - // 创建用于存储请求参数的Map对象 Map params = new HashMap(); - // 将表名添加到参数Map中 params.put("table", tableName); - // 将列名添加到参数Map中 params.put("column", columnName); - // 将列值添加到参数Map中 params.put("columnValue", columnValue); - // 调用通用服务类的方法,根据参数获取单条记录数据 Map result = commonService.getFollowByOption(params); - // 返回成功响应,并将获取到的单条记录数据封装在"data"属性中 return R.ok().put("data", result); } + /** * 修改table表的sfsh状态 - * @param map 包含表名和其他相关参数的Map对象 - * @return 响应结果对象,表示操作是否成功 + * @param map + * @return */ @RequestMapping("/sh/{tableName}") public R sh(@PathVariable("tableName") String tableName, @RequestBody Map map) { - // 将表名添加到参数Map中 map.put("table", tableName); - // 调用通用服务类的方法,执行修改sfsh状态的操作 commonService.sh(map); - // 返回成功响应 return R.ok(); } + /** * 获取需要提醒的记录数 - * @param tableName 表名 - * @param columnName 列名 - * @param type 类型(1:数字 2:日期) - * @param map 包含其他相关参数的Map对象 - * @return 响应结果对象,包含需要提醒的记录数 + * @param tableName + * @param columnName + * @param type 1:数字 2:日期 + * @param map + * @return */ @RequestMapping("/remind/{tableName}/{columnName}/{type}") - @IgnoreAuth // 忽略权限验证的注解 + @IgnoreAuth public R remindCount(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, - @PathVariable("type") String type, @RequestParam Map map) { - // 将表名添加到参数Map中 + @PathVariable("type") String type,@RequestParam Map map) { map.put("table", tableName); - // 将列名添加到参数Map中 map.put("column", columnName); - // 将类型添加到参数Map中 map.put("type", type); - // 如果类型为日期("2") - if (type.equals("2")) { - // 创建日期格式化对象,格式为"yyyy-MM-dd" + if(type.equals("2")) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - // 获取日历实例 Calendar c = Calendar.getInstance(); - // 用于存储提醒开始日期,初始化为null Date remindStartDate = null; - // 用于存储提醒结束日期,初始化为null Date remindEndDate = null; - // 如果参数Map中包含"remindstart"(提醒开始时间间隔) - if (map.get("remindstart") != null) { - // 将"remindstart"转换为整数 + if(map.get("remindstart")!=null) { Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); - // 设置日历时间为当前日期 c.setTime(new Date()); - // 根据提醒开始时间间隔,计算提醒开始日期 - c.add(Calendar.DAY_OF_MONTH, remindStart); - // 获取计算后的提醒开始日期 + c.add(Calendar.DAY_OF_MONTH,remindStart); remindStartDate = c.getTime(); - // 将提醒开始日期格式化为字符串,并更新参数Map中的"remindstart"值 map.put("remindstart", sdf.format(remindStartDate)); } - // 如果参数Map中包含"remindend"(提醒结束时间间隔) - if (map.get("remindend") != null) { - // 将"remindend"转换为整数 + if(map.get("remindend")!=null) { Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); - // 设置日历时间为当前日期 c.setTime(new Date()); - // 根据提醒结束时间间隔,计算提醒结束日期 - c.add(Calendar.DAY_OF_MONTH, remindEnd); - // 获取计算后的提醒结束日期 + c.add(Calendar.DAY_OF_MONTH,remindEnd); remindEndDate = c.getTime(); - // 将提醒结束日期格式化为字符串,并更新参数Map中的"remindend"值 map.put("remindend", sdf.format(remindEndDate)); } } - // 调用通用服务类的方法,根据参数获取需要提醒的记录数 int count = commonService.remindCount(map); - // 返回成功响应,并将记录数封装在"count"属性中 return R.ok().put("count", count); } + /** - * 图表统计 + * 圖表统计 */ - @IgnoreAuth // 忽略权限验证的注解 + @IgnoreAuth @RequestMapping("/group/{tableName}") - public R group1(@PathVariable("tableName") String tableName, @RequestParam Map params) { - // 将表名添加到参数Map中,键为"table1" + public R group1(@PathVariable("tableName") String tableName, @RequestParam Map params) { params.put("table1", tableName); - // 调用通用服务类的方法,进行图表统计并获取结果 List> result = commonService.chartBoth(params); - // 返回成功响应,并将统计结果封装在"data"属性中 return R.ok().put("data", result); } + + /** * 单列求和 */ @RequestMapping("/cal/{tableName}/{columnName}") - @IgnoreAuth // 忽略权限验证的注解 + @IgnoreAuth public R cal(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) { - // 创建用于存储请求参数的Map对象 Map params = new HashMap(); - // 将表名添加到参数Map中 params.put("table", tableName); - //将列名添加到参数Map中 params.put("column", columnName); - // 调用通用服务类的方法,进行单列求和并获取结果 Map result = commonService.selectCal(params); - // 返回成功响应,并将求和结果封装在"data"属性中 return R.ok().put("data", result); } + /** * 分组统计 */ @RequestMapping("/group/{tableName}/{columnName}") - @IgnoreAuth // 忽略权限验证的注解 + @IgnoreAuth public R group(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) { - // 创建用于存储请求参数的Map对象 Map params = new HashMap(); - // 将表名添加到参数Map中 params.put("table", tableName); - // 将列名添加到参数Map中 params.put("column", columnName); - // 调用通用服务类的方法,进行分组统计并获取结果 List> result = commonService.selectGroup(params); - // 返回成功响应,并将统计结果封装在"data"属性中 return R.ok().put("data", result); } + /** * (按值统计) */ @RequestMapping("/value/{tableName}/{xColumnName}/{yColumnName}") - @IgnoreAuth // 忽略权限验证的注解 + @IgnoreAuth public R value(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName) { - // 创建用于存储请求参数的Map对象 Map params = new HashMap(); - // 将表名添加到参数Map中 params.put("table", tableName); - // 将x轴列名添加到参数Map中 params.put("xColumn", xColumnName); - //将y轴列名添加到参数Map中 params.put("yColumn", yColumnName); - // 调用通用服务类的 \ No newline at end of file + List> result = commonService.selectValue(params); + return R.ok().put("data", result); + } + + + + + /** + * 查询字典表的分组求和 + * tableName 表名 + * groupColumn 分组字段 + * sumCloum 统计字段 + * @return + */ + @RequestMapping("/newSelectGroupSum") + public R newSelectGroupSum(@RequestParam Map params) { + logger.debug("newSelectGroupSum:,,Controller:{},,params:{}",this.getClass().getName(),params); + List> result = commonService.newSelectGroupSum(params); + return R.ok().put("data", result); + } + + + + /** + tableName 查询表 + condition1 条件1 + condition1Value 条件1值 + average 计算平均评分 + 取值 + 有值 Number(res.data.value.toFixed(1)) + 无值 if(res.data){} + * */ + @IgnoreAuth + @RequestMapping("/queryScore") + public R queryScore(@RequestParam Map params) { + logger.debug("queryScore:,,Controller:{},,params:{}",this.getClass().getName(),params); + Map queryScore = commonService.queryScore(params); + return R.ok().put("data", queryScore); + } + + + /** + * 查询字典表的分组统计总条数 + * tableName 表名 + * groupColumn 分组字段 + * @return + */ + @RequestMapping("/newSelectGroupCount") + public R newSelectGroupCount(@RequestParam Map params) { + logger.debug("newSelectGroupCount:,,Controller:{},,params:{}",this.getClass().getName(),params); + List> result = commonService.newSelectGroupCount(params); + return R.ok().put("data", result); + } + + /** + * 当前表的日期分组求和 + * tableName 表名 + * groupColumn 分组字段 + * sumCloum 统计字段 + * dateFormatType 日期格式化类型 1:年 2:月 3:日 + * @return + */ + @RequestMapping("/newSelectDateGroupSum") + public R newSelectDateGroupSum(@RequestParam Map params) { + logger.debug("newSelectDateGroupSum:,,Controller:{},,params:{}",this.getClass().getName(),params); + String dateFormatType = String.valueOf(params.get("dateFormatType")); + if("1".equals(dateFormatType)){ + params.put("dateFormat", "%Y"); + }else if("2".equals(dateFormatType)){ + params.put("dateFormat", "%Y-%m"); + }else if("3".equals(dateFormatType)){ + params.put("dateFormat", "%Y-%m-%d"); + }else{ + R.error("日期格式化不正确"); + } + List> result = commonService.newSelectDateGroupSum(params); + return R.ok().put("data", result); + } + + + /** + * 1查询字典表的分组统计总条数 + * tableName 表名 + * groupColumn 分组字段 + * dateFormatType 日期格式化类型 1:年 2:月 3:日 + * @return + */ + @RequestMapping("/newSelectDateGroupCount") + public R newSelectDateGroupCount(@RequestParam Map params) { + logger.debug("newSelectDateGroupCount:,,Controller:{},,params:{}",this.getClass().getName(),params); + String dateFormatType = String.valueOf(params.get("dateFormatType")); + if("1".equals(dateFormatType)){ + params.put("dateFormat", "%Y"); + }else if("2".equals(dateFormatType)){ + params.put("dateFormat", "%Y-%m"); + }else if("3".equals(dateFormatType)){ + params.put("dateFormat", "%Y-%m-%d"); + }else{ + R.error("日期格式化类型不正确"); + } + List> result = commonService.newSelectDateGroupCount(params); + return R.ok().put("data", result); + } +/** + * 饼状图 + * -- 饼状图 查询当前表 + -- 查询字典表【月】 + -- 统计 -- 查询某个月的每个类型的订单销售数量 + -- 求和 -- 查询某个月的每个类型的订单销售额 + -- 查询某个字符串【月】 + -- 统计 -- 查询某个月的每个员工的订单销售数量 + -- 求和 -- 查询某个月的每个员工的订单销售额 + -- 查询时间【年】 + -- 统计 -- 查询每个月的订单销售数量 + -- 求和 -- 查询每个月的订单销售额 + -- 饼状图 查询级联表 + -- 查询字典表 + -- 统计 -- 查询某个月的每个类型的订单销售数量 + -- 求和 -- 查询某个月的每个类型的订单销售额 + -- 查询某个字符串 + -- 统计 -- 查询某个月的每个员工的订单销售数量 + -- 求和 -- 查询某个月的每个员工的订单销售额 + -- 查询时间 + -- 统计 -- 统计每个月的订单销售数量 + -- 求和 -- 查询每个月的订单销售额 + */ + + +/** + * 柱状图 + -- 柱状图 查询当前表 + -- 某个【年,月】 + -- 当前表 2 级联表 1 + -- 统计 + -- 【日期,字符串,下拉框】 + -- 求和 + -- 【日期,字符串,下拉框】 + -- 柱状图 查询级联表 + -- 某个【年,月】 + -- 统计 + -- 【日期,字符串,下拉框】 + -- 求和 + -- 【日期,字符串,下拉框】 + */ + + /** + * 柱状图求和 + */ + @RequestMapping("/barSum") + public R barSum(@RequestParam Map params) { + logger.debug("barSum方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params)); + Boolean isJoinTableFlag = false;//是否有级联表相关 + String one = "";//第一优先 + String two = "";//第二优先 + + //处理thisTable和joinTable 处理内容是把json字符串转为Map并把带有,的切割为数组 + //当前表 + Map thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class); + params.put("thisTable",thisTable); + + //级联表 + String joinTableString = String.valueOf(params.get("joinTable")); + if(StringUtil.isNotEmpty(joinTableString)) { + Map joinTable = JSON.parseObject(joinTableString, Map.class); + params.put("joinTable", joinTable); + isJoinTableFlag = true; + } + + if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))){//当前表日期 + thisTable.put("date",String.valueOf(thisTable.get("date")).split(",")); + one = "thisDate0"; + } + if(isJoinTableFlag){//级联表日期 + Map joinTable = (Map) params.get("joinTable"); + if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("date")))){ + joinTable.put("date",String.valueOf(joinTable.get("date")).split(",")); + if(StringUtil.isEmpty(one)){ + one ="joinDate0"; + }else{ + if(StringUtil.isEmpty(two)){ + two ="joinDate0"; + } + } + } + } + if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("string")))){//当前表字符串 + thisTable.put("string",String.valueOf(thisTable.get("string")).split(",")); + if(StringUtil.isEmpty(one)){ + one ="thisString0"; + }else{ + if(StringUtil.isEmpty(two)){ + two ="thisString0"; + } + } + } + if(isJoinTableFlag){//级联表字符串 + Map joinTable = (Map) params.get("joinTable"); + if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("string")))){ + joinTable.put("string",String.valueOf(joinTable.get("string")).split(",")); + if(StringUtil.isEmpty(one)){ + one ="joinString0"; + }else{ + if(StringUtil.isEmpty(two)){ + two ="joinString0"; + } + } + } + } + if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("types")))){//当前表类型 + thisTable.put("types",String.valueOf(thisTable.get("types")).split(",")); + if(StringUtil.isEmpty(one)){ + one ="thisTypes0"; + }else{ + if(StringUtil.isEmpty(two)){ + two ="thisTypes0"; + } + } + } + if(isJoinTableFlag){//级联表类型 + Map joinTable = (Map) params.get("joinTable"); + if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("types")))){ + joinTable.put("types",String.valueOf(joinTable.get("types")).split(",")); + if(StringUtil.isEmpty(one)){ + one ="joinTypes0"; + }else{ + if(StringUtil.isEmpty(two)){ + two ="joinTypes0"; + } + } + + } + } + + List> result = commonService.barSum(params); + + List xAxis = new ArrayList<>();//报表x轴 + List> yAxis = new ArrayList<>();//y轴 + List legend = new ArrayList<>();//标题 + + if(StringUtil.isEmpty(two)){//不包含第二列 + List yAxis0 = new ArrayList<>(); + yAxis.add(yAxis0); + legend.add("数值"); + for(Map map :result){ + String oneValue = String.valueOf(map.get(one)); + String value = String.valueOf(map.get("value")); + xAxis.add(oneValue); + yAxis0.add(value); + } + }else{//包含第二列 + Map> dataMap = new LinkedHashMap<>(); + if(StringUtil.isNotEmpty(two)){ + for(Map map :result){ + String oneValue = String.valueOf(map.get(one)); + String twoValue = String.valueOf(map.get(two)); + String value = String.valueOf(map.get("value")); + if(!legend.contains(twoValue)){ + legend.add(twoValue);//添加完成后 就是最全的第二列的类型 + } + if(dataMap.containsKey(oneValue)){ + dataMap.get(oneValue).put(twoValue,value); + }else{ + HashMap oneData = new HashMap<>(); + oneData.put(twoValue,value); + dataMap.put(oneValue,oneData); + } + + } + } + + for(int i =0; i()); + } + + Set keys = dataMap.keySet(); + for(String key:keys){ + xAxis.add(key); + HashMap map = dataMap.get(key); + for(int i =0; i data = yAxis.get(i); + if(StringUtil.isNotEmpty(map.get(legend.get(i)))){ + data.add(map.get(legend.get(i))); + }else{ + data.add("0"); + } + } + } + System.out.println(); + } + + Map resultMap = new HashMap<>(); + resultMap.put("xAxis",xAxis); + resultMap.put("yAxis",yAxis); + resultMap.put("legend",legend); + return R.ok().put("data", resultMap); + } + + /** + * 柱状图统计 + */ + @RequestMapping("/barCount") + public R barCount(@RequestParam Map params) { + logger.debug("barCount方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params)); + Boolean isJoinTableFlag = false;//是否有级联表相关 + String one = "";//第一优先 + String two = "";//第二优先 + + //处理thisTable和joinTable 处理内容是把json字符串转为Map并把带有,的切割为数组 + //当前表 + Map thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class); + params.put("thisTable",thisTable); + + //级联表 + String joinTableString = String.valueOf(params.get("joinTable")); + if(StringUtil.isNotEmpty(joinTableString)) { + Map joinTable = JSON.parseObject(joinTableString, Map.class); + params.put("joinTable", joinTable); + isJoinTableFlag = true; + } + + if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))){//当前表日期 + thisTable.put("date",String.valueOf(thisTable.get("date")).split(",")); + one = "thisDate0"; + } + if(isJoinTableFlag){//级联表日期 + Map joinTable = (Map) params.get("joinTable"); + if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("date")))){ + joinTable.put("date",String.valueOf(joinTable.get("date")).split(",")); + if(StringUtil.isEmpty(one)){ + one ="joinDate0"; + }else{ + if(StringUtil.isEmpty(two)){ + two ="joinDate0"; + } + } + } + } + if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("string")))){//当前表字符串 + thisTable.put("string",String.valueOf(thisTable.get("string")).split(",")); + if(StringUtil.isEmpty(one)){ + one ="thisString0"; + }else{ + if(StringUtil.isEmpty(two)){ + two ="thisString0"; + } + } + } + if(isJoinTableFlag){//级联表字符串 + Map joinTable = (Map) params.get("joinTable"); + if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("string")))){ + joinTable.put("string",String.valueOf(joinTable.get("string")).split(",")); + if(StringUtil.isEmpty(one)){ + one ="joinString0"; + }else{ + if(StringUtil.isEmpty(two)){ + two ="joinString0"; + } + } + } + } + if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("types")))){//当前表类型 + thisTable.put("types",String.valueOf(thisTable.get("types")).split(",")); + if(StringUtil.isEmpty(one)){ + one ="thisTypes0"; + }else{ + if(StringUtil.isEmpty(two)){ + two ="thisTypes0"; + } + } + } + if(isJoinTableFlag){//级联表类型 + Map joinTable = (Map) params.get("joinTable"); + if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("types")))){ + joinTable.put("types",String.valueOf(joinTable.get("types")).split(",")); + if(StringUtil.isEmpty(one)){ + one ="joinTypes0"; + }else{ + if(StringUtil.isEmpty(two)){ + two ="joinTypes0"; + } + } + + } + } + + List> result = commonService.barCount(params); + + List xAxis = new ArrayList<>();//报表x轴 + List> yAxis = new ArrayList<>();//y轴 + List legend = new ArrayList<>();//标题 + + if(StringUtil.isEmpty(two)){//不包含第二列 + List yAxis0 = new ArrayList<>(); + yAxis.add(yAxis0); + legend.add("数值"); + for(Map map :result){ + String oneValue = String.valueOf(map.get(one)); + String value = String.valueOf(map.get("value")); + xAxis.add(oneValue); + yAxis0.add(value); + } + }else{//包含第二列 + Map> dataMap = new LinkedHashMap<>(); + if(StringUtil.isNotEmpty(two)){ + for(Map map :result){ + String oneValue = String.valueOf(map.get(one)); + String twoValue = String.valueOf(map.get(two)); + String value = String.valueOf(map.get("value")); + if(!legend.contains(twoValue)){ + legend.add(twoValue);//添加完成后 就是最全的第二列的类型 + } + if(dataMap.containsKey(oneValue)){ + dataMap.get(oneValue).put(twoValue,value); + }else{ + HashMap oneData = new HashMap<>(); + oneData.put(twoValue,value); + dataMap.put(oneValue,oneData); + } + + } + } + + for(int i =0; i()); + } + + Set keys = dataMap.keySet(); + for(String key:keys){ + xAxis.add(key); + HashMap map = dataMap.get(key); + for(int i =0; i data = yAxis.get(i); + if(StringUtil.isNotEmpty(map.get(legend.get(i)))){ + data.add(map.get(legend.get(i))); + }else{ + data.add("0"); + } + } + } + System.out.println(); + } + + Map resultMap = new HashMap<>(); + resultMap.put("xAxis",xAxis); + resultMap.put("yAxis",yAxis); + resultMap.put("legend",legend); + return R.ok().put("data", resultMap); + } +}