你çšcqq 2 months ago
commit 9f1631eaf0

@ -1,34 +1,63 @@
package com.controller;
ppackage com.controller;
import java.io.File; import java.io.File;
// 导入用于高精度十进制计算的类
import java.math.BigDecimal; import java.math.BigDecimal;
// 导入处理 URL 的类
import java.net.URL; import java.net.URL;
// 导入用于格式化日期的类
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
// 导入阿里巴巴的 JSON 处理类
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
// 导入常用的集合类
import java.util.*; import java.util.*;
// 导入 Spring 框架用于 Bean 属性复制的工具类
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
// 导入 Servlet 请求相关类
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
// 导入 Spring 上下文加载器类
import org.springframework.web.context.ContextLoader; import org.springframework.web.context.ContextLoader;
// 导入 Servlet 上下文类
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
// 导入自定义的 Token 服务类
import com.service.TokenService; import com.service.TokenService;
// 导入自定义的工具类包
import com.utils.*; import com.utils.*;
// 导入反射调用异常类
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
// 导入自定义的字典服务类
import com.service.DictionaryService; import com.service.DictionaryService;
// 导入 Apache Commons 提供的字符串工具类
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
// 导入自定义的忽略权限注解类
import com.annotation.IgnoreAuth; import com.annotation.IgnoreAuth;
// 导入日志记录器接口
import org.slf4j.Logger; import org.slf4j.Logger;
// 导入日志记录器工厂类
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
// 导入 Spring 的自动注入注解
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
// 导入 Spring 的控制器注解
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
// 导入 Spring 的请求映射注解
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
// 导入 MyBatis-Plus 的实体包装器类
import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.EntityWrapper;
// 导入 MyBatis-Plus 的查询包装器接口
import com.baomidou.mybatisplus.mapper.Wrapper; import com.baomidou.mybatisplus.mapper.Wrapper;
// 导入自定义的实体类包
import com.entity.*; import com.entity.*;
// 导入自定义的视图实体类包
import com.entity.view.*; import com.entity.view.*;
// 导入自定义的服务类包
import com.service.*; import com.service.*;
// 导入自定义的分页工具类
import com.utils.PageUtils; import com.utils.PageUtils;
// 导入自定义的响应结果类
import com.utils.R; import com.utils.R;
// 导入阿里巴巴的 JSON 处理类
import com.alibaba.fastjson.*; import com.alibaba.fastjson.*;
/** /**
@ -69,37 +98,36 @@ public class ChatController {
/** /**
* *
* 线 * 线
* * @param params Map
* @param params Map
* @param request HttpServletRequest * @param request HttpServletRequest
* @return R * @return R
*/ */
@RequestMapping("/page") @RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request) { public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
// 记录调试日志,输出方法名、控制器类名和请求参数 // 记录调试日志,输出方法名、控制器类名和请求参数
logger.debug("page方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params)); logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
// 获取当前用户的角色信息 // 获取当前用户的角色信息
String role = String.valueOf(request.getSession().getAttribute("role")); String role = String.valueOf(request.getSession().getAttribute("role"));
// 这个条件永远为 false这里的代码逻辑可能有误正常不会进入此分支 // 这个条件永远为 false这里的代码逻辑可能有误正常不会进入此分支
if (false) if(false)
return R.error(511, "永不会进入"); return R.error(511,"永不会进入");
// 如果用户角色是 "用户",则将用户 ID 添加到请求参数中 // 如果用户角色是 "用户",则将用户 ID 添加到请求参数中
else if ("用户".equals(role)) else if("用户".equals(role))
params.put("yonghuId", request.getSession().getAttribute("userId")); params.put("yonghuId",request.getSession().getAttribute("userId"));
// 如果用户角色是 "医生",则将医生 ID 添加到请求参数中 // 如果用户角色是 "医生",则将医生 ID 添加到请求参数中
else if ("医生".equals(role)) else if("医生".equals(role))
params.put("yishengId", request.getSession().getAttribute("userId")); params.put("yishengId",request.getSession().getAttribute("userId"));
// 如果请求参数中没有指定排序字段,则默认按 id 排序 // 如果请求参数中没有指定排序字段,则默认按 id 排序
if (params.get("orderBy") == null || params.get("orderBy") == "") { if(params.get("orderBy")==null || params.get("orderBy")==""){
params.put("orderBy", "id"); params.put("orderBy","id");
} }
// 调用 ChatService 的 queryPage 方法获取分页数据 // 调用 ChatService 的 queryPage 方法获取分页数据
PageUtils page = chatService.queryPage(params); PageUtils page = chatService.queryPage(params);
// 将分页数据中的列表转换为 ChatView 类型的列表 // 将分页数据中的列表转换为 ChatView 类型的列表
List<ChatView> list = (List<ChatView>) page.getList(); List<ChatView> list =(List<ChatView>)page.getList();
// 遍历列表,对每个 ChatView 对象进行字典表数据转换 // 遍历列表,对每个 ChatView 对象进行字典表数据转换
for (ChatView c : list) { for(ChatView c:list){
dictionaryService.dictionaryConvert(c, request); dictionaryService.dictionaryConvert(c, request);
} }
// 返回成功响应,并将分页数据封装在 data 属性中 // 返回成功响应,并将分页数据封装在 data 属性中
@ -109,29 +137,28 @@ public class ChatController {
/** /**
* *
* 线 * 线
* * @param id 线 ID
* @param id 线 ID
* @param request HttpServletRequest * @param request HttpServletRequest
* @return R * @return R
*/ */
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request) { public R info(@PathVariable("id") Long id, HttpServletRequest request){
// 记录调试日志,输出方法名、控制器类名和要查询的 ID // 记录调试日志,输出方法名、控制器类名和要查询的 ID
logger.debug("info方法:,,Controller:{},,id:{}", this.getClass().getName(), id); logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
// 根据 ID 查询在线咨询记录 // 根据 ID 查询在线咨询记录
ChatEntity chat = chatService.selectById(id); ChatEntity chat = chatService.selectById(id);
// 如果查询到记录 // 如果查询到记录
if (chat != null) { if(chat !=null){
// 将 ChatEntity 转换为 ChatView // 将 ChatEntity 转换为 ChatView
ChatView view = new ChatView(); ChatView view = new ChatView();
// 使用 BeanUtils 将 ChatEntity 的属性复制到 ChatView 中 // 使用 BeanUtils 将 ChatEntity 的属性复制到 ChatView 中
BeanUtils.copyProperties(chat, view); BeanUtils.copyProperties( chat , view );
// 级联查询用户信息 // 级联查询用户信息
YonghuEntity yonghu = yonghuService.selectById(chat.getYonghuId()); YonghuEntity yonghu = yonghuService.selectById(chat.getYonghuId());
// 如果查询到用户信息 // 如果查询到用户信息
if (yonghu != null) { if(yonghu != null){
// 将用户信息的部分属性复制到 ChatView 中,并排除指定字段 // 将用户信息的部分属性复制到 ChatView 中,并排除指定字段
BeanUtils.copyProperties(yonghu, view, new String[]{"id", "createTime", "insertTime", "updateTime"}); BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});
// 设置 ChatView 中的用户 ID // 设置 ChatView 中的用户 ID
view.setYonghuId(yonghu.getId()); view.setYonghuId(yonghu.getId());
} }
@ -140,9 +167,9 @@ public class ChatController {
dictionaryService.dictionaryConvert(view, request); dictionaryService.dictionaryConvert(view, request);
// 返回成功响应,并将处理后的 ChatView 数据封装在 data 属性中 // 返回成功响应,并将处理后的 ChatView 数据封装在 data 属性中
return R.ok().put("data", view); return R.ok().put("data", view);
} else { }else {
// 如果未查询到记录,返回错误响应 // 如果未查询到记录,返回错误响应
return R.error(511, "查不到数据"); return R.error(511,"查不到数据");
} }
} }
@ -150,23 +177,22 @@ public class ChatController {
/** /**
* *
* 线 * 线
* * @param chat 线
* @param chat 线
* @param request HttpServletRequest * @param request HttpServletRequest
* @return R * @return R
*/ */
@RequestMapping("/save") @RequestMapping("/save")
public R save(@RequestBody ChatEntity chat, HttpServletRequest request) { public R save(@RequestBody ChatEntity chat, HttpServletRequest request){
// 记录调试日志,输出方法名、控制器类名和要保存的 ChatEntity 对象 // 记录调试日志,输出方法名、控制器类名和要保存的 ChatEntity 对象
logger.debug("save方法:,,Controller:{},,chat:{}", this.getClass().getName(), chat.toString()); logger.debug("save方法:,,Controller:{},,chat:{}",this.getClass().getName(),chat.toString());
// 获取当前用户的角色信息 // 获取当前用户的角色信息
String role = String.valueOf(request.getSession().getAttribute("role")); String role = String.valueOf(request.getSession().getAttribute("role"));
// 这个条件永远为 false这里的代码逻辑可能有误正常不会进入此分支 // 这个条件永远为 false这里的代码逻辑可能有误正常不会进入此分支
if (false) if(false)
return R.error(511, "永远不会进入"); return R.error(511,"永远不会进入");
// 如果用户角色是 "用户",则设置在线咨询记录的用户 ID // 如果用户角色是 "用户",则设置在线咨询记录的用户 ID
else if ("用户".equals(role)) else if("用户".equals(role))
chat.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")))); chat.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
// 创建查询条件,检查是否已存在相同数据 // 创建查询条件,检查是否已存在相同数据
@ -178,35 +204,34 @@ public class ChatController {
.eq("chat_types", chat.getChatTypes()); .eq("chat_types", chat.getChatTypes());
// 记录查询条件的 SQL 片段日志 // 记录查询条件的 SQL 片段日志
logger.info("sql语句:" + queryWrapper.getSqlSegment()); logger.info("sql语句:"+queryWrapper.getSqlSegment());
// 根据查询条件查询是否已存在相同数据 // 根据查询条件查询是否已存在相同数据
ChatEntity chatEntity = chatService.selectOne(queryWrapper); ChatEntity chatEntity = chatService.selectOne(queryWrapper);
// 如果不存在相同数据 // 如果不存在相同数据
if (chatEntity == null) { if(chatEntity==null){
// 设置插入时间为当前时间 // 设置插入时间为当前时间
chat.setInsertTime(new Date()); chat.setInsertTime(new Date());
// 插入在线咨询记录 // 插入在线咨询记录
chatService.insert(chat); chatService.insert(chat);
// 返回成功响应 // 返回成功响应
return R.ok(); return R.ok();
} else { }else {
// 如果存在相同数据,返回错误响应 // 如果存在相同数据,返回错误响应
return R.error(511, "表中有相同数据"); return R.error(511,"表中有相同数据");
} }
} }
/** /**
* *
* 线 * 线
* * @param chat 线
* @param chat 线
* @param request HttpServletRequest * @param request HttpServletRequest
* @return R * @return R
*/ */
@RequestMapping("/update") @RequestMapping("/update")
public R update(@RequestBody ChatEntity chat, HttpServletRequest request) { public R update(@RequestBody ChatEntity chat, HttpServletRequest request){
// 记录调试日志,输出方法名、控制器类名和要修改的 ChatEntity 对象 // 记录调试日志,输出方法名、控制器类名和要修改的 ChatEntity 对象
logger.debug("update方法:,,Controller:{},,chat:{}", this.getClass().getName(), chat.toString()); logger.debug("update方法:,,Controller:{},,chat:{}",this.getClass().getName(),chat.toString());
// 获取当前用户的角色信息 // 获取当前用户的角色信息
String role = String.valueOf(request.getSession().getAttribute("role")); String role = String.valueOf(request.getSession().getAttribute("role"));
@ -217,7 +242,7 @@ public class ChatController {
// 创建查询条件,检查是否已存在相同数据(排除当前要修改的记录) // 创建查询条件,检查是否已存在相同数据(排除当前要修改的记录)
Wrapper<ChatEntity> queryWrapper = new EntityWrapper<ChatEntity>() Wrapper<ChatEntity> queryWrapper = new EntityWrapper<ChatEntity>()
.notIn("id", chat.getId()) .notIn("id",chat.getId())
.andNew() .andNew()
.eq("yonghu_id", chat.getYonghuId()) .eq("yonghu_id", chat.getYonghuId())
.eq("chat_issue", chat.getChatIssue()) .eq("chat_issue", chat.getChatIssue())
@ -226,32 +251,31 @@ public class ChatController {
.eq("chat_types", chat.getChatTypes()); .eq("chat_types", chat.getChatTypes());
// 记录查询条件的 SQL 片段日志 // 记录查询条件的 SQL 片段日志
logger.info("sql语句:" + queryWrapper.getSqlSegment()); logger.info("sql语句:"+queryWrapper.getSqlSegment());
// 根据查询条件查询是否已存在相同数据 // 根据查询条件查询是否已存在相同数据
ChatEntity chatEntity = chatService.selectOne(queryWrapper); ChatEntity chatEntity = chatService.selectOne(queryWrapper);
// 如果不存在相同数据 // 如果不存在相同数据
if (chatEntity == null) { if(chatEntity==null){
// 根据 ID 更新在线咨询记录 // 根据 ID 更新在线咨询记录
chatService.updateById(chat); chatService.updateById(chat);
// 返回成功响应 // 返回成功响应
return R.ok(); return R.ok();
} else { }else {
// 如果存在相同数据,返回错误响应 // 如果存在相同数据,返回错误响应
return R.error(511, "表中有相同数据"); return R.error(511,"表中有相同数据");
} }
} }
/** /**
* *
* 线 * 线
*
* @param ids 线 ID * @param ids 线 ID
* @return R * @return R
*/ */
@RequestMapping("/delete") @RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids) { public R delete(@RequestBody Integer[] ids){
// 记录调试日志,输出方法名、控制器类名和要删除的 ID 数组 // 记录调试日志,输出方法名、控制器类名和要删除的 ID 数组
logger.debug("delete:,,Controller:{},,ids:{}", this.getClass().getName(), ids.toString()); logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
// 批量删除在线咨询记录 // 批量删除在线咨询记录
chatService.deleteBatchIds(Arrays.asList(ids)); chatService.deleteBatchIds(Arrays.asList(ids));
// 返回成功响应 // 返回成功响应
@ -261,50 +285,49 @@ public class ChatController {
/** /**
* *
* 线 Excel * 线 Excel
*
* @param fileName Excel * @param fileName Excel
* @return R * @return R
*/ */
@RequestMapping("/batchInsert") @RequestMapping("/batchInsert")
public R save(String fileName) { public R save( String fileName){
// 记录调试日志,输出方法名、控制器类名和文件名 // 记录调试日志,输出方法名、控制器类名和文件名
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}", this.getClass().getName(), fileName); logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
try { try {
// 创建用于存储上传的在线咨询实体对象的列表 // 创建用于存储上传的在线咨询实体对象的列表
List<ChatEntity> chatList = new ArrayList<>(); List<ChatEntity> chatList = new ArrayList<>();
// 创建用于存储要查询的字段的 Map // 创建用于存储要查询的字段的 Map
Map<String, List<String>> seachFields = new HashMap<>(); Map<String, List<String>> seachFields= new HashMap<>();
// 获取当前时间 // 获取当前时间
Date date = new Date(); Date date = new Date();
// 获取文件名的后缀位置 // 获取文件名的后缀位置
int lastIndexOf = fileName.lastIndexOf("."); int lastIndexOf = fileName.lastIndexOf(".");
// 如果没有找到后缀 // 如果没有找到后缀
if (lastIndexOf == -1) { if(lastIndexOf == -1){
// 返回错误响应,提示文件没有后缀 // 返回错误响应,提示文件没有后缀
return R.error(511, "该文件没有后缀"); return R.error(511,"该文件没有后缀");
} else { }else{
// 获取文件后缀 // 获取文件后缀
String suffix = fileName.substring(lastIndexOf); String suffix = fileName.substring(lastIndexOf);
// 如果后缀不是.xls // 如果后缀不是.xls
if (!".xls".equals(suffix)) { if(!".xls".equals(suffix)){
// 返回错误响应,提示只支持.xls 后缀的 Excel 文件 // 返回错误响应,提示只支持.xls 后缀的 Excel 文件
return R.error(511, "只支持后缀为xls的excel文件"); return R.error(511,"只支持后缀为xls的excel文件");
} else { }else{
// 获取文件的 URL // 获取文件的 URL
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName); URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);
// 创建文件对象 // 创建文件对象
File file = new File(resource.getFile()); File file = new File(resource.getFile());
// 如果文件不存在 // 如果文件不存在
if (!file.exists()) { if(!file.exists()){
// 返回错误响应,提示找不到上传文件 // 返回错误响应,提示找不到上传文件
return R.error(511, "找不到上传文件,请联系管理员"); return R.error(511,"找不到上传文件,请联系管理员");
} else { }else{
// 从 Excel 文件中读取数据 // 从 Excel 文件中读取数据
List<List<String>> dataList = PoiUtil.poiImport(file.getPath()); List<List<String>> dataList = PoiUtil.poiImport(file.getPath());
// 删除第一行(通常是表头) // 删除第一行(通常是表头)
dataList.remove(0); dataList.remove(0);
// 遍历数据列表 // 遍历数据列表
for (List<String> data : dataList) { for(List<String> data:dataList){
// 创建在线咨询实体对象 // 创建在线咨询实体对象
ChatEntity chatEntity = new ChatEntity(); ChatEntity chatEntity = new ChatEntity();
@ -320,35 +343,34 @@ public class ChatController {
} }
} }
} }
} catch (Exception e) { }catch (Exception e){
// 如果发生异常,返回错误响应,提示批量插入数据异常 // 如果发生异常,返回错误响应,提示批量插入数据异常
return R.error(511, "批量插入数据异常,请联系管理员"); return R.error(511,"批量插入数据异常,请联系管理员");
} }
} }
/** /**
* *
* 线 * 线
* * @param params Map
* @param params Map
* @param request HttpServletRequest * @param request HttpServletRequest
* @return R * @return R
*/ */
@IgnoreAuth @IgnoreAuth
@RequestMapping("/list") @RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request) { public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
// 记录调试日志,输出方法名、控制器类名和请求参数 // 记录调试日志,输出方法名、控制器类名和请求参数
logger.debug("list方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params)); logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
// 如果没有指定排序字段,就默认按 id 倒序排序 // 如果没有指定排序字段,就默认按 id 倒序排序
if (StringUtil.isEmpty(String.valueOf(params.get("orderBy")))) { if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
params.put("orderBy", "id"); params.put("orderBy","id");
} }
// 调用 ChatService 的 queryPage 方法获取分页数据 // 调用 ChatService 的 queryPage 方法获取分页数据
PageUtils page = chatService.queryPage(params); PageUtils page = chatService.queryPage(params);
// 将分页数据中的列表转换为 ChatView 类型的列表 // 将分页数据中的列表转换为 ChatView 类型的列表
List<ChatView> list = (List<ChatView>) page.getList(); List<ChatView> list =(List<ChatView>)page.getList();
// 遍历列表,对每个 ChatView 对象进行字典表数据转换 // 遍历列表,对每个 ChatView 对象进行字典表数据转换
for (ChatView c : list) for(ChatView c:list)
dictionaryService.dictionaryConvert(c, request); dictionaryService.dictionaryConvert(c, request);
// 返回成功响应,并将分页数据封装在 data 属性中 // 返回成功响应,并将分页数据封装在 data 属性中
return R.ok().put("data", page); return R.ok().put("data", page);
@ -357,30 +379,29 @@ public class ChatController {
/** /**
* *
* 线 * 线
* * @param id 线 ID
* @param id 线 ID
* @param request HttpServletRequest * @param request HttpServletRequest
* @return R * @return R
*/ */
@RequestMapping("/detail/{id}") @RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id, HttpServletRequest request) { public R detail(@PathVariable("id") Long id, HttpServletRequest request){
// 记录调试日志,输出方法名、控制器类名和要查询的 ID // 记录调试日志,输出方法名、控制器类名和要查询的 ID
logger.debug("detail方法:,,Controller:{},,id:{}", this.getClass().getName(), id); logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
// 根据 ID 查询在线咨询记录 // 根据 ID 查询在线咨询记录
ChatEntity chat = chatService.selectById(id); ChatEntity chat = chatService.selectById(id);
// 如果查询到记录 // 如果查询到记录
if (chat != null) { if(chat !=null){
// 将 ChatEntity 转换为 ChatView // 将 ChatEntity 转换为 ChatView
ChatView view = new ChatView(); ChatView view = new ChatView();
// 使用 BeanUtils 将 ChatEntity 的属性复制到 ChatView 中 // 使用 BeanUtils 将 ChatEntity 的属性复制到 ChatView 中
BeanUtils.copyProperties(chat, view); BeanUtils.copyProperties( chat , view );
// 级联查询用户信息 // 级联查询用户信息
YonghuEntity yonghu = yonghuService.selectById(chat.getYonghuId()); YonghuEntity yonghu = yonghuService.selectById(chat.getYonghuId());
// 如果查询到用户信息 // 如果查询到用户信息
if (yonghu != null) { if(yonghu != null){
// 将用户信息的部分属性复制到 ChatView 中,并排除指定字段 // 将用户信息的部分属性复制到 ChatView 中,并排除指定字段
BeanUtils.copyProperties(yonghu, view, new String[]{"id", "createDate"}); BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});
// 设置 ChatView 中的用户 ID // 设置 ChatView 中的用户 ID
view.setYonghuId(yonghu.getId()); view.setYonghuId(yonghu.getId());
} }
@ -389,10 +410,10 @@ public class ChatController {
dictionaryService.dictionaryConvert(view, request); dictionaryService.dictionaryConvert(view, request);
// 返回成功响应,并将处理后的 ChatView 数据封装在 data 属性中 // 返回成功响应,并将处理后的 ChatView 数据封装在 data 属性中
return R.ok().put("data", view); return R.ok().put("data", view);
} else { }else {
// 如果未查询到记录,返回错误响应 // 如果未查询到记录,返回错误响应
return R.error(511, "查不到数据"); return R.error(511,"查不到数据");
} }
} }
}
/**

@ -39,26 +39,19 @@ import com.utils.R;
* *
*/ */
@RestController @RestController
public class CommonController { public class CommonController{
// 用于记录日志
private static final Logger logger = LoggerFactory.getLogger(CommonController.class); private static final Logger logger = LoggerFactory.getLogger(CommonController.class);
// 注入CommonService处理通用业务逻辑 // 注入CommonService处理通用业务逻辑
@Autowired @Autowired
private CommonService commonService; private CommonService commonService;
// 注入ConfigService用于配置信息的操作
@Autowired @Autowired
private ConfigService configService; private ConfigService configService;
// 百度人脸识别客户端
private static AipFace client = null; private static AipFace client = null;
// 百度地图AKAccess Key
private static String BAIDU_DITU_AK = null; private static String BAIDU_DITU_AK = null;
/**
*
* @param lng
* @param lat
* @return
*/
@RequestMapping("/location") @RequestMapping("/location")
public R location(String lng, String lat) { public R location(String lng, String lat) {
// 如果BAIDU_DITU_AK为空从配置中获取 // 如果BAIDU_DITU_AK为空从配置中获取
@ -128,8 +121,7 @@ public class CommonController {
} catch (IOException e) { } catch (IOException e) {
// 处理IO异常 // 处理IO异常
e.printStackTrace(); e.printStackTrace();
} }
// 返回包含比对结果的数据对象
return R.ok().put("data", com.alibaba.fastjson.JSONObject.parse(res.get("result").toString())); return R.ok().put("data", com.alibaba.fastjson.JSONObject.parse(res.get("result").toString()));
} }
@ -209,16 +201,13 @@ public class CommonController {
*/ */
@RequestMapping("/remind/{tableName}/{columnName}/{type}") @RequestMapping("/remind/{tableName}/{columnName}/{type}")
@IgnoreAuth @IgnoreAuth
public R remindCount(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, public R remindCount(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,
@PathVariable("type") String type, @RequestParam Map<String, Object> map) { @PathVariable("type") String type,@RequestParam Map<String, Object> map) {
// 将表名、列名、类型添加到参数Map中
map.put("table", tableName); map.put("table", tableName);
map.put("column", columnName); map.put("column", columnName);
map.put("type", type); map.put("type", type);
// 如果类型为日期 if(type.equals("2")) {
if (type.equals("2")) {
// 创建日期格式化对象
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// 获取当前日期 // 获取当前日期
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
@ -228,10 +217,8 @@ public class CommonController {
if (map.get("remindstart") != null) { if (map.get("remindstart") != null) {
// 解析提醒开始日期偏移量 // 解析提醒开始日期偏移量
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
// 设置日期 c.setTime(new Date());
c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH,remindStart);
// 计算提醒开始日期
c.add(Calendar.DAY_OF_MONTH, remindStart);
remindStartDate = c.getTime(); remindStartDate = c.getTime();
// 将提醒开始日期格式化后添加到参数Map中 // 将提醒开始日期格式化后添加到参数Map中
map.put("remindstart", sdf.format(remindStartDate)); map.put("remindstart", sdf.format(remindStartDate));
@ -249,7 +236,7 @@ public class CommonController {
map.put("remindend", sdf.format(remindEndDate)); map.put("remindend", sdf.format(remindEndDate));
} }
} }
// 调用CommonService获取提醒记录数
int count = commonService.remindCount(map); int count = commonService.remindCount(map);
// 返回包含提醒记录数的结果对象 // 返回包含提醒记录数的结果对象
return R.ok().put("count", count); return R.ok().put("count", count);
@ -347,20 +334,21 @@ public class CommonController {
} }
/** /**
* tableName
* @param params Map condition1 1
* @return condition1Value 1
*/ average
@IgnoreAuth
@RequestMapping("/queryScore") Number(res.data.value.toFixed(1))
public R queryScore(@RequestParam Map<String, Object> params) { if(res.data){}
// 记录日志 * */
logger.debug("queryScore:,,Controller:{},,params:{}", this.getClass().getName(), params); @IgnoreAuth
// 调用CommonService查询平均评分 @RequestMapping("/queryScore")
Map<String, Object> queryScore = commonService.queryScore(params); public R queryScore(@RequestParam Map<String, Object> params) {
// 返回包含平均评分结果的结果对象 logger.debug("queryScore:,,Controller:{},,params:{}",this.getClass().getName(),params);
return R.ok().put("data", queryScore); Map<String, Object> queryScore = commonService.queryScore(params);
} return R.ok().put("data", queryScore);
}
/** /**
* *
@ -433,33 +421,28 @@ public class CommonController {
return R.ok().put("data", result); return R.ok().put("data", result);
} }
/** /**
* *
* @param params Map */
* @return @RequestMapping("/barSum")
*/ public R barSum(@RequestParam Map<String,Object> params) {
@RequestMapping("/barSum") logger.debug("barSum方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params));
public R barSum(@RequestParam Map<String, Object> params) { Boolean isJoinTableFlag = false;//是否有级联表相关
// 记录日志 String one = "";//第一优先
logger.debug("barSum方法:,,Controller:{},,params:{}", this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params)); String two = "";//第二优先
// 是否有级联表相关
Boolean isJoinTableFlag = false; //处理thisTable和joinTable 处理内容是把json字符串转为Map并把带有,的切割为数组
// 第一优先 //当前表
String one = ""; Map<String,Object> thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class);
// 第二优先 params.put("thisTable",thisTable);
String two = "";
//级联表
// 处理当前表 String joinTableString = String.valueOf(params.get("joinTable"));
Map<String, Object> thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")), Map.class); if(StringUtil.isNotEmpty(joinTableString)) {
params.put("thisTable", thisTable); Map<String, Object> joinTable = JSON.parseObject(joinTableString, Map.class);
params.put("joinTable", joinTable);
// 处理级联表 isJoinTableFlag = true;
String joinTableString = String.valueOf(params.get("joinTable")); }
if (StringUtil.isNotEmpty(joinTableString)) {
Map<String, Object> joinTable = JSON.parseObject(joinTableString, Map.class);
params.put("joinTable", joinTable);
isJoinTableFlag = true;
}
// 处理当前表日期 // 处理当前表日期
if (StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))) { if (StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))) {
@ -603,32 +586,27 @@ public class CommonController {
} }
/** /**
* *
* @param params Map */
* @return @RequestMapping("/barCount")
*/ public R barCount(@RequestParam Map<String,Object> params) {
@RequestMapping("/barCount") logger.debug("barCount方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params));
public R barCount(@RequestParam Map<String, Object> params) { Boolean isJoinTableFlag = false;//是否有级联表相关
// 记录日志 String one = "";//第一优先
logger.debug("barCount方法:,,Controller:{},,params:{}", this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params)); String two = "";//第二优先
// 是否有级联表相关
Boolean isJoinTableFlag = false; //处理thisTable和joinTable 处理内容是把json字符串转为Map并把带有,的切割为数组
// 第一优先 //当前表
String one = ""; Map<String,Object> thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class);
// 第二优先 params.put("thisTable",thisTable);
String two = "";
//级联表
// 处理当前表 String joinTableString = String.valueOf(params.get("joinTable"));
Map<String, Object> thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")), Map.class); if(StringUtil.isNotEmpty(joinTableString)) {
params.put("thisTable", thisTable); Map<String, Object> joinTable = JSON.parseObject(joinTableString, Map.class);
params.put("joinTable", joinTable);
// 处理级联表 isJoinTableFlag = true;
String joinTableString = String.valueOf(params.get("joinTable")); }
if (StringUtil.isNotEmpty(joinTableString)) {
Map<String, Object> joinTable = JSON.parseObject(joinTableString, Map.class);
params.put("joinTable", joinTable);
isJoinTableFlag = true;
}
// 处理当前表日期 // 处理当前表日期
if (StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))) { if (StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))) {

@ -1,111 +1,156 @@
package com.controller; package com.controller;
// 导入用于操作数组的工具类
import java.util.Arrays; import java.util.Arrays;
// 导入Map接口用于存储键值对
import java.util.Map; import java.util.Map;
// 导入Spring的自动注入注解
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
// 导入Spring的路径变量注解用于从URL中获取参数
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
// 导入Spring的POST请求映射注解
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
// 导入Spring的请求体注解用于获取请求体中的数据
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
// 导入Spring的请求映射注解用于映射请求路径
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
// 导入Spring的请求参数注解用于获取请求参数
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
// 导入Spring的RESTful控制器注解
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
// 导入自定义的忽略权限验证注解
import com.annotation.IgnoreAuth; import com.annotation.IgnoreAuth;
// 导入MyBatis-Plus的实体包装器类用于构建查询条件
import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.EntityWrapper;
// 导入配置实体类
import com.entity.ConfigEntity; import com.entity.ConfigEntity;
// 导入配置服务接口
import com.service.ConfigService; import com.service.ConfigService;
// 导入分页工具类
import com.utils.PageUtils; import com.utils.PageUtils;
// 导入自定义的响应结果类
import com.utils.R; import com.utils.R;
// 导入自定义的验证工具类
import com.utils.ValidatorUtils; import com.utils.ValidatorUtils;
/** /**
* *
*/ */
// 映射请求路径,所有以/config开头的请求都会由该控制器处理
@RequestMapping("config") @RequestMapping("config")
// 声明该类为RESTful控制器
@RestController @RestController
public class ConfigController{ public class ConfigController {
@Autowired // 自动注入配置服务接口的实现类实例
private ConfigService configService; @Autowired
private ConfigService configService;
/** /**
* *
*/ */
// 映射/page请求路径支持GET请求
@RequestMapping("/page") @RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,ConfigEntity config){ public R page(@RequestParam Map<String, Object> params, ConfigEntity config) {
// 创建一个EntityWrapper对象用于构建查询条件
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>();
PageUtils page = configService.queryPage(params); // 调用配置服务的queryPage方法根据请求参数进行分页查询
PageUtils page = configService.queryPage(params);
// 返回成功响应,并将分页查询结果放入响应数据中
return R.ok().put("data", page); return R.ok().put("data", page);
} }
/** /**
* *
*/ */
// 映射/list请求路径支持GET请求且忽略权限验证
@IgnoreAuth @IgnoreAuth
@RequestMapping("/list") @RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,ConfigEntity config){ public R list(@RequestParam Map<String, Object> params, ConfigEntity config) {
// 创建一个EntityWrapper对象用于构建查询条件
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>();
PageUtils page = configService.queryPage(params); // 调用配置服务的queryPage方法根据请求参数进行分页查询
PageUtils page = configService.queryPage(params);
// 返回成功响应,并将分页查询结果放入响应数据中
return R.ok().put("data", page); return R.ok().put("data", page);
} }
/** /**
* *
*/ */
// 映射/info/{id}请求路径支持GET请求{id}为路径变量
@RequestMapping("/info/{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); ConfigEntity config = configService.selectById(id);
// 返回成功响应,并将查询到的配置信息放入响应数据中
return R.ok().put("data", config); return R.ok().put("data", config);
} }
/** /**
* *
*/ */
// 映射/detail/{id}请求路径支持GET请求{id}为路径变量,且忽略权限验证
@IgnoreAuth @IgnoreAuth
@RequestMapping("/detail/{id}") @RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") String id){ public R detail(@PathVariable("id") String id) {
// 调用配置服务的selectById方法根据ID查询配置信息
ConfigEntity config = configService.selectById(id); ConfigEntity config = configService.selectById(id);
// 返回成功响应,并将查询到的配置信息放入响应数据中
return R.ok().put("data", config); return R.ok().put("data", config);
} }
/** /**
* name * name
*/ */
// 映射/info请求路径支持GET请求
@RequestMapping("/info") @RequestMapping("/info")
public R infoByName(@RequestParam String name){ public R infoByName(@RequestParam String name) {
// 调用配置服务的selectOne方法根据名称查询配置信息
ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
// 返回成功响应,并将查询到的配置信息放入响应数据中
return R.ok().put("data", config); return R.ok().put("data", config);
} }
/** /**
* *
*/ */
// 映射/save请求路径支持POST请求
@PostMapping("/save") @PostMapping("/save")
public R save(@RequestBody ConfigEntity config){ public R save(@RequestBody ConfigEntity config) {
// 注释掉的代码,原本用于验证实体数据的合法性
// ValidatorUtils.validateEntity(config); // ValidatorUtils.validateEntity(config);
configService.insert(config); // 调用配置服务的insert方法将配置信息插入数据库
configService.insert(config);
// 返回成功响应
return R.ok(); return R.ok();
} }
/** /**
* *
*/ */
// 映射/update请求路径支持GET或POST请求
@RequestMapping("/update") @RequestMapping("/update")
public R update(@RequestBody ConfigEntity config){ public R update(@RequestBody ConfigEntity config) {
// 注释掉的代码,原本用于验证实体数据的合法性
// ValidatorUtils.validateEntity(config); // ValidatorUtils.validateEntity(config);
configService.updateById(config);//全部更新 // 调用配置服务的updateById方法根据ID更新配置信息全部字段更新
configService.updateById(config);
// 返回成功响应
return R.ok(); return R.ok();
} }
/** /**
* *
*/ */
// 映射/delete请求路径支持GET或POST请求
@RequestMapping("/delete") @RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){ public R delete(@RequestBody Long[] ids) {
configService.deleteBatchIds(Arrays.asList(ids)); // 调用配置服务的deleteBatchIds方法根据ID数组批量删除配置信息
configService.deleteBatchIds(Arrays.asList(ids));
// 返回成功响应
return R.ok(); return R.ok();
} }
} }

@ -1,35 +1,62 @@
package com.controller; package com.controller;
// 导入文件操作类
import java.io.File; import java.io.File;
// 导入用于高精度计算的类
import java.math.BigDecimal; import java.math.BigDecimal;
// 导入用于处理URL的类
import java.net.URL; import java.net.URL;
// 导入用于日期格式化的类
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
// 导入阿里巴巴的JSON对象类
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
// 导入常用的集合类
import java.util.*; import java.util.*;
// 导入Spring的Bean属性复制工具类
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
// 导入Servlet请求相关类
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
// 导入Spring的上下文加载器类
import org.springframework.web.context.ContextLoader; import org.springframework.web.context.ContextLoader;
// 导入Servlet上下文类
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
// 导入令牌服务类
import com.service.TokenService; import com.service.TokenService;
// 导入自定义工具类
import com.utils.*; import com.utils.*;
// 导入反射调用异常类
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
// 导入字典服务类
import com.service.DictionaryService; import com.service.DictionaryService;
// 导入Apache Commons提供的字符串工具类
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
// 导入自定义的忽略权限注解类
import com.annotation.IgnoreAuth; import com.annotation.IgnoreAuth;
// 导入日志记录器接口
import org.slf4j.Logger; import org.slf4j.Logger;
// 导入日志记录器工厂类
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
// 导入Spring的自动注入注解
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
// 导入Spring的控制器注解
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
// 导入Spring的请求映射注解
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
// 导入MyBatis-Plus的实体包装器类
import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.EntityWrapper;
// 导入MyBatis-Plus的查询包装器接口
import com.baomidou.mybatisplus.mapper.Wrapper; import com.baomidou.mybatisplus.mapper.Wrapper;
// 导入自定义的实体类
import com.entity.*; import com.entity.*;
// 导入自定义的视图类
import com.entity.view.*; import com.entity.view.*;
// 导入自定义的服务类
import com.service.*; import com.service.*;
// 导入自定义的分页工具类
import com.utils.PageUtils; import com.utils.PageUtils;
// 导入自定义的响应结果类
import com.utils.R; import com.utils.R;
// 导入阿里巴巴的JSON工具类
import com.alibaba.fastjson.*; import com.alibaba.fastjson.*;
/** /**
@ -37,214 +64,284 @@ import com.alibaba.fastjson.*;
* *
* @author * @author
* @email * @email
*/ */
// 声明该类为RESTful控制器
@RestController @RestController
// 声明该类为控制器
@Controller @Controller
// 映射请求路径,所有以/dictionary开头的请求都会由该控制器处理
@RequestMapping("/dictionary") @RequestMapping("/dictionary")
public class DictionaryController { public class DictionaryController {
// 日志记录器,用于记录当前控制器类的日志信息
private static final Logger logger = LoggerFactory.getLogger(DictionaryController.class); private static final Logger logger = LoggerFactory.getLogger(DictionaryController.class);
@Autowired // 此处注解有误,应为@Autowired自动注入用户服务类
private DictionaryService dictionaryService; @Autow
@Autowired
private TokenService tokenService;
//级联表service
@Autowired
private YonghuService yonghuService; private YonghuService yonghuService;
// 自动注入医生服务类
@Autowired @Autowired
private YishengService yishengService; private YishengService yishengService;
/** /**
* *
*/ */
// 映射/page请求路径支持GET请求且忽略权限验证
@RequestMapping("/page") @RequestMapping("/page")
@IgnoreAuth @IgnoreAuth
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){ public R page(@RequestParam Map<String, Object> params, HttpServletRequest request) {
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); // 记录方法调用日志,包含控制器类名和请求参数
if(params.get("orderBy")==null || params.get("orderBy")==""){ logger.debug("page方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params));
params.put("orderBy","id"); // 如果请求参数中没有指定排序字段则默认按id排序
if (params.get("orderBy") == null || params.get("orderBy") == "") {
params.put("orderBy", "id");
} }
// 调用字典服务的queryPage方法根据请求参数进行分页查询
PageUtils page = dictionaryService.queryPage(params); PageUtils page = dictionaryService.queryPage(params);
//字典表数据转换 // 将分页结果中的列表转换为字典视图列表
List<DictionaryView> list =(List<DictionaryView>)page.getList(); List<DictionaryView> list = (List<DictionaryView>) page.getList();
for(DictionaryView c:list){ // 遍历字典视图列表
//修改对应字典表字段 for (DictionaryView c : list) {
// 调用字典服务的dictionaryConvert方法修改对应字典表字段
dictionaryService.dictionaryConvert(c, request); dictionaryService.dictionaryConvert(c, request);
} }
// 返回成功响应,并将分页查询结果放入响应数据中
return R.ok().put("data", page); return R.ok().put("data", page);
} }
/** /**
* *
*/ */
// 映射/info/{id}请求路径支持GET请求{id}为路径变量
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){ public R info(@PathVariable("id") Long id, HttpServletRequest request) {
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录方法调用日志包含控制器类名和请求的id
logger.debug("info方法:,,Controller:{},,id:{}", this.getClass().getName(), id);
// 调用字典服务的selectById方法根据id查询字典实体
DictionaryEntity dictionary = dictionaryService.selectById(id); DictionaryEntity dictionary = dictionaryService.selectById(id);
if(dictionary !=null){ // 如果查询到字典实体
//entity转view if (dictionary != null) {
// 创建字典视图对象
DictionaryView view = new DictionaryView(); DictionaryView view = new DictionaryView();
BeanUtils.copyProperties( dictionary , view );//把实体数据重构到view // 使用BeanUtils将字典实体的属性复制到字典视图
BeanUtils.copyProperties(dictionary, view);
//修改对应字典表字段 // 调用字典服务的dictionaryConvert方法修改对应字典表字段
dictionaryService.dictionaryConvert(view, request); dictionaryService.dictionaryConvert(view, request);
// 返回成功响应,并将字典视图对象放入响应数据中
return R.ok().put("data", view); return R.ok().put("data", view);
}else { } else {
return R.error(511,"查不到数据"); // 如果未查询到数据返回错误响应错误码为511
return R.error(511, "查不到数据");
} }
} }
/** /**
* *
*/ */
// 映射/save请求路径支持POST请求
@RequestMapping("/save") @RequestMapping("/save")
public R save(@RequestBody DictionaryEntity dictionary, HttpServletRequest request){ public R save(@RequestBody DictionaryEntity dictionary, HttpServletRequest request) {
logger.debug("save方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString()); // 记录方法调用日志,包含控制器类名和要保存的字典实体信息
logger.debug("save方法:,,Controller:{},,dictionary:{}", this.getClass().getName(), dictionary.toString());
// 从请求会话中获取用户角色
String role = String.valueOf(request.getSession().getAttribute("role")); String role = String.valueOf(request.getSession().getAttribute("role"));
if(false) // 此条件永远为false注释掉的代码表示永远不会进入该分支
return R.error(511,"永远不会进入"); if (false)
return R.error(511, "永远不会进入");
// 创建查询包装器,用于构建查询条件
Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>() Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
.eq("dic_code", dictionary.getDicCode()) .eq("dic_code", dictionary.getDicCode())
.eq("index_name", dictionary.getIndexName()) .eq("index_name", dictionary.getIndexName());
; // 如果字典代码包含_erji_types则添加super_id的查询条件
if(dictionary.getDicCode().contains("_erji_types")){ if (dictionary.getDicCode().contains("_erji_types")) {
queryWrapper.eq("super_id",dictionary.getSuperId()); queryWrapper.eq("super_id", dictionary.getSuperId());
} }
// 记录生成的SQL查询语句
logger.info("sql语句:"+queryWrapper.getSqlSegment()); logger.info("sql语句:" + queryWrapper.getSqlSegment());
// 调用字典服务的selectOne方法根据查询条件查询是否存在相同数据
DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper); DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper);
if(dictionaryEntity==null){ // 如果未查询到相同数据
if (dictionaryEntity == null) {
// 设置字典实体的创建时间为当前时间
dictionary.setCreateTime(new Date()); dictionary.setCreateTime(new Date());
// 调用字典服务的insert方法将字典实体插入数据库
dictionaryService.insert(dictionary); dictionaryService.insert(dictionary);
//字典表新增数据,把数据再重新查出,放入监听器中 // 查询所有字典实体
List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>()); List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
// 获取Servlet上下文
ServletContext servletContext = request.getServletContext(); ServletContext servletContext = request.getServletContext();
Map<String, Map<Integer,String>> map = new HashMap<>(); // 创建一个Map用于存储字典数据
for(DictionaryEntity d :dictionaryEntities){ Map<String, Map<Integer, String>> map = new HashMap<>();
// 遍历所有字典实体
for (DictionaryEntity d : dictionaryEntities) {
// 获取当前字典代码对应的子Map
Map<Integer, String> m = map.get(d.getDicCode()); Map<Integer, String> m = map.get(d.getDicCode());
if(m ==null || m.isEmpty()){ // 如果子Map为空则创建一个新的子Map
if (m == null || m.isEmpty()) {
m = new HashMap<>(); m = new HashMap<>();
} }
m.put(d.getCodeIndex(),d.getIndexName()); // 将当前字典实体的代码索引和索引名称存入子Map
map.put(d.getDicCode(),m); 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(); return R.ok();
}else { } else {
return R.error(511,"表中有相同数据"); // 如果查询到相同数据返回错误响应错误码为511
return R.error(511, "表中有相同数据");
} }
} }
/** /**
* *
*/ */
// 映射/update请求路径支持POST请求
@RequestMapping("/update") @RequestMapping("/update")
public R update(@RequestBody DictionaryEntity dictionary, HttpServletRequest request){ public R update(@RequestBody DictionaryEntity dictionary, HttpServletRequest request) {
logger.debug("update方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString()); // 记录方法调用日志,包含控制器类名和要修改的字典实体信息
logger.debug("update方法:,,Controller:{},,dictionary:{}", this.getClass().getName(), dictionary.toString());
// 从请求会话中获取用户角色
String role = String.valueOf(request.getSession().getAttribute("role")); String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false) // 此条件注释掉,表示永远不会进入该分支
// return R.error(511,"永远不会进入"); // if (false)
//根据字段查询是否有相同数据 // return R.error(511, "永远不会进入");
// 创建查询包装器,用于构建查询条件,排除当前要修改的记录
Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>() Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
.notIn("id",dictionary.getId()) .notIn("id", dictionary.getId())
.eq("dic_code", dictionary.getDicCode()) .eq("dic_code", dictionary.getDicCode())
.eq("index_name", dictionary.getIndexName()) .eq("index_name", dictionary.getIndexName());
; // 如果字典代码包含_erji_types则添加super_id的查询条件
if (dictionary.getDicCode().contains("_erji_types")) {
if(dictionary.getDicCode().contains("_erji_types")){ queryWrapper.eq("super_id", dictionary.getSuperId());
queryWrapper.eq("super_id",dictionary.getSuperId());
} }
logger.info("sql语句:"+queryWrapper.getSqlSegment()); // 记录生成的SQL查询语句
logger.info("sql语句:" + queryWrapper.getSqlSegment());
// 调用字典服务的selectOne方法根据查询条件查询是否存在相同数据
DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper); DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper);
if(dictionaryEntity==null){ // 如果未查询到相同数据
dictionaryService.updateById(dictionary);//根据id更新 if (dictionaryEntity == null) {
//如果字典表修改数据的话,把数据再重新查出,放入监听器中 // 调用字典服务的updateById方法根据id更新字典实体
dictionaryService.updateById(dictionary);
// 查询所有字典实体
List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>()); List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
// 获取Servlet上下文
ServletContext servletContext = request.getServletContext(); ServletContext servletContext = request.getServletContext();
Map<String, Map<Integer,String>> map = new HashMap<>(); // 创建一个Map用于存储字典数据
for(DictionaryEntity d :dictionaryEntities){ Map<String, Map<Integer, String>> map = new HashMap<>();
// 遍历所有字典实体
for (DictionaryEntity d : dictionaryEntities) {
// 获取当前字典代码对应的子Map
Map<Integer, String> m = map.get(d.getDicCode()); Map<Integer, String> m = map.get(d.getDicCode());
if(m ==null || m.isEmpty()){ // 如果子Map为空则创建一个新的子Map
if (m == null || m.isEmpty()) {
m = new HashMap<>(); m = new HashMap<>();
} }
m.put(d.getCodeIndex(),d.getIndexName()); // 将当前字典实体的代码索引和索引名称存入子Map
map.put(d.getDicCode(),m); 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(); return R.ok();
}else { } else {
return R.error(511,"表中有相同数据"); // 如果查询到相同数据返回错误响应错误码为511
return R.error(511, "表中有相同数据");
} }
} }
/** /**
* *
*/ */
// 映射/delete请求路径支持POST请求
@RequestMapping("/delete") @RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){ public R delete(@RequestBody Integer[] ids) {
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); // 记录方法调用日志包含控制器类名和要删除的记录id数组
logger.debug("delete:,,Controller:{},,ids:{}", this.getClass().getName(), ids.toString());
// 调用字典服务的deleteBatchIds方法根据id数组批量删除记录
dictionaryService.deleteBatchIds(Arrays.asList(ids)); dictionaryService.deleteBatchIds(Arrays.asList(ids));
// 返回成功响应
return R.ok(); return R.ok();
} }
/** /**
* *
*/ */
// 映射/maxCodeIndex请求路径支持POST请求
@RequestMapping("/maxCodeIndex") @RequestMapping("/maxCodeIndex")
public R maxCodeIndex(@RequestBody DictionaryEntity dictionary){ public R maxCodeIndex(@RequestBody DictionaryEntity dictionary) {
logger.debug("maxCodeIndex:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString()); // 记录方法调用日志,包含控制器类名和传入的字典实体信息
logger.debug("maxCodeIndex:,,Controller:{},,dictionary:{}", this.getClass().getName(), dictionary.toString());
// 创建一个列表,用于存储排序字段
List<String> descs = new ArrayList<>(); List<String> descs = new ArrayList<>();
// 添加按code_index降序排序的字段
descs.add("code_index"); descs.add("code_index");
// 创建查询包装器,用于构建查询条件
Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>() Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
.eq("dic_code", dictionary.getDicCode()) .eq("dic_code", dictionary.getDicCode())
.orderDesc(descs); .orderDesc(descs);
logger.info("sql语句:"+queryWrapper.getSqlSegment()); // 记录生成的SQL查询语句
logger.info("sql语句:" + queryWrapper.getSqlSegment());
// 调用字典服务的selectList方法根据查询条件查询字典实体列表
List<DictionaryEntity> dictionaryEntityList = dictionaryService.selectList(queryWrapper); List<DictionaryEntity> dictionaryEntityList = dictionaryService.selectList(queryWrapper);
if(dictionaryEntityList != null ){ // 如果查询到的列表不为空
return R.ok().put("maxCodeIndex",dictionaryEntityList.get(0).getCodeIndex()+1); if (dictionaryEntityList != null) {
}else{ // 返回成功响应并将最大的code_index加1作为结果放入响应数据中
return R.ok().put("maxCodeIndex",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") @RequestMapping("/batchInsert")
public R save( String fileName){ public R save(String fileName) {
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); // 记录方法调用日志,包含控制器类名和文件名
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}", this.getClass().getName(), fileName);
try { try {
List<DictionaryEntity> dictionaryList = new ArrayList<>();//上传的东西 // 创建一个列表,用于存储要上传的字典实体
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段 List<DictionaryEntity> dictionaryList = new ArrayList<>();
// 创建一个Map用于存储要查询的字段
Map<String, List<String>> seachFields = new HashMap<>();
// 获取当前时间
Date date = new Date(); Date date = new Date();
// 获取文件名中最后一个点的索引
int lastIndexOf = fileName.lastIndexOf("."); int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){ // 如果文件名中没有点返回错误响应错误码为511
return R.error(511,"该文件没有后缀"); if (lastIndexOf == -1) {
}else{ return R.error(511, "该文件没有后缀");
} else {
// 获取文件后缀
String suffix = fileName.substring(lastIndexOf); String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){ // 如果文件后缀不是.xls返回错误响应错误码为511
return R.error(511,"只支持后缀为xls的excel文件"); if (!".xls".equals(suffix)) {
}else{ return R.error(511, "只支持后缀为xls的excel文件");
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径 } else {
// 获取文件的URL
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);
// 创建文件对象
File file = new File(resource.getFile()); File file = new File(resource.getFile());
if(!file.exists()){ // 如果文件不存在返回错误响应错误码为511
return R.error(511,"找不到上传文件,请联系管理员"); if (!file.exists()) {
}else{ return R.error(511, "找不到上传文件,请联系管理员");
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件 } else {
dataList.remove(0);//删除第一行,因为第一行是提示 // 使用PoiUtil工具类读取xls文件的数据
for(List<String> data:dataList){ List<List<String>> dataList = PoiUtil.poiImport(file.getPath());
//循环 // 删除第一行数据,因为第一行通常是表头
dataList.remove(0);
// 遍历数据列表
for (List<String> data : dataList) {
// 创建一个新的字典实体
DictionaryEntity dictionaryEntity = new DictionaryEntity(); DictionaryEntity dictionaryEntity = new DictionaryEntity();
// 以下代码注释掉,表示需要根据实际情况修改字段赋值
// dictionaryEntity.setDicCode(data.get(0)); //字段 要改的 // dictionaryEntity.setDicCode(data.get(0)); //字段 要改的
// dictionaryEntity.setDicName(data.get(0)); //字段名 要改的 // dictionaryEntity.setDicName(data.get(0)); //字段名 要改的
// dictionaryEntity.setCodeIndex(Integer.valueOf(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.setSuperId(Integer.valueOf(data.get(0))); //父字段id 要改的
// dictionaryEntity.setBeizhu(data.get(0)); //备注 要改的 // dictionaryEntity.setBeizhu(data.get(0)); //备注 要改的
// dictionaryEntity.setCreateTime(date);//时间 // dictionaryEntity.setCreateTime(date);//时间
// 将字典实体添加到上传列表中
dictionaryList.add(dictionaryEntity); dictionaryList.add(dictionaryEntity);
// 把要查询是否重复的字段放入map中
//把要查询是否重复的字段放入map中
} }
//查询是否重复 // 调用字典服务的insertBatch方法批量插入字典实体
dictionaryService.insertBatch(dictionaryList); dictionaryService.insertBatch(dictionaryList);
// 返回成功响应
return R.ok(); return R.ok();
} }
} }
} }
}catch (Exception e){ } catch (Exception e) {
return R.error(511,"批量插入数据异常,请联系管理员"); // 如果发生异常返回错误响应错误码为511
return R.error(511, "批量插入数据异常,请联系管理员");
} }
} }
}
}

@ -1,110 +1,370 @@
package com.controller; package com.controller;
// 导入文件操作类
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; // 导入用于高精度计算的类
import java.io.IOException; import java.math.BigDecimal;
import java.util.Arrays; // 导入用于处理URL的类
import java.util.Date; import java.net.URL;
import java.util.HashMap; // 导入用于日期格式化的类
import java.util.List; import java.text.SimpleDateFormat;
import java.util.Map; // 导入阿里巴巴的JSON对象类
import java.util.Random; import com.alibaba.fastjson.JSONObject;
import java.util.UUID; // 导入常用的集合类
import java.util.*;
import org.apache.commons.io.FileUtils; // 导入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.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 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.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity; // 导入MyBatis-Plus的查询包装器接口
import com.entity.EIException; import com.baomidou.mybatisplus.mapper.Wrapper;
import com.service.ConfigService; // 导入自定义的实体类
import com.entity.*;
// 导入自定义的视图类
import com.entity.view.*;
// 导入自定义的服务类
import com.service.*;
// 导入自定义的分页工具类
import com.utils.PageUtils;
// 导入自定义的响应结果类
import com.utils.R; import com.utils.R;
// 导入阿里巴巴的JSON工具类
import com.alibaba.fastjson.*;
/** /**
* *
*
* @author
* @email
*/ */
// 声明该类为RESTful控制器
@RestController @RestController
@RequestMapping("file") // 声明该类为控制器
@SuppressWarnings({"unchecked","rawtypes"}) @Controller
public class FileController{ // 映射请求路径,所有以/dictionary开头的请求都会由该控制器处理
@RequestMapping("/dictionary")
public class DictionaryController {
// 日志记录器,用于记录当前控制器类的日志信息
private static final Logger logger = LoggerFactory.getLogger(DictionaryController.class);
// 此处注解有误,应为@Autowired自动注入用户服务类
@Autow
private YonghuService yonghuService;
// 自动注入医生服务类
@Autowired @Autowired
private ConfigService configService; private YishengService yishengService;
/** /**
* *
*/ */
@RequestMapping("/upload") // 映射/page请求路径支持GET请求且忽略权限验证
public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception { @RequestMapping("/page")
if (file.isEmpty()) { @IgnoreAuth
throw new EIException("上传文件不能为空"); public R page(@RequestParam Map<String, Object> 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); // 调用字典服务的queryPage方法根据请求参数进行分页查询
File path = new File(ResourceUtils.getURL("classpath:static").getPath()); PageUtils page = dictionaryService.queryPage(params);
if(!path.exists()) {
path = new File(""); // 将分页结果中的列表转换为字典视图列表
List<DictionaryView> list = (List<DictionaryView>) page.getList();
// 遍历字典视图列表
for (DictionaryView c : list) {
// 调用字典服务的dictionaryConvert方法修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
} }
File upload = new File(path.getAbsolutePath(),"/upload/"); // 返回成功响应,并将分页查询结果放入响应数据中
if(!upload.exists()) { return R.ok().put("data", page);
upload.mkdirs(); }
/**
*
*/
// 映射/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<ConfigEntity>().eq("name", "faceFile")); */
if(configEntity==null) { // 映射/save请求路径支持POST请求
configEntity = new ConfigEntity(); @RequestMapping("/save")
configEntity.setName("faceFile"); public R save(@RequestBody DictionaryEntity dictionary, HttpServletRequest request) {
configEntity.setValue(fileName); // 记录方法调用日志,包含控制器类名和要保存的字典实体信息
} else { logger.debug("save方法:,,Controller:{},,dictionary:{}", this.getClass().getName(), dictionary.toString());
configEntity.setValue(fileName); // 从请求会话中获取用户角色
String role = String.valueOf(request.getSession().getAttribute("role"));
// 此条件永远为false注释掉的代码表示永远不会进入该分支
if (false)
return R.error(511, "永远不会进入");
// 创建查询包装器,用于构建查询条件
Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
.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<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
// 获取Servlet上下文
ServletContext servletContext = request.getServletContext();
// 创建一个Map用于存储字典数据
Map<String, Map<Integer, String>> map = new HashMap<>();
// 遍历所有字典实体
for (DictionaryEntity d : dictionaryEntities) {
// 获取当前字典代码对应的子Map
Map<Integer, String> 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 // 映射/update请求路径支持POST请求
@RequestMapping("/download") @RequestMapping("/update")
public ResponseEntity<byte[]> download(@RequestParam String fileName) { public R update(@RequestBody DictionaryEntity dictionary, HttpServletRequest request) {
try { // 记录方法调用日志,包含控制器类名和要修改的字典实体信息
File path = new File(ResourceUtils.getURL("classpath:static").getPath()); logger.debug("update方法:,,Controller:{},,dictionary:{}", this.getClass().getName(), dictionary.toString());
if(!path.exists()) { // 从请求会话中获取用户角色
path = new File(""); String role = String.valueOf(request.getSession().getAttribute("role"));
} // 此条件注释掉,表示永远不会进入该分支
File upload = new File(path.getAbsolutePath(),"/upload/"); // if (false)
if(!upload.exists()) { // return R.error(511, "永远不会进入");
upload.mkdirs(); // 创建查询包装器,用于构建查询条件,排除当前要修改的记录
Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
.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<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
// 获取Servlet上下文
ServletContext servletContext = request.getServletContext();
// 创建一个Map用于存储字典数据
Map<String, Map<Integer, String>> map = new HashMap<>();
// 遍历所有字典实体
for (DictionaryEntity d : dictionaryEntities) {
// 获取当前字典代码对应的子Map
Map<Integer, String> 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); // 将主Map存入Servlet上下文的属性中
if(file.exists()){ servletContext.setAttribute("dictionaryMap", map);
/*if(!fileService.canRead(file, SessionManager.getSessionUser())){ // 返回成功响应
getResponse().sendError(403); return R.ok();
}*/ } else {
HttpHeaders headers = new HttpHeaders(); // 如果查询到相同数据返回错误响应错误码为511
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); return R.error(511, "表中有相同数据");
headers.setContentDispositionFormData("attachment", fileName); }
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED); }
/**
*
*/
// 映射/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<String> descs = new ArrayList<>();
// 添加按code_index降序排序的字段
descs.add("code_index");
// 创建查询包装器,用于构建查询条件
Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
.eq("dic_code", dictionary.getDicCode())
.orderDesc(descs);
// 记录生成的SQL查询语句
logger.info("sql语句:" + queryWrapper.getSqlSegment());
// 调用字典服务的selectList方法根据查询条件查询字典实体列表
List<DictionaryEntity> 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<DictionaryEntity> dictionaryList = new ArrayList<>();
// 创建一个Map用于存储要查询的字段
Map<String, List<String>> 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<List<String>> dataList = PoiUtil.poiImport(file.getPath());
// 删除第一行数据,因为第一行通常是表头
dataList.remove(0);
// 遍历数据列表
for (List<String> 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) { } catch (Exception e) {
e.printStackTrace(); // 如果发生异常返回错误响应错误码为511
return R.error(511, "批量插入数据异常,请联系管理员");
} }
return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
}
}

@ -1,35 +1,63 @@
package com.controller; package com.controller;
// 导入文件操作相关类
import java.io.File; import java.io.File;
// 导入用于高精度计算的类
import java.math.BigDecimal; import java.math.BigDecimal;
// 导入用于处理URL的类
import java.net.URL; import java.net.URL;
// 导入用于日期格式化的类
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
// 导入阿里巴巴的JSON对象类
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
// 导入常用的集合类
import java.util.*; import java.util.*;
// 导入Spring的Bean属性复制工具类
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
// 导入Servlet请求相关类
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
// 导入Spring的上下文加载器类
import org.springframework.web.context.ContextLoader; import org.springframework.web.context.ContextLoader;
// 导入Servlet上下文类
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
// 导入令牌服务类
import com.service.TokenService; import com.service.TokenService;
// 导入自定义工具类
import com.utils.*; import com.utils.*;
// 导入反射调用异常类
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
// 导入字典服务类
import com.service.DictionaryService; import com.service.DictionaryService;
// 导入Apache Commons提供的字符串工具类
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
// 导入自定义的忽略权限注解类
import com.annotation.IgnoreAuth; import com.annotation.IgnoreAuth;
// 导入日志记录器接口
import org.slf4j.Logger; import org.slf4j.Logger;
// 导入日志记录器工厂类
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
// 导入Spring的自动注入注解
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
// 导入Spring的控制器注解
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
// 导入Spring的请求映射注解
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
// 导入MyBatis-Plus的实体包装器类
import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.EntityWrapper;
// 导入MyBatis-Plus的查询包装器接口
import com.baomidou.mybatisplus.mapper.Wrapper; import com.baomidou.mybatisplus.mapper.Wrapper;
// 导入自定义的实体类
import com.entity.*; import com.entity.*;
// 导入自定义的视图类
import com.entity.view.*; import com.entity.view.*;
// 导入自定义的服务类
import com.service.*; import com.service.*;
// 导入自定义的分页工具类
import com.utils.PageUtils; import com.utils.PageUtils;
// 导入自定义的响应结果类
import com.utils.R; import com.utils.R;
// 导入阿里巴巴的JSON工具类
import com.alibaba.fastjson.*; import com.alibaba.fastjson.*;
/** /**
@ -37,205 +65,276 @@ import com.alibaba.fastjson.*;
* *
* @author * @author
* @email * @email
*/ */
// 声明该类为RESTful控制器
@RestController @RestController
// 声明该类为控制器
@Controller @Controller
// 映射请求路径,所有以/guahao开头的请求都会由该控制器处理
@RequestMapping("/guahao") @RequestMapping("/guahao")
public class GuahaoController { public class GuahaoController {
// 日志记录器,用于记录当前控制器类的日志信息
private static final Logger logger = LoggerFactory.getLogger(GuahaoController.class); private static final Logger logger = LoggerFactory.getLogger(GuahaoController.class);
// 自动注入挂号服务类,用于处理挂号相关业务逻辑
@Autowired @Autowired
private GuahaoService guahaoService; private GuahaoService guahaoService;
// 自动注入令牌服务类
@Autowired @Autowired
private TokenService tokenService; private TokenService tokenService;
// 自动注入字典服务类
@Autowired @Autowired
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
//级联表service // 级联表service,自动注入医生服务类
@Autowired @Autowired
private YishengService yishengService; private YishengService yishengService;
// 级联表service自动注入用户服务类
@Autowired @Autowired
private YonghuService yonghuService; private YonghuService yonghuService;
/** /**
* *
*/ */
// 映射/page请求路径支持GET请求
@RequestMapping("/page") @RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){ public R page(@RequestParam Map<String, Object> params, HttpServletRequest request) {
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); // 记录方法调用日志,包含控制器类名和请求参数
logger.debug("page方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params));
// 从请求会话中获取用户角色
String role = String.valueOf(request.getSession().getAttribute("role")); String role = String.valueOf(request.getSession().getAttribute("role"));
if(false) // 此条件永远为false注释掉的代码表示永远不会进入该分支
return R.error(511,"永不会进入"); if (false)
else if("用户".equals(role)) return R.error(511, "永不会进入");
params.put("yonghuId",request.getSession().getAttribute("userId")); // 如果用户角色为"用户"
else if("医生".equals(role)) else if ("用户".equals(role))
params.put("yishengId",request.getSession().getAttribute("userId")); // 在请求参数中添加用户id
if(params.get("orderBy")==null || params.get("orderBy")==""){ params.put("yonghuId", request.getSession().getAttribute("userId"));
params.put("orderBy","id"); // 如果用户角色为"医生"
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); PageUtils page = guahaoService.queryPage(params);
//字典表数据转换 // 将分页结果中的列表转换为挂号视图列表
List<GuahaoView> list =(List<GuahaoView>)page.getList(); List<GuahaoView> list = (List<GuahaoView>) page.getList();
for(GuahaoView c:list){ // 遍历挂号视图列表
//修改对应字典表字段 for (GuahaoView c : list) {
// 调用字典服务的dictionaryConvert方法修改对应字典表字段
dictionaryService.dictionaryConvert(c, request); dictionaryService.dictionaryConvert(c, request);
} }
// 返回成功响应,并将分页查询结果放入响应数据中
return R.ok().put("data", page); return R.ok().put("data", page);
} }
/** /**
* *
*/ */
// 映射/info/{id}请求路径支持GET请求{id}为路径变量
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){ public R info(@PathVariable("id") Long id, HttpServletRequest request) {
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录方法调用日志包含控制器类名和请求的id
logger.debug("info方法:,,Controller:{},,id:{}", this.getClass().getName(), id);
// 调用挂号服务的selectById方法根据id查询挂号实体
GuahaoEntity guahao = guahaoService.selectById(id); GuahaoEntity guahao = guahaoService.selectById(id);
if(guahao !=null){ // 如果查询到挂号实体
//entity转view if (guahao != null) {
// 创建挂号视图对象
GuahaoView view = new GuahaoView(); GuahaoView view = new GuahaoView();
BeanUtils.copyProperties( guahao , view );//把实体数据重构到view中 // 使用BeanUtils将挂号实体的属性复制到挂号视图中
BeanUtils.copyProperties(guahao, view);
//级联表
YishengEntity yisheng = yishengService.selectById(guahao.getYishengId()); // 级联查询医生信息
if(yisheng != null){ YishengEntity yisheng = yishengService.selectById(guahao.getYishengId());
BeanUtils.copyProperties( yisheng , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段 // 如果查询到医生信息
view.setYishengId(yisheng.getId()); if (yisheng != null) {
} // 将医生信息的部分属性复制到挂号视图中,并排除指定字段
//级联表 BeanUtils.copyProperties(yisheng, view, new String[]{"id", "createTime", "insertTime", "updateTime"});
YonghuEntity yonghu = yonghuService.selectById(guahao.getYonghuId()); // 设置挂号视图中的医生id
if(yonghu != null){ view.setYishengId(yisheng.getId());
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段 }
view.setYonghuId(yonghu.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); dictionaryService.dictionaryConvert(view, request);
// 返回成功响应,并将挂号视图对象放入响应数据中
return R.ok().put("data", view); return R.ok().put("data", view);
}else { } else {
return R.error(511,"查不到数据"); // 如果未查询到数据返回错误响应错误码为511
return R.error(511, "查不到数据");
} }
} }
/** /**
* *
*/ */
// 映射/save请求路径支持POST请求
@RequestMapping("/save") @RequestMapping("/save")
public R save(@RequestBody GuahaoEntity guahao, HttpServletRequest request){ public R save(@RequestBody GuahaoEntity guahao, HttpServletRequest request) {
logger.debug("save方法:,,Controller:{},,guahao:{}",this.getClass().getName(),guahao.toString()); // 记录方法调用日志,包含控制器类名和要保存的挂号实体信息
logger.debug("save方法:,,Controller:{},,guahao:{}", this.getClass().getName(), guahao.toString());
// 从请求会话中获取用户角色
String role = String.valueOf(request.getSession().getAttribute("role")); String role = String.valueOf(request.getSession().getAttribute("role"));
if(false) // 此条件永远为false注释掉的代码表示永远不会进入该分支
return R.error(511,"永远不会进入"); if (false)
else if("医生".equals(role)) return R.error(511, "永远不会进入");
// 如果用户角色为"医生"
else if ("医生".equals(role))
// 设置挂号实体的医生id为当前会话中的用户id
guahao.setYishengId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")))); 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")))); guahao.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
// 创建查询包装器,用于构建查询条件
Wrapper<GuahaoEntity> queryWrapper = new EntityWrapper<GuahaoEntity>() Wrapper<GuahaoEntity> queryWrapper = new EntityWrapper<GuahaoEntity>()
.eq("yisheng_id", guahao.getYishengId()) .eq("yisheng_id", guahao.getYishengId())
.eq("yonghu_id", guahao.getYonghuId()) .eq("yonghu_id", guahao.getYonghuId())
.eq("guahao_uuin_number", guahao.getGuahaoUuinNumber()) .eq("guahao_uuin_number", guahao.getGuahaoUuinNumber())
.eq("guahao_time", new SimpleDateFormat("yyyy-MM-dd").format(guahao.getGuahaoTime())) .eq("guahao_time", new SimpleDateFormat("yyyy-MM-dd").format(guahao.getGuahaoTime()))
.eq("guahao_types", guahao.getGuahaoTypes()) .eq("guahao_types", guahao.getGuahaoTypes())
.eq("guahao_status_types", guahao.getGuahaoStatusTypes()) .eq("guahao_status_types", guahao.getGuahaoStatusTypes())
.eq("guahao_yesno_types", guahao.getGuahaoYesnoTypes()) .eq("guahao_yesno_types", guahao.getGuahaoYesnoTypes())
.eq("guahao_yesno_text", guahao.getGuahaoYesnoText()) .eq("guahao_yesno_text", guahao.getGuahaoYesnoText());
;
// 记录生成的SQL查询语句
logger.info("sql语句:"+queryWrapper.getSqlSegment()); logger.info("sql语句:" + queryWrapper.getSqlSegment());
// 调用挂号服务的selectOne方法根据查询条件查询是否存在相同数据
GuahaoEntity guahaoEntity = guahaoService.selectOne(queryWrapper); GuahaoEntity guahaoEntity = guahaoService.selectOne(queryWrapper);
if(guahaoEntity==null){ // 如果未查询到相同数据
if (guahaoEntity == null) {
// 设置挂号审核类型为1
guahao.setGuahaoYesnoTypes(1); guahao.setGuahaoYesnoTypes(1);
// 设置挂号实体的创建时间为当前时间
guahao.setCreateTime(new Date()); guahao.setCreateTime(new Date());
// 调用挂号服务的insert方法将挂号实体插入数据库
guahaoService.insert(guahao); guahaoService.insert(guahao);
// 返回成功响应
return R.ok(); return R.ok();
}else { } else {
return R.error(511,"表中有相同数据"); // 如果查询到相同数据返回错误响应错误码为511
return R.error(511, "表中有相同数据");
} }
} }
/** /**
* *
*/ */
// 映射/update请求路径支持POST请求
@RequestMapping("/update") @RequestMapping("/update")
public R update(@RequestBody GuahaoEntity guahao, HttpServletRequest request){ public R update(@RequestBody GuahaoEntity guahao, HttpServletRequest request) {
logger.debug("update方法:,,Controller:{},,guahao:{}",this.getClass().getName(),guahao.toString()); // 记录方法调用日志,包含控制器类名和要修改的挂号实体信息
logger.debug("update方法:,,Controller:{},,guahao:{}", this.getClass().getName(), guahao.toString());
// 从请求会话中获取用户角色
String role = String.valueOf(request.getSession().getAttribute("role")); String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false) // 此条件注释掉,表示永远不会进入该分支
// return R.error(511,"永远不会进入"); // if (false)
// else if("医生".equals(role)) // return R.error(511, "永远不会进入");
// else if ("医生".equals(role))
// guahao.setYishengId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")))); // 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")))); // guahao.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
//根据字段查询是否有相同数据 // 创建查询包装器,用于构建查询条件,排除当前要修改的记录
Wrapper<GuahaoEntity> queryWrapper = new EntityWrapper<GuahaoEntity>() Wrapper<GuahaoEntity> queryWrapper = new EntityWrapper<GuahaoEntity>()
.notIn("id",guahao.getId()) .notIn("id", guahao.getId())
.andNew() .andNew()
.eq("yisheng_id", guahao.getYishengId()) .eq("yisheng_id", guahao.getYishengId())
.eq("yonghu_id", guahao.getYonghuId()) .eq("yonghu_id", guahao.getYonghuId())
.eq("guahao_uuin_number", guahao.getGuahaoUuinNumber()) .eq("guahao_uuin_number", guahao.getGuahaoUuinNumber())
.eq("guahao_time", guahao.getGuahaoTime()) .eq("guahao_time", guahao.getGuahaoTime())
.eq("guahao_types", guahao.getGuahaoTypes()) .eq("guahao_types", guahao.getGuahaoTypes())
.eq("guahao_status_types", guahao.getGuahaoStatusTypes()) .eq("guahao_status_types", guahao.getGuahaoStatusTypes())
.eq("guahao_yesno_types", guahao.getGuahaoYesnoTypes()) .eq("guahao_yesno_types", guahao.getGuahaoYesnoTypes())
.eq("guahao_yesno_text", guahao.getGuahaoYesnoText()) .eq("guahao_yesno_text", guahao.getGuahaoYesnoText());
;
// 记录生成的SQL查询语句
logger.info("sql语句:"+queryWrapper.getSqlSegment()); logger.info("sql语句:" + queryWrapper.getSqlSegment());
// 调用挂号服务的selectOne方法根据查询条件查询是否存在相同数据
GuahaoEntity guahaoEntity = guahaoService.selectOne(queryWrapper); GuahaoEntity guahaoEntity = guahaoService.selectOne(queryWrapper);
if(guahaoEntity==null){ // 如果未查询到相同数据
guahaoService.updateById(guahao);//根据id更新 if (guahaoEntity == null) {
// 调用挂号服务的updateById方法根据id更新挂号实体
guahaoService.updateById(guahao);
// 返回成功响应
return R.ok(); return R.ok();
}else { } else {
return R.error(511,"表中有相同数据"); // 如果查询到相同数据返回错误响应错误码为511
return R.error(511, "表中有相同数据");
} }
} }
/** /**
* *
*/ */
// 映射/delete请求路径支持POST请求
@RequestMapping("/delete") @RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){ public R delete(@RequestBody Integer[] ids) {
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); // 记录方法调用日志包含控制器类名和要删除的记录id数组
logger.debug("delete:,,Controller:{},,ids:{}", this.getClass().getName(), ids.toString());
// 调用挂号服务的deleteBatchIds方法根据id数组批量删除记录
guahaoService.deleteBatchIds(Arrays.asList(ids)); guahaoService.deleteBatchIds(Arrays.asList(ids));
// 返回成功响应
return R.ok(); return R.ok();
} }
/** /**
* *
*/ */
// 映射/batchInsert请求路径支持POST请求
@RequestMapping("/batchInsert") @RequestMapping("/batchInsert")
public R save( String fileName){ public R save(String fileName) {
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); // 记录方法调用日志,包含控制器类名和文件名
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}", this.getClass().getName(), fileName);
try { try {
List<GuahaoEntity> guahaoList = new ArrayList<>();//上传的东西 // 创建一个列表,用于存储要上传的挂号实体
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段 List<GuahaoEntity> guahaoList = new ArrayList<>();
// 创建一个Map用于存储要查询的字段
Map<String, List<String>> seachFields = new HashMap<>();
// 获取当前时间
Date date = new Date(); Date date = new Date();
// 获取文件名中最后一个点的索引
int lastIndexOf = fileName.lastIndexOf("."); int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){ // 如果文件名中没有点返回错误响应错误码为511
return R.error(511,"该文件没有后缀"); if (lastIndexOf == -1) {
}else{ return R.error(511, "该文件没有后缀");
} else {
// 获取文件后缀
String suffix = fileName.substring(lastIndexOf); String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){ // 如果文件后缀不是.xls返回错误响应错误码为511
return R.error(511,"只支持后缀为xls的excel文件"); if (!".xls".equals(suffix)) {
}else{ return R.error(511, "只支持后缀为xls的excel文件");
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径 } else {
// 获取文件的URL
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);
// 创建文件对象
File file = new File(resource.getFile()); File file = new File(resource.getFile());
if(!file.exists()){ // 如果文件不存在返回错误响应错误码为511
return R.error(511,"找不到上传文件,请联系管理员"); if (!file.exists()) {
}else{ return R.error(511, "找不到上传文件,请联系管理员");
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件 } else {
dataList.remove(0);//删除第一行,因为第一行是提示 // 使用PoiUtil工具类读取xls文件的数据
for(List<String> data:dataList){ List<List<String>> dataList = PoiUtil.poiImport(file.getPath());
//循环 // 删除第一行数据,因为第一行通常是表头
dataList.remove(0);
// 遍历数据列表
for (List<String> data : dataList) {
// 创建一个新的挂号实体
GuahaoEntity guahaoEntity = new GuahaoEntity(); GuahaoEntity guahaoEntity = new GuahaoEntity();
// 以下代码注释掉,表示需要根据实际情况修改字段赋值
// guahaoEntity.setYishengId(Integer.valueOf(data.get(0))); //医生 要改的 // guahaoEntity.setYishengId(Integer.valueOf(data.get(0))); //医生 要改的
// guahaoEntity.setYonghuId(Integer.valueOf(data.get(0))); //用户 要改的 // guahaoEntity.setYonghuId(Integer.valueOf(data.get(0))); //用户 要改的
// guahaoEntity.setGuahaoUuinNumber(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.setGuahaoYesnoTypes(Integer.valueOf(data.get(0))); //挂号审核 要改的
// guahaoEntity.setGuahaoYesnoText(data.get(0)); //审核结果 要改的 // guahaoEntity.setGuahaoYesnoText(data.get(0)); //审核结果 要改的
// guahaoEntity.setCreateTime(date);//时间 // guahaoEntity.setCreateTime(date);//时间
// 将挂号实体添加到上传列表中
guahaoList.add(guahaoEntity); 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<String, Object> 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<GuahaoView> list =(List<GuahaoView>)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<GuahaoEntity> queryWrapper = new EntityWrapper<GuahaoEntity>()
.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()<yishengEntity.getYishengNewMoney()){
return R.error("余额不足请充值");
}
userId.setNewMoney(userId.getNewMoney()-yishengEntity.getYishengNewMoney());
boolean b = yonghuService.updateById(userId);
if(!b){
return R.error();
}
guahaoService.insert(guahao);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
}

@ -1,35 +1,63 @@
package com.controller; package com.controller;
// 导入文件操作相关类
import java.io.File; import java.io.File;
// 导入用于高精度计算的类
import java.math.BigDecimal; import java.math.BigDecimal;
// 导入用于处理URL的类
import java.net.URL; import java.net.URL;
// 导入用于日期格式化的类
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
// 导入阿里巴巴的JSON对象类
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
// 导入常用的集合类
import java.util.*; import java.util.*;
// 导入Spring的Bean属性复制工具类
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
// 导入Servlet请求相关类
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
// 导入Spring的上下文加载器类
import org.springframework.web.context.ContextLoader; import org.springframework.web.context.ContextLoader;
// 导入Servlet上下文类
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
// 导入令牌服务类
import com.service.TokenService; import com.service.TokenService;
// 导入自定义工具类
import com.utils.*; import com.utils.*;
// 导入反射调用异常类
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
// 导入字典服务类
import com.service.DictionaryService; import com.service.DictionaryService;
// 导入Apache Commons提供的字符串工具类
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
// 导入自定义的忽略权限注解类
import com.annotation.IgnoreAuth; import com.annotation.IgnoreAuth;
// 导入日志记录器接口
import org.slf4j.Logger; import org.slf4j.Logger;
// 导入日志记录器工厂类
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
// 导入Spring的自动注入注解
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
// 导入Spring的控制器注解
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
// 导入Spring的请求映射注解
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
// 导入MyBatis-Plus的实体包装器类
import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.EntityWrapper;
// 导入MyBatis-Plus的查询包装器接口
import com.baomidou.mybatisplus.mapper.Wrapper; import com.baomidou.mybatisplus.mapper.Wrapper;
// 导入自定义的实体类
import com.entity.*; import com.entity.*;
// 导入自定义的视图类
import com.entity.view.*; import com.entity.view.*;
// 导入自定义的服务类
import com.service.*; import com.service.*;
// 导入自定义的分页工具类
import com.utils.PageUtils; import com.utils.PageUtils;
// 导入自定义的响应结果类
import com.utils.R; import com.utils.R;
// 导入阿里巴巴的JSON工具类
import com.alibaba.fastjson.*; import com.alibaba.fastjson.*;
/** /**
@ -37,189 +65,261 @@ import com.alibaba.fastjson.*;
* *
* @author * @author
* @email * @email
*/ */
// 声明该类为RESTful控制器用于处理HTTP请求并返回JSON数据
@RestController @RestController
// 声明该类为Spring MVC控制器
@Controller @Controller
// 映射请求路径,所有以/jiankangjiaoyu开头的请求都会由该控制器处理
@RequestMapping("/jiankangjiaoyu") @RequestMapping("/jiankangjiaoyu")
public class JiankangjiaoyuController { public class JiankangjiaoyuController {
// 日志记录器,用于记录当前控制器类的日志信息
private static final Logger logger = LoggerFactory.getLogger(JiankangjiaoyuController.class); private static final Logger logger = LoggerFactory.getLogger(JiankangjiaoyuController.class);
// 自动注入健康教育服务类,用于处理健康教育相关业务逻辑
@Autowired @Autowired
private JiankangjiaoyuService jiankangjiaoyuService; private JiankangjiaoyuService jiankangjiaoyuService;
// 自动注入令牌服务类
@Autowired @Autowired
private TokenService tokenService; private TokenService tokenService;
// 自动注入字典服务类,用于字典表数据转换
@Autowired @Autowired
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
//级联表service // 级联表service自动注入用户服务类
@Autowired @Autowired
private YonghuService yonghuService; private YonghuService yonghuService;
// 级联表service自动注入医生服务类
@Autowired @Autowired
private YishengService yishengService; private YishengService yishengService;
/** /**
* *
*/ */
// 映射/page请求路径支持GET请求用于获取健康教育信息的分页列表
@RequestMapping("/page") @RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){ public R page(@RequestParam Map<String, Object> params, HttpServletRequest request) {
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); // 记录方法调用日志,包含控制器类名和请求参数
logger.debug("page方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params));
// 从请求会话中获取用户角色
String role = String.valueOf(request.getSession().getAttribute("role")); String role = String.valueOf(request.getSession().getAttribute("role"));
if(false) // 此条件永远为false注释掉的代码表示永远不会进入该分支
return R.error(511,"永不会进入"); if (false)
else if("用户".equals(role)) return R.error(511, "永不会进入");
params.put("yonghuId",request.getSession().getAttribute("userId")); // 如果用户角色为"用户"
else if("医生".equals(role)) else if ("用户".equals(role))
params.put("yishengId",request.getSession().getAttribute("userId")); // 在请求参数中添加用户id
params.put("jiankangjiaoyuDeleteStart",1);params.put("jiankangjiaoyuDeleteEnd",1); params.put("yonghuId", request.getSession().getAttribute("userId"));
if(params.get("orderBy")==null || params.get("orderBy")==""){ // 如果用户角色为"医生"
params.put("orderBy","id"); 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); PageUtils page = jiankangjiaoyuService.queryPage(params);
//字典表数据转换 // 将分页结果中的列表转换为健康教育视图列表
List<JiankangjiaoyuView> list =(List<JiankangjiaoyuView>)page.getList(); List<JiankangjiaoyuView> list = (List<JiankangjiaoyuView>) page.getList();
for(JiankangjiaoyuView c:list){ // 遍历健康教育视图列表
//修改对应字典表字段 for (JiankangjiaoyuView c : list) {
// 调用字典服务的dictionaryConvert方法修改对应字典表字段
dictionaryService.dictionaryConvert(c, request); dictionaryService.dictionaryConvert(c, request);
} }
// 返回成功响应,并将分页查询结果放入响应数据中
return R.ok().put("data", page); return R.ok().put("data", page);
} }
/** /**
* *
*/ */
// 映射/info/{id}请求路径支持GET请求{id}为路径变量用于获取指定id的健康教育信息详情
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){ public R info(@PathVariable("id") Long id, HttpServletRequest request) {
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录方法调用日志包含控制器类名和请求的id
logger.debug("info方法:,,Controller:{},,id:{}", this.getClass().getName(), id);
// 调用健康教育服务的selectById方法根据id查询健康教育实体
JiankangjiaoyuEntity jiankangjiaoyu = jiankangjiaoyuService.selectById(id); JiankangjiaoyuEntity jiankangjiaoyu = jiankangjiaoyuService.selectById(id);
if(jiankangjiaoyu !=null){ // 如果查询到健康教育实体
//entity转view if (jiankangjiaoyu != null) {
// 创建健康教育视图对象
JiankangjiaoyuView view = new JiankangjiaoyuView(); JiankangjiaoyuView view = new JiankangjiaoyuView();
BeanUtils.copyProperties( jiankangjiaoyu , view );//把实体数据重构到view中 // 使用BeanUtils将健康教育实体的属性复制到健康教育视图中
BeanUtils.copyProperties(jiankangjiaoyu, view);
//修改对应字典表字段 // 调用字典服务的dictionaryConvert方法修改对应字典表字段
dictionaryService.dictionaryConvert(view, request); dictionaryService.dictionaryConvert(view, request);
// 返回成功响应,并将健康教育视图对象放入响应数据中
return R.ok().put("data", view); return R.ok().put("data", view);
}else { } else {
return R.error(511,"查不到数据"); // 如果未查询到数据返回错误响应错误码为511
return R.error(511, "查不到数据");
} }
} }
/** /**
* *
*/ */
// 映射/save请求路径支持POST请求用于保存新的健康教育信息
@RequestMapping("/save") @RequestMapping("/save")
public R save(@RequestBody JiankangjiaoyuEntity jiankangjiaoyu, HttpServletRequest request){ public R save(@RequestBody JiankangjiaoyuEntity jiankangjiaoyu, HttpServletRequest request) {
logger.debug("save方法:,,Controller:{},,jiankangjiaoyu:{}",this.getClass().getName(),jiankangjiaoyu.toString()); // 记录方法调用日志,包含控制器类名和要保存的健康教育实体信息
logger.debug("save方法:,,Controller:{},,jiankangjiaoyu:{}", this.getClass().getName(), jiankangjiaoyu.toString());
// 从请求会话中获取用户角色
String role = String.valueOf(request.getSession().getAttribute("role")); String role = String.valueOf(request.getSession().getAttribute("role"));
if(false) // 此条件永远为false注释掉的代码表示永远不会进入该分支
return R.error(511,"永远不会进入"); if (false)
return R.error(511, "永远不会进入");
// 创建查询包装器,用于构建查询条件,检查是否存在相同的健康教育信息
Wrapper<JiankangjiaoyuEntity> queryWrapper = new EntityWrapper<JiankangjiaoyuEntity>() Wrapper<JiankangjiaoyuEntity> queryWrapper = new EntityWrapper<JiankangjiaoyuEntity>()
.eq("jiankangjiaoyu_name", jiankangjiaoyu.getJiankangjiaoyuName()) .eq("jiankangjiaoyu_name", jiankangjiaoyu.getJiankangjiaoyuName())
.eq("jiankangjiaoyu_types", jiankangjiaoyu.getJiankangjiaoyuTypes()) .eq("jiankangjiaoyu_types", jiankangjiaoyu.getJiankangjiaoyuTypes())
.eq("jiankangjiaoyu_delete", jiankangjiaoyu.getJiankangjiaoyuDelete()) .eq("jiankangjiaoyu_delete", jiankangjiaoyu.getJiankangjiaoyuDelete());
;
logger.info("sql语句:"+queryWrapper.getSqlSegment()); // 记录生成的SQL查询语句
logger.info("sql语句:" + queryWrapper.getSqlSegment());
// 调用健康教育服务的selectOne方法根据查询条件查询是否存在相同数据
JiankangjiaoyuEntity jiankangjiaoyuEntity = jiankangjiaoyuService.selectOne(queryWrapper); JiankangjiaoyuEntity jiankangjiaoyuEntity = jiankangjiaoyuService.selectOne(queryWrapper);
if(jiankangjiaoyuEntity==null){ // 如果未查询到相同数据
if (jiankangjiaoyuEntity == null) {
// 设置插入时间为当前时间
jiankangjiaoyu.setInsertTime(new Date()); jiankangjiaoyu.setInsertTime(new Date());
// 设置逻辑删除字段为1表示未删除
jiankangjiaoyu.setJiankangjiaoyuDelete(1); jiankangjiaoyu.setJiankangjiaoyuDelete(1);
// 设置创建时间为当前时间
jiankangjiaoyu.setCreateTime(new Date()); jiankangjiaoyu.setCreateTime(new Date());
// 调用健康教育服务的insert方法将健康教育实体插入数据库
jiankangjiaoyuService.insert(jiankangjiaoyu); jiankangjiaoyuService.insert(jiankangjiaoyu);
// 返回成功响应
return R.ok(); return R.ok();
}else { } else {
return R.error(511,"表中有相同数据"); // 如果查询到相同数据返回错误响应错误码为511
return R.error(511, "表中有相同数据");
} }
} }
/** /**
* *
*/ */
// 映射/update请求路径支持POST请求用于修改已有的健康教育信息
@RequestMapping("/update") @RequestMapping("/update")
public R update(@RequestBody JiankangjiaoyuEntity jiankangjiaoyu, HttpServletRequest request){ public R update(@RequestBody JiankangjiaoyuEntity jiankangjiaoyu, HttpServletRequest request) {
logger.debug("update方法:,,Controller:{},,jiankangjiaoyu:{}",this.getClass().getName(),jiankangjiaoyu.toString()); // 记录方法调用日志,包含控制器类名和要修改的健康教育实体信息
logger.debug("update方法:,,Controller:{},,jiankangjiaoyu:{}", this.getClass().getName(), jiankangjiaoyu.toString());
// 从请求会话中获取用户角色
String role = String.valueOf(request.getSession().getAttribute("role")); String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false) // 此条件注释掉,表示永远不会进入该分支
// return R.error(511,"永远不会进入"); // if (false)
//根据字段查询是否有相同数据 // return R.error(511, "永远不会进入");
// 创建查询包装器,用于构建查询条件,排除当前要修改的记录,检查是否存在相同的健康教育信息
Wrapper<JiankangjiaoyuEntity> queryWrapper = new EntityWrapper<JiankangjiaoyuEntity>() Wrapper<JiankangjiaoyuEntity> queryWrapper = new EntityWrapper<JiankangjiaoyuEntity>()
.notIn("id",jiankangjiaoyu.getId()) .notIn("id", jiankangjiaoyu.getId())
.andNew() .andNew()
.eq("jiankangjiaoyu_name", jiankangjiaoyu.getJiankangjiaoyuName()) .eq("jiankangjiaoyu_name", jiankangjiaoyu.getJiankangjiaoyuName())
.eq("jiankangjiaoyu_types", jiankangjiaoyu.getJiankangjiaoyuTypes()) .eq("jiankangjiaoyu_types", jiankangjiaoyu.getJiankangjiaoyuTypes())
.eq("jiankangjiaoyu_delete", jiankangjiaoyu.getJiankangjiaoyuDelete()) .eq("jiankangjiaoyu_delete", jiankangjiaoyu.getJiankangjiaoyuDelete());
;
// 记录生成的SQL查询语句
logger.info("sql语句:"+queryWrapper.getSqlSegment()); logger.info("sql语句:" + queryWrapper.getSqlSegment());
// 调用健康教育服务的selectOne方法根据查询条件查询是否存在相同数据
JiankangjiaoyuEntity jiankangjiaoyuEntity = jiankangjiaoyuService.selectOne(queryWrapper); JiankangjiaoyuEntity jiankangjiaoyuEntity = jiankangjiaoyuService.selectOne(queryWrapper);
if("".equals(jiankangjiaoyu.getJiankangjiaoyuPhoto()) || "null".equals(jiankangjiaoyu.getJiankangjiaoyuPhoto())){ // 如果健康教育照片字段为空字符串或"null"则将其设置为null
jiankangjiaoyu.setJiankangjiaoyuPhoto(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(); return R.ok();
}else { } else {
return R.error(511,"表中有相同数据"); // 如果查询到相同数据返回错误响应错误码为511
return R.error(511, "表中有相同数据");
} }
} }
/** /**
* *
*/ */
// 映射/delete请求路径支持POST请求用于删除健康教育信息逻辑删除
@RequestMapping("/delete") @RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){ public R delete(@RequestBody Integer[] ids) {
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); // 记录方法调用日志包含控制器类名和要删除的记录id数组
logger.debug("delete:,,Controller:{},,ids:{}", this.getClass().getName(), ids.toString());
// 创建一个ArrayList用于存储要更新的健康教育实体
ArrayList<JiankangjiaoyuEntity> list = new ArrayList<>(); ArrayList<JiankangjiaoyuEntity> list = new ArrayList<>();
for(Integer id:ids){ // 遍历要删除的记录id数组
for (Integer id : ids) {
// 创建一个新的健康教育实体
JiankangjiaoyuEntity jiankangjiaoyuEntity = new JiankangjiaoyuEntity(); JiankangjiaoyuEntity jiankangjiaoyuEntity = new JiankangjiaoyuEntity();
// 设置健康教育实体的id
jiankangjiaoyuEntity.setId(id); jiankangjiaoyuEntity.setId(id);
// 设置逻辑删除字段为2表示已删除
jiankangjiaoyuEntity.setJiankangjiaoyuDelete(2); jiankangjiaoyuEntity.setJiankangjiaoyuDelete(2);
// 将健康教育实体添加到列表中
list.add(jiankangjiaoyuEntity); list.add(jiankangjiaoyuEntity);
} }
if(list != null && list.size() >0){ // 如果列表不为空
if (list != null && list.size() > 0) {
// 调用健康教育服务的updateBatchById方法批量更新健康教育实体
jiankangjiaoyuService.updateBatchById(list); jiankangjiaoyuService.updateBatchById(list);
} }
// 返回成功响应
return R.ok(); return R.ok();
} }
/** /**
* *
*/ */
// 映射/batchInsert请求路径支持POST请求用于批量上传健康教育信息
@RequestMapping("/batchInsert") @RequestMapping("/batchInsert")
public R save( String fileName){ public R save(String fileName) {
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); // 记录方法调用日志,包含控制器类名和文件名
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}", this.getClass().getName(), fileName);
try { try {
List<JiankangjiaoyuEntity> jiankangjiaoyuList = new ArrayList<>();//上传的东西 // 创建一个列表,用于存储要上传的健康教育实体
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段 List<JiankangjiaoyuEntity> jiankangjiaoyuList = new ArrayList<>();
// 创建一个Map用于存储要查询的字段
Map<String, List<String>> seachFields = new HashMap<>();
// 获取当前时间
Date date = new Date(); Date date = new Date();
// 获取文件名中最后一个点的索引
int lastIndexOf = fileName.lastIndexOf("."); int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){ // 如果文件名中没有点返回错误响应错误码为511
return R.error(511,"该文件没有后缀"); if (lastIndexOf == -1) {
}else{ return R.error(511, "该文件没有后缀");
} else {
// 获取文件后缀
String suffix = fileName.substring(lastIndexOf); String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){ // 如果文件后缀不是.xls返回错误响应错误码为511
return R.error(511,"只支持后缀为xls的excel文件"); if (!".xls".equals(suffix)) {
}else{ return R.error(511, "只支持后缀为xls的excel文件");
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径 } else {
// 获取文件的URL
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);
// 创建文件对象
File file = new File(resource.getFile()); File file = new File(resource.getFile());
if(!file.exists()){ // 如果文件不存在返回错误响应错误码为511
return R.error(511,"找不到上传文件,请联系管理员"); if (!file.exists()) {
}else{ return R.error(511, "找不到上传文件,请联系管理员");
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件 } else {
dataList.remove(0);//删除第一行,因为第一行是提示 // 使用PoiUtil工具类读取xls文件的数据
for(List<String> data:dataList){ List<List<String>> dataList = PoiUtil.poiImport(file.getPath());
//循环 // 删除第一行数据,因为第一行通常是表头
dataList.remove(0);
// 遍历数据列表
for (List<String> data : dataList) {
// 创建一个新的健康教育实体
JiankangjiaoyuEntity jiankangjiaoyuEntity = new JiankangjiaoyuEntity(); JiankangjiaoyuEntity jiankangjiaoyuEntity = new JiankangjiaoyuEntity();
// 以下代码注释掉,表示需要根据实际情况修改字段赋值
// jiankangjiaoyuEntity.setJiankangjiaoyuName(data.get(0)); //健康教育标题 要改的 // jiankangjiaoyuEntity.setJiankangjiaoyuName(data.get(0)); //健康教育标题 要改的
// jiankangjiaoyuEntity.setJiankangjiaoyuTypes(Integer.valueOf(data.get(0))); //健康教育类型 要改的 // jiankangjiaoyuEntity.setJiankangjiaoyuTypes(Integer.valueOf(data.get(0))); //健康教育类型 要改的
// jiankangjiaoyuEntity.setJiankangjiaoyuPhoto("");//照片 // jiankangjiaoyuEntity.setJiankangjiaoyuPhoto("");//照片
@ -227,94 +327,111 @@ public class JiankangjiaoyuController {
// jiankangjiaoyuEntity.setJiankangjiaoyuContent("");//照片 // jiankangjiaoyuEntity.setJiankangjiaoyuContent("");//照片
// jiankangjiaoyuEntity.setJiankangjiaoyuDelete(1);//逻辑删除字段 // jiankangjiaoyuEntity.setJiankangjiaoyuDelete(1);//逻辑删除字段
// jiankangjiaoyuEntity.setCreateTime(date);//时间 // jiankangjiaoyuEntity.setCreateTime(date);//时间
// 将健康教育实体添加到上传列表中
jiankangjiaoyuList.add(jiankangjiaoyuEntity); jiankangjiaoyuList.add(jiankangjiaoyuEntity);
// 把要查询是否重复的字段放入map中
//把要查询是否重复的字段放入map中
} }
//查询是否重复 // 调用健康教育服务的insertBatch方法批量插入健康教育实体
jiankangjiaoyuService.insertBatch(jiankangjiaoyuList); jiankangjiaoyuService.insertBatch(jiankangjiaoyuList);
// 返回成功响应
return R.ok(); return R.ok();
} }
} }
} }
}catch (Exception e){ } catch (Exception e) {
return R.error(511,"批量插入数据异常,请联系管理员"); // 如果发生异常返回错误响应错误码为511
return R.error(511, "批量插入数据异常,请联系管理员");
} }
} }
/** /**
* *
*/ */
// 映射/list请求路径支持GET请求用于前端获取健康教育信息的分页列表忽略权限验证
@IgnoreAuth @IgnoreAuth
@RequestMapping("/list") @RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){ public R list(@RequestParam Map<String, Object> params, HttpServletRequest request) {
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); // 记录方法调用日志,包含控制器类名和请求参数
logger.debug("list方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params));
// 没有指定排序字段就默认id倒 // 如果请求参数中没有指定排序字段则默认按id倒序排
if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){ if (StringUtil.isEmpty(String.valueOf(params.get("orderBy")))) {
params.put("orderBy","id"); params.put("orderBy", "id");
} }
// 调用健康教育服务的queryPage方法根据请求参数进行分页查询
PageUtils page = jiankangjiaoyuService.queryPage(params); PageUtils page = jiankangjiaoyuService.queryPage(params);
//字典表数据转换 // 将分页结果中的列表转换为健康教育视图列表
List<JiankangjiaoyuView> list =(List<JiankangjiaoyuView>)page.getList(); List<JiankangjiaoyuView> list = (List<JiankangjiaoyuView>) page.getList();
for(JiankangjiaoyuView c:list) // 遍历健康教育视图列表
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段 for (JiankangjiaoyuView c : list)
// 调用字典服务的dictionaryConvert方法修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
// 返回成功响应,并将分页查询结果放入响应数据中
return R.ok().put("data", page); return R.ok().put("data", page);
} }
/** /**
* *
*/ */
// 映射/detail/{id}请求路径支持GET请求{id}为路径变量用于前端获取指定id的健康教育信息详情
@RequestMapping("/detail/{id}") @RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id, HttpServletRequest request){ public R detail(@PathVariable("id") Long id, HttpServletRequest request) {
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录方法调用日志包含控制器类名和请求的id
logger.debug("detail方法:,,Controller:{},,id:{}", this.getClass().getName(), id);
// 调用健康教育服务的selectById方法根据id查询健康教育实体
JiankangjiaoyuEntity jiankangjiaoyu = jiankangjiaoyuService.selectById(id); JiankangjiaoyuEntity jiankangjiaoyu = jiankangjiaoyuService.selectById(id);
if(jiankangjiaoyu !=null){ // 如果查询到健康教育实体
if (jiankangjiaoyu != null) {
// 创建健康教育视图对象
//entity转view JiankangjiaoyuView view = new JiankangjiaoyuView();
JiankangjiaoyuView view = new JiankangjiaoyuView(); // 使用BeanUtils将健康教育实体的属性复制到健康教育视图中
BeanUtils.copyProperties( jiankangjiaoyu , view );//把实体数据重构到view中 BeanUtils.copyProperties(jiankangjiaoyu, view);
//修改对应字典表字段 // 调用字典服务的dictionaryConvert方法修改对应字典表字段
dictionaryService.dictionaryConvert(view, request); dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view); // 返回成功响应,并将健康教育视图对象放入响应数据中
}else { return R.ok().put("data", view);
return R.error(511,"查不到数据"); } else {
} // 如果未查询到数据返回错误响应错误码为511
return R.error(511, "查不到数据");
}
} }
/** /**
* *
*/ */
// 映射/add请求路径支持POST请求用于前端保存新的健康教育信息
@RequestMapping("/add") @RequestMapping("/add")
public R add(@RequestBody JiankangjiaoyuEntity jiankangjiaoyu, HttpServletRequest request){ public R add(@RequestBody JiankangjiaoyuEntity jiankangjiaoyu, HttpServletRequest request) {
logger.debug("add方法:,,Controller:{},,jiankangjiaoyu:{}",this.getClass().getName(),jiankangjiaoyu.toString()); // 记录方法调用日志,包含控制器类名和要保存的健康教育实体信息
logger.debug("add方法:,,Controller:{},,jiankangjiaoyu:{}", this.getClass().getName(), jiankangjiaoyu.toString());
// 创建查询包装器,用于构建查询条件,检查是否存在相同的健康教育信息
Wrapper<JiankangjiaoyuEntity> queryWrapper = new EntityWrapper<JiankangjiaoyuEntity>() Wrapper<JiankangjiaoyuEntity> queryWrapper = new EntityWrapper<JiankangjiaoyuEntity>()
.eq("jiankangjiaoyu_name", jiankangjiaoyu.getJiankangjiaoyuName()) .eq("jiankangjiaoyu_name", jiankangjiaoyu.getJiankangjiaoyuName())
.eq("jiankangjiaoyu_types", jiankangjiaoyu.getJiankangjiaoyuTypes()) .eq("jiankangjiaoyu_types", jiankangjiaoyu.getJiankangjiaoyuTypes())
.eq("jiankangjiaoyu_delete", jiankangjiaoyu.getJiankangjiaoyuDelete()) .eq("jiankangjiaoyu_delete", jiankangjiaoyu.getJiankangjiaoyuDelete());
;
logger.info("sql语句:"+queryWrapper.getSqlSegment()); // 记录生成的SQL查询语句
logger.info("sql语句:" + queryWrapper.getSqlSegment());
// 调用健康教育服务的selectOne方法根据查询条件查询是否存在相同数据
JiankangjiaoyuEntity jiankangjiaoyuEntity = jiankangjiaoyuService.selectOne(queryWrapper); JiankangjiaoyuEntity jiankangjiaoyuEntity = jiankangjiaoyuService.selectOne(queryWrapper);
if(jiankangjiaoyuEntity==null){ // 如果未查询到相同数据
if (jiankangjiaoyuEntity == null) {
// 设置插入时间为当前时间
jiankangjiaoyu.setInsertTime(new Date()); jiankangjiaoyu.setInsertTime(new Date());
// 设置逻辑删除字段为1表示未删除
jiankangjiaoyu.setJiankangjiaoyuDelete(1); jiankangjiaoyu.setJiankangjiaoyuDelete(1);
// 设置创建时间为当前时间
jiankangjiaoyu.setCreateTime(new Date()); jiankangjiaoyu.setCreateTime(new Date());
jiankangjiaoyuService.insert(jiankangjiaoyu); // 调用健康教育服务的insert方法将健康教育实体插入数据库
jiankangjiaoyuService.insert(jiankangjiaoyu);
// 返回成功响应
return R.ok(); return R.ok();
}else { } else {
return R.error(511,"表中有相同数据"); // 如果查询到相同数据返回错误响应错误码为511
return R.error(511, "表中有相同数据");
} }
} }
}
}

@ -1,35 +1,63 @@
package com.controller; package com.controller;
// 导入文件操作相关类
import java.io.File; import java.io.File;
// 导入用于高精度计算的类
import java.math.BigDecimal; import java.math.BigDecimal;
// 导入用于处理URL的类
import java.net.URL; import java.net.URL;
// 导入用于日期格式化的类
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
// 导入阿里巴巴的JSON对象类
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
// 导入常用的集合类
import java.util.*; import java.util.*;
// 导入Spring的Bean属性复制工具类
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
// 导入Servlet请求相关类
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
// 导入Spring的上下文加载器类
import org.springframework.web.context.ContextLoader; import org.springframework.web.context.ContextLoader;
// 导入Servlet上下文类
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
// 导入令牌服务类
import com.service.TokenService; import com.service.TokenService;
// 导入自定义工具类
import com.utils.*; import com.utils.*;
// 导入反射调用异常类
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
// 导入字典服务类
import com.service.DictionaryService; import com.service.DictionaryService;
// 导入Apache Commons提供的字符串工具类
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
// 导入自定义的忽略权限注解类
import com.annotation.IgnoreAuth; import com.annotation.IgnoreAuth;
// 导入日志记录器接口
import org.slf4j.Logger; import org.slf4j.Logger;
// 导入日志记录器工厂类
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
// 导入Spring的自动注入注解
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
// 导入Spring的控制器注解
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
// 导入Spring的请求映射注解
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
// 导入MyBatis-Plus的实体包装器类
import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.EntityWrapper;
// 导入MyBatis-Plus的查询包装器接口
import com.baomidou.mybatisplus.mapper.Wrapper; import com.baomidou.mybatisplus.mapper.Wrapper;
// 导入自定义的实体类
import com.entity.*; import com.entity.*;
// 导入自定义的视图类
import com.entity.view.*; import com.entity.view.*;
// 导入自定义的服务类
import com.service.*; import com.service.*;
// 导入自定义的分页工具类
import com.utils.PageUtils; import com.utils.PageUtils;
// 导入自定义的响应结果类
import com.utils.R; import com.utils.R;
// 导入阿里巴巴的JSON工具类
import com.alibaba.fastjson.*; import com.alibaba.fastjson.*;
/** /**
@ -37,268 +65,322 @@ import com.alibaba.fastjson.*;
* *
* @author * @author
* @email * @email
*/ */
// 声明该类为RESTful控制器用于处理HTTP请求并返回JSON数据
@RestController @RestController
// 声明该类为Spring MVC控制器
@Controller @Controller
// 映射请求路径,所有以/news开头的请求都会由该控制器处理
@RequestMapping("/news") @RequestMapping("/news")
public class NewsController { public class NewsController {
// 日志记录器,用于记录当前控制器类的日志信息
private static final Logger logger = LoggerFactory.getLogger(NewsController.class); private static final Logger logger = LoggerFactory.getLogger(NewsController.class);
// 自动注入新闻服务类,用于处理新闻相关业务逻辑
@Autowired @Autowired
private NewsService newsService; private NewsService newsService;
// 自动注入令牌服务类
@Autowired @Autowired
private TokenService tokenService; private TokenService tokenService;
// 自动注入字典服务类,用于字典表数据转换
@Autowired @Autowired
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
//级联表service // 级联表service自动注入用户服务类
@Autowired @Autowired
private YonghuService yonghuService; private YonghuService yonghuService;
// 级联表service自动注入医生服务类
@Autowired @Autowired
private YishengService yishengService; private YishengService yishengService;
/** /**
* *
*/ */
// 映射/page请求路径支持GET请求用于获取公告信息的分页列表
@RequestMapping("/page") @RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){ public R page(@RequestParam Map<String, Object> params, HttpServletRequest request) {
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); // 记录方法调用日志,包含控制器类名和请求参数
logger.debug("page方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params));
// 从请求会话中获取用户角色
String role = String.valueOf(request.getSession().getAttribute("role")); String role = String.valueOf(request.getSession().getAttribute("role"));
if(false) // 此条件永远为false注释掉的代码表示永远不会进入该分支
return R.error(511,"永不会进入"); if (false)
else if("用户".equals(role)) return R.error(511, "永不会进入");
params.put("yonghuId",request.getSession().getAttribute("userId")); // 如果用户角色为"用户"
else if("医生".equals(role)) else if ("用户".equals(role))
params.put("yishengId",request.getSession().getAttribute("userId")); // 在请求参数中添加用户id
if(params.get("orderBy")==null || params.get("orderBy")==""){ params.put("yonghuId", request.getSession().getAttribute("userId"));
params.put("orderBy","id"); // 如果用户角色为"医生"
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); PageUtils page = newsService.queryPage(params);
//字典表数据转换 // 将分页结果中的列表转换为新闻视图列表
List<NewsView> list =(List<NewsView>)page.getList(); List<NewsView> list = (List<NewsView>) page.getList();
for(NewsView c:list){ // 遍历新闻视图列表
//修改对应字典表字段 for (NewsView c : list) {
// 调用字典服务的dictionaryConvert方法修改对应字典表字段
dictionaryService.dictionaryConvert(c, request); dictionaryService.dictionaryConvert(c, request);
} }
// 返回成功响应,并将分页查询结果放入响应数据中
return R.ok().put("data", page); return R.ok().put("data", page);
} }
/** /**
* *
*/ */
// 映射/info/{id}请求路径支持GET请求{id}为路径变量用于获取指定id的公告信息详情
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){ public R info(@PathVariable("id") Long id, HttpServletRequest request) {
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录方法调用日志包含控制器类名和请求的id
logger.debug("info方法:,,Controller:{},,id:{}", this.getClass().getName(), id);
// 调用新闻服务的selectById方法根据id查询新闻实体
NewsEntity news = newsService.selectById(id); NewsEntity news = newsService.selectById(id);
if(news !=null){ // 如果查询到新闻实体
//entity转view if (news != null) {
// 创建新闻视图对象
NewsView view = new NewsView(); NewsView view = new NewsView();
BeanUtils.copyProperties( news , view );//把实体数据重构到view中 // 使用BeanUtils将新闻实体的属性复制到新闻视图中
BeanUtils.copyProperties(news, view);
//修改对应字典表字段 // 调用字典服务的dictionaryConvert方法修改对应字典表字段
dictionaryService.dictionaryConvert(view, request); dictionaryService.dictionaryConvert(view, request);
// 返回成功响应,并将新闻视图对象放入响应数据中
return R.ok().put("data", view); return R.ok().put("data", view);
}else { } else {
return R.error(511,"查不到数据"); // 如果未查询到数据返回错误响应错误码为511
return R.error(511, "查不到数据");
} }
} }
/** /**
* *
*/ */
// 映射/save请求路径支持POST请求用于保存新的公告信息
@RequestMapping("/save") @RequestMapping("/save")
public R save(@RequestBody NewsEntity news, HttpServletRequest request){ public R save(@RequestBody NewsEntity news, HttpServletRequest request) {
logger.debug("save方法:,,Controller:{},,news:{}",this.getClass().getName(),news.toString()); // 记录方法调用日志,包含控制器类名和要保存的新闻实体信息
logger.debug("save方法:,,Controller:{},,news:{}", this.getClass().getName(), news.toString());
// 从请求会话中获取用户角色
String role = String.valueOf(request.getSession().getAttribute("role")); String role = String.valueOf(request.getSession().getAttribute("role"));
if(false) // 此条件永远为false注释掉的代码表示永远不会进入该分支
return R.error(511,"永远不会进入"); if (false)
return R.error(511, "永远不会进入");
// 创建查询包装器,用于构建查询条件,检查是否存在相同的公告信息
Wrapper<NewsEntity> queryWrapper = new EntityWrapper<NewsEntity>() Wrapper<NewsEntity> queryWrapper = new EntityWrapper<NewsEntity>()
.eq("news_name", news.getNewsName()) .eq("news_name", news.getNewsName())
.eq("news_types", news.getNewsTypes()) .eq("news_types", news.getNewsTypes());
;
logger.info("sql语句:"+queryWrapper.getSqlSegment()); // 记录生成的SQL查询语句
logger.info("sql语句:" + queryWrapper.getSqlSegment());
// 调用新闻服务的selectOne方法根据查询条件查询是否存在相同数据
NewsEntity newsEntity = newsService.selectOne(queryWrapper); NewsEntity newsEntity = newsService.selectOne(queryWrapper);
if(newsEntity==null){ // 如果未查询到相同数据
if (newsEntity == null) {
// 设置插入时间为当前时间
news.setInsertTime(new Date()); news.setInsertTime(new Date());
// 设置创建时间为当前时间
news.setCreateTime(new Date()); news.setCreateTime(new Date());
// 调用新闻服务的insert方法将新闻实体插入数据库
newsService.insert(news); newsService.insert(news);
// 返回成功响应
return R.ok(); return R.ok();
}else { } else {
return R.error(511,"表中有相同数据"); // 如果查询到相同数据返回错误响应错误码为511
return R.error(511, "表中有相同数据");
} }
} }
/** /**
* *
*/ */
// 映射/update请求路径支持POST请求用于修改已有的公告信息
@RequestMapping("/update") @RequestMapping("/update")
public R update(@RequestBody NewsEntity news, HttpServletRequest request){ public R update(@RequestBody NewsEntity news, HttpServletRequest request) {
logger.debug("update方法:,,Controller:{},,news:{}",this.getClass().getName(),news.toString()); // 记录方法调用日志,包含控制器类名和要修改的新闻实体信息
logger.debug("update方法:,,Controller:{},,news:{}", this.getClass().getName(), news.toString());
// 从请求会话中获取用户角色
String role = String.valueOf(request.getSession().getAttribute("role")); String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false) // 此条件注释掉,表示永远不会进入该分支
// return R.error(511,"永远不会进入"); // if (false)
//根据字段查询是否有相同数据 // return R.error(511, "永远不会进入");
// 创建查询包装器,用于构建查询条件,排除当前要修改的记录,检查是否存在相同的公告信息
Wrapper<NewsEntity> queryWrapper = new EntityWrapper<NewsEntity>() Wrapper<NewsEntity> queryWrapper = new EntityWrapper<NewsEntity>()
.notIn("id",news.getId()) .notIn("id", news.getId())
.andNew() .andNew()
.eq("news_name", news.getNewsName()) .eq("news_name", news.getNewsName())
.eq("news_types", news.getNewsTypes()) .eq("news_types", news.getNewsTypes());
;
// 记录生成的SQL查询语句
logger.info("sql语句:"+queryWrapper.getSqlSegment()); logger.info("sql语句:" + queryWrapper.getSqlSegment());
// 调用新闻服务的selectOne方法根据查询条件查询是否存在相同数据
NewsEntity newsEntity = newsService.selectOne(queryWrapper); NewsEntity newsEntity = newsService.selectOne(queryWrapper);
if("".equals(news.getNewsPhoto()) || "null".equals(news.getNewsPhoto())){ // 如果新闻照片字段为空字符串或"null"则将其设置为null
news.setNewsPhoto(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(); return R.ok();
}else { } else {
return R.error(511,"表中有相同数据"); // 如果查询到相同数据返回错误响应错误码为511
return R.error(511, "表中有相同数据");
} }
} }
/** /**
* *
*/ */
// 映射/delete请求路径支持POST请求用于删除公告信息
@RequestMapping("/delete") @RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){ public R delete(@RequestBody Integer[] ids) {
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); // 记录方法调用日志包含控制器类名和要删除的记录id数组
logger.debug("delete:,,Controller:{},,ids:{}", this.getClass().getName(), ids.toString());
// 调用新闻服务的deleteBatchIds方法根据id数组批量删除记录
newsService.deleteBatchIds(Arrays.asList(ids)); newsService.deleteBatchIds(Arrays.asList(ids));
// 返回成功响应
return R.ok(); return R.ok();
} }
/** /**
* *
*/ */
// 映射/batchInsert请求路径支持POST请求用于批量上传公告信息
@RequestMapping("/batchInsert") @RequestMapping("/batchInsert")
public R save( String fileName){ public R save(String fileName) {
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); // 记录方法调用日志,包含控制器类名和文件名
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}", this.getClass().getName(), fileName);
try { try {
List<NewsEntity> newsList = new ArrayList<>();//上传的东西 // 创建一个列表,用于存储要上传的新闻实体
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段 List<NewsEntity> newsList = new ArrayList<>();
// 创建一个Map用于存储要查询的字段
Map<String, List<String>> seachFields = new HashMap<>();
// 获取当前时间
Date date = new Date(); Date date = new Date();
// 获取文件名中最后一个点的索引
int lastIndexOf = fileName.lastIndexOf("."); int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){ // 如果文件名中没有点返回错误响应错误码为511
return R.error(511,"该文件没有后缀"); if (lastIndexOf == -1) {
}else{ return R.error(511, "该文件没有后缀");
} else {
// 获取文件后缀
String suffix = fileName.substring(lastIndexOf); String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){ // 如果文件后缀不是.xls返回错误响应错误码为511
return R.error(511,"只支持后缀为xls的excel文件"); if (!".xls".equals(suffix)) {
}else{ return R.error(511, "只支持后缀为xls的excel文件");
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径 } else {
// 获取文件的URL
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);
// 创建文件对象
File file = new File(resource.getFile()); File file = new File(resource.getFile());
if(!file.exists()){ // 如果文件不存在返回错误响应错误码为511
return R.error(511,"找不到上传文件,请联系管理员"); if (!file.exists()) {
}else{ return R.error(511, "找不到上传文件,请联系管理员");
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件 } else {
dataList.remove(0);//删除第一行,因为第一行是提示 // 使用PoiUtil工具类读取xls文件的数据
for(List<String> data:dataList){ List<List<String>> dataList = PoiUtil.poiImport(file.getPath());
//循环 // 删除第一行数据,因为第一行通常是表头
dataList.remove(0);
// 遍历数据列表
for (List<String> data : dataList) {
// 创建一个新的新闻实体
NewsEntity newsEntity = new NewsEntity(); NewsEntity newsEntity = new NewsEntity();
// 以下代码注释掉,表示需要根据实际情况修改字段赋值
// newsEntity.setNewsName(data.get(0)); //公告名称 要改的 // newsEntity.setNewsName(data.get(0)); //公告名称 要改的
// newsEntity.setNewsPhoto("");//照片 // newsEntity.setNewsPhoto("");//照片
// newsEntity.setNewsTypes(Integer.valueOf(data.get(0))); //公告类型 要改的 // newsEntity.setNewsTypes(Integer.valueOf(data.get(0))); //公告类型 要改的
// newsEntity.setInsertTime(date);//时间 // newsEntity.setInsertTime(date);//时间
// newsEntity.setNewsContent("");//照片 // newsEntity.setNewsContent("");//照片
// newsEntity.setCreateTime(date);//时间 // newsEntity.setCreateTime(date);//时间
// 将新闻实体添加到上传列表中
newsList.add(newsEntity); newsList.add(newsEntity);
// 把要查询是否重复的字段放入map中
//把要查询是否重复的字段放入map中
} }
//查询是否重复 // 调用新闻服务的insertBatch方法批量插入新闻实体
newsService.insertBatch(newsList); newsService.insertBatch(newsList);
// 返回成功响应
return R.ok(); return R.ok();
} }
} }
} }
}catch (Exception e){ } catch (Exception e) {
return R.error(511,"批量插入数据异常,请联系管理员"); // 如果发生异常返回错误响应错误码为511
return R.error(511, "批量插入数据异常,请联系管理员");
} }
} }
/** /**
* *
*/ */
// 映射/list请求路径支持GET请求用于前端获取公告信息的分页列表忽略权限验证
@IgnoreAuth @IgnoreAuth
@RequestMapping("/list") @RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){ public R list(@RequestParam Map<String, Object> params, HttpServletRequest request) {
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); // 记录方法调用日志,包含控制器类名和请求参数
logger.debug("list方法:,,Controller:{},,params:{}", this.getClass().getName(), JSONObject.toJSONString(params));
// 没有指定排序字段就默认id倒 // 如果请求参数中没有指定排序字段则默认按id倒序排
if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){ if (StringUtil.isEmpty(String.valueOf(params.get("orderBy")))) {
params.put("orderBy","id"); params.put("orderBy", "id");
} }
// 调用新闻服务的queryPage方法根据请求参数进行分页查询
PageUtils page = newsService.queryPage(params); PageUtils page = newsService.queryPage(params);
//字典表数据转换 // 将分页结果中的列表转换为新闻视图列表
List<NewsView> list =(List<NewsView>)page.getList(); List<NewsView> list = (List<NewsView>) page.getList();
for(NewsView c:list) // 遍历新闻视图列表
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段 for (NewsView c : list)
// 调用字典服务的dictionaryConvert方法修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
// 返回成功响应,并将分页查询结果放入响应数据中
return R.ok().put("data", page); return R.ok().put("data", page);
} }
/** /**
* *
*/ */
// 映射/detail/{id}请求路径支持GET请求{id}为路径变量用于前端获取指定id的公告信息详情
@RequestMapping("/detail/{id}") @RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id, HttpServletRequest request){ public R detail(@PathVariable("id") Long id, HttpServletRequest request) {
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id); // 记录方法调用日志包含控制器类名和请求的id
logger.debug("detail方法:,,Controller:{},,id:{}", this.getClass().getName(), id);
// 调用新闻服务的selectById方法根据id查询新闻实体
NewsEntity news = newsService.selectById(id); NewsEntity news = newsService.selectById(id);
if(news !=null){ // 如果查询到新闻实体
if (news != null) {
// 创建新闻视图对象
//entity转view NewsView view = new NewsView();
NewsView view = new NewsView(); // 使用BeanUtils将新闻实体的属性复制到新闻视图中
BeanUtils.copyProperties( news , view );//把实体数据重构到view中 BeanUtils.copyProperties(news, view);
//修改对应字典表字段 // 调用字典服务的dictionaryConvert方法修改对应字典表字段
dictionaryService.dictionaryConvert(view, request); dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view); // 返回成功响应,并将新闻视图对象放入响应数据中
}else { return R.ok().put("data", view);
return R.error(511,"查不到数据"); } else {
} // 如果未查询到数据返回错误响应错误码为511
return R.error(511, "查不到数据");
}
} }
/** /**
* *
*/ */
// 映射/add请求路径支持POST请求用于前端保存新的公告信息
@RequestMapping("/add") @RequestMapping("/add")
public R add(@RequestBody NewsEntity news, HttpServletRequest request){ public R add(@RequestBody NewsEntity news, HttpServletRequest request) {
logger.debug("add方法:,,Controller:{},,news:{}",this.getClass().getName(),news.toString()); // 记录方法调用日志,包含控制器类名和要保存的新闻实体信息
Wrapper<NewsEntity> queryWrapper = new EntityWrapper<NewsEntity>() logger.debug("add方法:,,Controller:{},,news:{}", this.getClass().getName(), news.toString());
.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,"表中有相同数据");
}
}
}

@ -1,7 +1,5 @@
package com.controller; package com.controller;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map; import java.util.Map;
@ -28,141 +26,209 @@ import com.utils.R;
/** /**
* *
*/ */
// 定义请求映射路径,所有以/users开头的请求会被该控制器处理
@RequestMapping("users") @RequestMapping("users")
// 声明该类为一个RESTful风格的控制器用于处理HTTP请求并返回JSON数据
@RestController @RestController
public class UsersController { public class UsersController {
// 自动注入UsersService用于处理与用户相关的业务逻辑
@Autowired @Autowired
private UsersService usersService; private UsersService usersService;
// 自动注入TokenService用于处理与令牌相关的业务逻辑
@Autowired @Autowired
private TokenService tokenService; private TokenService tokenService;
/** /**
* *
* @param username
* @param password
* @param captcha 使
* @param request HTTP
* @return R
*/ */
@IgnoreAuth @IgnoreAuth // 忽略权限验证的注解
@PostMapping(value = "/login") @PostMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) { public R login(String username, String password, String captcha, HttpServletRequest request) {
// 根据用户名查询用户实体
UsersEntity user = usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username)); UsersEntity user = usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username));
if(user==null || !user.getPassword().equals(password)) { // 如果用户不存在或者用户输入的密码与数据库中存储的密码不匹配
if (user == null || !user.getPassword().equals(password)) {
// 返回错误响应,提示账号或密码不正确
return R.error("账号或密码不正确"); 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 r = R.ok();
// 将生成的令牌放入响应数据中
r.put("token", token); 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; return r;
} }
/** /**
* *
*/ */
@IgnoreAuth @IgnoreAuth
@PostMapping(value = "/register") @PostMapping(value = "/register")
public R register(@RequestBody UsersEntity user){ public R register(@RequestBody UsersEntity user) {
// ValidatorUtils.validateEntity(user); // ValidatorUtils.validateEntity(user); // 被注释掉的代码,可能用于验证用户实体的合法性,目前未启用
if(usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) !=null) { // 根据用户名查询数据库,判断用户是否已经存在
return R.error("用户已存在"); if (usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) != null) {
} // 如果用户已存在,返回错误响应
usersService.insert(user); return R.error("用户已存在");
return R.ok(); }
} // 将新用户插入到数据库中
usersService.insert(user);
// 返回成功响应
return R.ok();
}
/** /**
* 退 * 退
*/ */
@GetMapping(value = "logout") @GetMapping(value = "logout")
public R logout(HttpServletRequest request) { public R logout(HttpServletRequest request) {
// 使当前用户的会话失效,实现退出登录
request.getSession().invalidate(); request.getSession().invalidate();
// 返回成功响应,并附带退出成功的提示信息
return R.ok("退出成功"); return R.ok("退出成功");
} }
/** /**
* *
*/ * @param username
@IgnoreAuth * @param request HTTP
* @return R
*/
@IgnoreAuth // 忽略权限验证的注解
@RequestMapping(value = "/resetPass") @RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){ public R resetPass(String username, HttpServletRequest request) {
UsersEntity user = usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username)); // 根据用户名查询用户实体
if(user==null) { UsersEntity user = usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username));
return R.error("账号不存在"); // 如果用户不存在
} if (user == null) {
user.setPassword("123456"); // 返回错误响应,提示账号不存在
usersService.update(user,null); return R.error("账号不存在");
return R.ok("密码已重置为123456"); }
} // 将用户密码重置为默认值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<String, Object> params, UsersEntity user) {
// 创建一个EntityWrapper对象用于构建查询条件
EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>();
// 调用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
@RequestMapping("/page") * @return R
public R page(@RequestParam Map<String, Object> params,UsersEntity user){ */
EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>(); @RequestMapping("/list")
PageUtils page = usersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params)); public R list(UsersEntity user) {
return R.ok().put("data", page); // 创建一个EntityWrapper对象
} EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>();
// 根据用户实体对象构建查询条件使用MPUtil.allEQMapPre方法设置相等条件
ew.allEq(MPUtil.allEQMapPre(user, "user"));
// 调用usersService的selectListView方法查询用户列表并将结果放入响应中返回
return R.ok().put("data", usersService.selectListView(ew));
}
/** /**
* *
*/ * @param id ID
@RequestMapping("/list") * @return R
public R list( UsersEntity user){ */
EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>(); @RequestMapping("/info/{id}")
ew.allEq(MPUtil.allEQMapPre( user, "user")); public R info(@PathVariable("id") String id) {
return R.ok().put("data", usersService.selectListView(ew)); // 根据用户ID查询用户实体
} UsersEntity user = usersService.selectById(id);
// 返回成功响应,并将用户信息放入响应中
/** return R.ok().put("data", user);
* }
*/
@RequestMapping("/info/{id}") /**
public R info(@PathVariable("id") String id){ *
UsersEntity user = usersService.selectById(id); * @param request HTTP
return R.ok().put("data", user); * @return R
} */
@RequestMapping("/session")
/** public R getCurrUser(HttpServletRequest request) {
* session // 从当前会话中获取用户ID
*/ Integer id = (Integer) request.getSession().getAttribute("userId");
@RequestMapping("/session") // 根据用户ID查询用户实体
public R getCurrUser(HttpServletRequest request){ UsersEntity user = usersService.selectById(id);
Integer id = (Integer)request.getSession().getAttribute("userId"); // 返回成功响应,并将用户信息放入响应中
UsersEntity user = usersService.selectById(id); return R.ok().put("data", user);
return R.ok().put("data", user); }
}
/**
/** *
* * @param user
*/ * @return R
@PostMapping("/save") */
public R save(@RequestBody UsersEntity user){ @PostMapping("/save")
// ValidatorUtils.validateEntity(user); public R save(@RequestBody UsersEntity user) {
if(usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) !=null) { // ValidatorUtils.validateEntity(user); // 被注释掉的代码,可能用于验证用户实体的合法性,目前未启用
return R.error("用户已存在"); // 根据用户名查询数据库,判断用户是否已经存在
} if (usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) != null) {
user.setPassword("123456"); // 如果用户已存在,返回错误响应
usersService.insert(user); return R.error("用户已存在");
return R.ok(); }
} // 设置用户密码为默认值123456
user.setPassword("123456");
/** // 将用户插入到数据库中
* usersService.insert(user);
*/ // 返回成功响应
@RequestMapping("/update") return R.ok();
public R update(@RequestBody UsersEntity user){ }
// ValidatorUtils.validateEntity(user);
usersService.updateById(user);//全部更新 /**
return R.ok(); *
} * @param user
* @return R
/** */
* @RequestMapping("/update")
*/ public R update(@RequestBody UsersEntity user) {
@RequestMapping("/delete") // ValidatorUtils.validateEntity(user); // 被注释掉的代码,可能用于验证用户实体的合法性,目前未启用
public R delete(@RequestBody Long[] ids){ // 根据用户ID更新用户信息到数据库
usersService.deleteBatchIds(Arrays.asList(ids)); usersService.updateById(user); // 全部更新
return R.ok(); // 返回成功响应
} 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();
}
}

@ -36,278 +36,307 @@ import com.alibaba.fastjson.*;
* *
* @author * @author
* @email * @email
*/ */
@RestController @RestController
// 声明为Spring MVC控制器
@Controller @Controller
// 定义请求映射路径,所有以/yisheng开头的请求由该控制器处理
@RequestMapping("/yisheng") @RequestMapping("/yisheng")
public class YishengController { public class YishengController {
// 日志记录器,用于记录当前控制器的日志信息
private static final Logger logger = LoggerFactory.getLogger(YishengController.class); private static final Logger logger = LoggerFactory.getLogger(YishengController.class);
// 自动注入医生服务类,用于处理医生相关业务逻辑
@Autowired @Autowired
private YishengService yishengService; // 医生服务 private YishengService yishengService;
@Autowired @Autowired
private TokenService tokenService; // token服务 private TokenService tokenService;
@Autowired @Autowired
private DictionaryService dictionaryService; // 字典服务 private DictionaryService dictionaryService;
//级联表service
// 级联表service自动注入用户服务类
@Autowired @Autowired
private YonghuService yonghuService; // 用户服务 private YonghuService yonghuService;
/** /**
* *
*/ */
@RequestMapping("/page") @RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){ public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role")); // 获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role"));
if(false) if(false)
return R.error(511,"永不会进入"); return R.error(511,"永不会进入");
else if("用户".equals(role)) else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId")); // 如果是用户角色添加用户ID参数 params.put("yonghuId",request.getSession().getAttribute("userId"));
else if("医生".equals(role)) else if("医生".equals(role))
params.put("yishengId",request.getSession().getAttribute("userId")); // 如果是医生角色添加医生ID参数 params.put("yishengId",request.getSession().getAttribute("userId"));
if(params.get("orderBy")==null || params.get("orderBy")==""){ if(params.get("orderBy")==null || params.get("orderBy")==""){
params.put("orderBy","id"); // 默认按ID排序 params.put("orderBy","id");
} }
PageUtils page = yishengService.queryPage(params); // 分页查询 PageUtils page = yishengService.queryPage(params);
//字典表数据转换 //字典表数据转换
List<YishengView> list =(List<YishengView>)page.getList(); List<YishengView> list =(List<YishengView>)page.getList();
for(YishengView c:list){ for(YishengView c:list){
//修改对应字典表字段 //修改对应字典表字段
dictionaryService.dictionaryConvert(c, request); // 转换字典字段 dictionaryService.dictionaryConvert(c, request);
} }
return R.ok().put("data", page); // 返回分页数据 return R.ok().put("data", page);
} }
/** /**
* *
*/ */
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){ public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
YishengEntity yisheng = yishengService.selectById(id); // 根据ID查询医生 YishengEntity yisheng = yishengService.selectById(id);
if(yisheng !=null){ if(yisheng !=null){
//entity转view //entity转view
YishengView view = new YishengView(); YishengView view = new YishengView();
BeanUtils.copyProperties( yisheng , view ); // 把实体数据重构到view中 BeanUtils.copyProperties( yisheng , view );//把实体数据重构到view中
//修改对应字典表字段 //修改对应字典表字段
dictionaryService.dictionaryConvert(view, request); // 转换字典字段 dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view); // 返回医生详情 return R.ok().put("data", view);
}else { }else {
return R.error(511,"查不到数据"); // 查询不到返回错误 return R.error(511,"查不到数据");
} }
} }
/** /**
* *
*/ */
@RequestMapping("/save") @RequestMapping("/save")
public R save(@RequestBody YishengEntity yisheng, HttpServletRequest request){ public R save(@RequestBody YishengEntity yisheng, HttpServletRequest request) {
logger.debug("save方法:,,Controller:{},,yisheng:{}",this.getClass().getName(),yisheng.toString()); // 记录方法调用日志,包含控制器类名和要保存的医生实体信息
logger.debug("save方法:,,Controller:{},,yisheng:{}", this.getClass().getName(), yisheng.toString());
String role = String.valueOf(request.getSession().getAttribute("role")); // 获取用户角色 String role = String.valueOf(request.getSession().getAttribute("role"));
if(false) if(false)
return R.error(511,"永远不会进入"); return R.error(511,"永远不会进入");
// 构建查询条件:用户名或手机号
Wrapper<YishengEntity> queryWrapper = new EntityWrapper<YishengEntity>() Wrapper<YishengEntity> queryWrapper = new EntityWrapper<YishengEntity>()
.eq("username", yisheng.getUsername()) .eq("username", yisheng.getUsername())
.or() .or()
.eq("yisheng_phone", yisheng.getYishengPhone()); .eq("yisheng_phone", yisheng.getYishengPhone());
logger.info("sql语句:"+queryWrapper.getSqlSegment()); logger.info("sql语句:"+queryWrapper.getSqlSegment());
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper); // 查询是否已存在 YishengEntity yishengEntity = yishengService.selectOne(queryWrapper);
if(yishengEntity==null){ if(yishengEntity==null){
yisheng.setCreateTime(new Date()); // 设置创建时间 yisheng.setCreateTime(new Date());
yisheng.setPassword("123456"); // 设置默认密码 yisheng.setPassword("123456");
yishengService.insert(yisheng); // 插入新医生数据 yishengService.insert(yisheng);
return R.ok(); // 返回成功 return R.ok();
}else { }else {
return R.error(511,"账户或者联系方式已经被使用"); // 已存在返回错误 return R.error(511,"账户或者联系方式已经被使用");
} }
} }
/** /**
* *
*/ */
@RequestMapping("/update") @RequestMapping("/update")
public R update(@RequestBody YishengEntity yisheng, HttpServletRequest request){ public R update(@RequestBody YishengEntity yisheng, HttpServletRequest request) {
logger.debug("update方法:,,Controller:{},,yisheng:{}",this.getClass().getName(),yisheng.toString()); // 记录方法调用日志,包含控制器类名和要更新的医生实体信息
logger.debug("update方法:,,Controller:{},,yisheng:{}", this.getClass().getName(), yisheng.toString());
String role = String.valueOf(request.getSession().getAttribute("role")); // 获取用户角色
// 构建查询条件排除当前ID查询用户名或手机号是否已被其他记录使用 String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
//根据字段查询是否有相同数据
Wrapper<YishengEntity> queryWrapper = new EntityWrapper<YishengEntity>() Wrapper<YishengEntity> queryWrapper = new EntityWrapper<YishengEntity>()
.notIn("id",yisheng.getId()) .notIn("id",yisheng.getId())
.andNew() .andNew()
.eq("username", yisheng.getUsername()) .eq("username", yisheng.getUsername())
.or() .or()
.eq("yisheng_phone", yisheng.getYishengPhone()); .eq("yisheng_phone", yisheng.getYishengPhone())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment()); logger.info("sql语句:"+queryWrapper.getSqlSegment());
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper); // 查询是否冲突 YishengEntity yishengEntity = yishengService.selectOne(queryWrapper);
if("".equals(yisheng.getYishengPhoto()) || "null".equals(yisheng.getYishengPhoto())){ if("".equals(yisheng.getYishengPhoto()) || "null".equals(yisheng.getYishengPhoto())){
yisheng.setYishengPhoto(null); // 处理空照片 yisheng.setYishengPhoto(null);
} }
if(yishengEntity==null){ if(yishengEntity==null){
yishengService.updateById(yisheng); // 根据id更新 yishengService.updateById(yisheng);//根据id更新
return R.ok(); // 返回成功 return R.ok();
}else { }else {
return R.error(511,"账户或者联系方式已经被使用"); // 冲突返回错误 return R.error(511,"账户或者联系方式已经被使用");
} }
} }
/** /**
* *
*/ */
@RequestMapping("/delete") @RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){ public R delete(@RequestBody Integer[] ids){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
yishengService.deleteBatchIds(Arrays.asList(ids)); // 批量删除 yishengService.deleteBatchIds(Arrays.asList(ids));
return R.ok(); // 返回成功 return R.ok();
} }
/** /**
* *
*/ */
@RequestMapping("/batchInsert") @RequestMapping("/batchInsert")
public R save( String fileName){ public R save(String fileName) {
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName); // 记录方法调用日志,包含控制器类名和文件名
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}", this.getClass().getName(), fileName);
try { try {
List<YishengEntity> yishengList = new ArrayList<>(); // 上传的数据列表 List<YishengEntity> yishengList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>(); // 要查询的字段 Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date(); Date date = new Date();
// 获取文件名中最后一个点的索引
int lastIndexOf = fileName.lastIndexOf("."); int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){ if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀"); // 文件后缀检查 return R.error(511,"该文件没有后缀");
}else{ }else{
String suffix = fileName.substring(lastIndexOf); String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){ if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件"); // 文件格式检查 return R.error(511,"只支持后缀为xls的excel文件");
}else{ }else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName); // 获取文件路径 URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
File file = new File(resource.getFile()); File file = new File(resource.getFile());
if(!file.exists()){ if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员"); // 文件存在检查 return R.error(511,"找不到上传文件,请联系管理员");
}else{ }else{
List<List<String>> dataList = PoiUtil.poiImport(file.getPath()); // 读取xls文件 List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0); // 删除第一行提示 dataList.remove(0);//删除第一行,因为第一行是提示
for(List<String> data:dataList){ for(List<String> data:dataList){
//循环处理每行数据 //循环
YishengEntity yishengEntity = new YishengEntity(); YishengEntity yishengEntity = new YishengEntity();
// 这里注释掉的代码是字段映射示例实际使用时需要根据Excel列对应关系修改 // yishengEntity.setYishengUuidNumber(data.get(0)); //医生工号 要改的
yishengList.add(yishengEntity); // 添加到列表 // yishengEntity.setUsername(data.get(0)); //账户 要改的
// //yishengEntity.setPassword("123456");//密码
// 把要查询是否重复的字段放入map中 // yishengEntity.setYishengName(data.get(0)); //医生名称 要改的
// 医生工号 // yishengEntity.setYishengTypes(Integer.valueOf(data.get(0))); //科室 要改的
if(seachFields.containsKey("yishengUuidNumber")){ // yishengEntity.setZhiweiTypes(Integer.valueOf(data.get(0))); //职位 要改的
List<String> yishengUuidNumber = seachFields.get("yishengUuidNumber"); // yishengEntity.setYishengZhichneg(data.get(0)); //职称 要改的
yishengUuidNumber.add(data.get(0)); // 要改的 // yishengEntity.setYishengPhoto("");//照片
}else{ // yishengEntity.setYishengPhone(data.get(0)); //联系方式 要改的
List<String> yishengUuidNumber = new ArrayList<>(); // yishengEntity.setYishengGuahao(data.get(0)); //挂号须知 要改的
yishengUuidNumber.add(data.get(0)); // 要改的 // yishengEntity.setYishengEmail(data.get(0)); //邮箱 要改的
seachFields.put("yishengUuidNumber",yishengUuidNumber); // yishengEntity.setYishengNewMoney(data.get(0)); //挂号价格 要改的
} // yishengEntity.setYishengContent("");//照片
// 账户 // yishengEntity.setCreateTime(date);//时间
if(seachFields.containsKey("username")){ yishengList.add(yishengEntity);
List<String> username = seachFields.get("username");
username.add(data.get(0)); // 要改的
}else{ //把要查询是否重复的字段放入map中
List<String> username = new ArrayList<>(); //医生工号
username.add(data.get(0)); // 要改的 if(seachFields.containsKey("yishengUuidNumber")){
seachFields.put("username",username); List<String> yishengUuidNumber = seachFields.get("yishengUuidNumber");
} yishengUuidNumber.add(data.get(0));//要改的
// 联系方式 }else{
if(seachFields.containsKey("yishengPhone")){ List<String> yishengUuidNumber = new ArrayList<>();
List<String> yishengPhone = seachFields.get("yishengPhone"); yishengUuidNumber.add(data.get(0));//要改的
yishengPhone.add(data.get(0)); // 要改的 seachFields.put("yishengUuidNumber",yishengUuidNumber);
}else{ }
List<String> yishengPhone = new ArrayList<>(); //账户
yishengPhone.add(data.get(0)); // 要改的 if(seachFields.containsKey("username")){
seachFields.put("yishengPhone",yishengPhone); List<String> username = seachFields.get("username");
} username.add(data.get(0));//要改的
}else{
List<String> username = new ArrayList<>();
username.add(data.get(0));//要改的
seachFields.put("username",username);
}
//联系方式
if(seachFields.containsKey("yishengPhone")){
List<String> yishengPhone = seachFields.get("yishengPhone");
yishengPhone.add(data.get(0));//要改的
}else{
List<String> yishengPhone = new ArrayList<>();
yishengPhone.add(data.get(0));//要改的
seachFields.put("yishengPhone",yishengPhone);
}
} }
// 查询是否重复 //查询是否重复
// 医生工号 //医生工号
List<YishengEntity> yishengEntities_yishengUuidNumber = yishengService.selectList(new EntityWrapper<YishengEntity>().in("yisheng_uuid_number", seachFields.get("yishengUuidNumber"))); List<YishengEntity> yishengEntities_yishengUuidNumber = yishengService.selectList(new EntityWrapper<YishengEntity>().in("yisheng_uuid_number", seachFields.get("yishengUuidNumber")));
if(yishengEntities_yishengUuidNumber.size() >0 ){ if (yishengEntities_yishengUuidNumber.size() > 0) {
ArrayList<String> repeatFields = new ArrayList<>(); ArrayList<String> repeatFields = new ArrayList<>();
for(YishengEntity s:yishengEntities_yishengUuidNumber){ for (YishengEntity s : yishengEntities_yishengUuidNumber) {
repeatFields.add(s.getYishengUuidNumber()); repeatFields.add(s.getYishengUuidNumber());
} }
return R.error(511,"数据库的该表中的 [医生工号] 字段已经存在 存在数据为:"+repeatFields.toString()); return R.error(511, "数据库的该表中的 [医生工号] 字段已经存在 存在数据为:" + repeatFields.toString());
} }
// 账户 // 账户
List<YishengEntity> yishengEntities_username = yishengService.selectList(new EntityWrapper<YishengEntity>().in("username", seachFields.get("username"))); List<YishengEntity> yishengEntities_username = yishengService.selectList(new EntityWrapper<YishengEntity>().in("username", seachFields.get("username")));
if(yishengEntities_username.size() >0 ){ if (yishengEntities_username.size() > 0) {
ArrayList<String> repeatFields = new ArrayList<>(); ArrayList<String> repeatFields = new ArrayList<>();
for(YishengEntity s:yishengEntities_username){ for (YishengEntity s : yishengEntities_username) {
repeatFields.add(s.getUsername()); repeatFields.add(s.getUsername());
} }
return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString()); return R.error(511, "数据库的该表中的 [账户] 字段已经存在 存在数据为:" + repeatFields.toString());
} }
// 联系方式 // 联系方式
List<YishengEntity> yishengEntities_yishengPhone = yishengService.selectList(new EntityWrapper<YishengEntity>().in("yisheng_phone", seachFields.get("yishengPhone"))); List<YishengEntity> yishengEntities_yishengPhone = yishengService.selectList(new EntityWrapper<YishengEntity>().in("yisheng_phone", seachFields.get("yishengPhone")));
if(yishengEntities_yishengPhone.size() >0 ){ if (yishengEntities_yishengPhone.size() > 0) {
ArrayList<String> repeatFields = new ArrayList<>(); ArrayList<String> repeatFields = new ArrayList<>();
for(YishengEntity s:yishengEntities_yishengPhone){ for (YishengEntity s : yishengEntities_yishengPhone) {
repeatFields.add(s.getYishengPhone()); repeatFields.add(s.getYishengPhone());
} }
return R.error(511,"数据库的该表中的 [联系方式] 字段已经存在 存在数据为:"+repeatFields.toString()); return R.error(511, "数据库的该表中的 [联系方式] 字段已经存在 存在数据为:" + repeatFields.toString());
} }
yishengService.insertBatch(yishengList); // 批量插入 yishengService.insertBatch(yishengList);
return R.ok(); return R.ok();
} }
} }
} }
}catch (Exception e){ }catch (Exception e){
return R.error(511,"批量插入数据异常,请联系管理员"); // 异常处理 return R.error(511,"批量插入数据异常,请联系管理员");
} }
} }
/** /**
* *
*/ */
@IgnoreAuth @IgnoreAuth
@RequestMapping(value = "/login") @RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) { public R login(String username, String password, String captcha, HttpServletRequest request) {
YishengEntity yisheng = yishengService.selectOne(new EntityWrapper<YishengEntity>().eq("username", username)); // 根据用户名查询 YishengEntity yisheng = yishengService.selectOne(new EntityWrapper<YishengEntity>().eq("username", username));
if(yisheng==null || !yisheng.getPassword().equals(password)) if(yisheng==null || !yisheng.getPassword().equals(password))
return R.error("账号或密码不正确"); // 验证账号密码 return R.error("账号或密码不正确");
String token = tokenService.generateToken(yisheng.getId(),username, "yisheng", "医生"); // 生成token // // 获取监听器中的字典表
// ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
// Map<String, Map<Integer, String>> dictionaryMap= (Map<String, Map<Integer, String>>) servletContext.getAttribute("dictionaryMap");
// Map<Integer, String> role_types = dictionaryMap.get("role_types");
// role_types.get(.getRoleTypes());
String token = tokenService.generateToken(yisheng.getId(),username, "yisheng", "医生");
R r = R.ok(); R r = R.ok();
r.put("token", token); // 返回token r.put("token", token);
r.put("role","医生"); // 返回角色 r.put("role","医生");
r.put("username",yisheng.getYishengName()); // 返回医生姓名 r.put("username",yisheng.getYishengName());
r.put("tableName","yisheng"); // 返回表名 r.put("tableName","yisheng");
r.put("userId",yisheng.getId()); // 返回用户ID r.put("userId",yisheng.getId());
return r; return r;
} }
/** /**
* *
*/ */
@IgnoreAuth @IgnoreAuth
@PostMapping(value = "/register") @PostMapping(value = "/register")
public R register(@RequestBody YishengEntity yisheng){ public R register(@RequestBody YishengEntity yisheng){
// 构建查询条件:用户名或手机号 // ValidatorUtils.validateEntity(user);
Wrapper<YishengEntity> queryWrapper = new EntityWrapper<YishengEntity>() Wrapper<YishengEntity> queryWrapper = new EntityWrapper<YishengEntity>()
.eq("username", yisheng.getUsername()) .eq("username", yisheng.getUsername())
.or() .or()
.eq("yisheng_phone", yisheng.getYishengPhone()); .eq("yisheng_phone", yisheng.getYishengPhone())
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper); // 查询是否已存在 ;
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper);
if(yishengEntity != null) if(yishengEntity != null)
return R.error("账户或者联系方式已经被使用"); // 已存在返回错误 return R.error("账户或者联系方式已经被使用");
yisheng.setYishengNewMoney(0.0); // 设置初始金额 yisheng.setYishengNewMoney(0.0);
yisheng.setCreateTime(new Date()); // 设置创建时间 yisheng.setCreateTime(new Date());
yishengService.insert(yisheng); // 插入新医生 yishengService.insert(yisheng);
return R.ok(); // 返回成功 return R.ok();
} }
/** /**
@ -316,63 +345,69 @@ public class YishengController {
@GetMapping(value = "/resetPassword") @GetMapping(value = "/resetPassword")
public R resetPassword(Integer id){ public R resetPassword(Integer id){
YishengEntity yisheng = new YishengEntity(); YishengEntity yisheng = new YishengEntity();
yisheng.setPassword("123456"); // 重置为默认密码 yisheng.setPassword("123456");
yisheng.setId(id); yisheng.setId(id);
yishengService.updateById(yisheng); // 更新密码 yishengService.updateById(yisheng);
return R.ok(); // 返回成功 return R.ok();
} }
/** /**
* *
*/ */
@IgnoreAuth @IgnoreAuth
@RequestMapping(value = "/resetPass") @RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request) { public R resetPass(String username, HttpServletRequest request) {
YishengEntity yisheng = yishengService.selectOne(new EntityWrapper<YishengEntity>().eq("username", username)); // 根据用户名查询 YishengEntity yisheng = yishengService.selectOne(new EntityWrapper<YishengEntity>().eq("username", username));
if(yisheng!=null){ if(yisheng!=null){
yisheng.setPassword("123456"); // 重置为默认密码 yisheng.setPassword("123456");
boolean b = yishengService.updateById(yisheng); // 更新密码 boolean b = yishengService.updateById(yisheng);
if(!b){ if(!b){
return R.error(); // 更新失败 return R.error();
} }
}else{ }else{
return R.error("账号不存在"); // 账号不存在 return R.error("账号不存在");
} }
return R.ok(); // 返回成功 return R.ok();
} }
/** /**
* session * session
*/ */
@RequestMapping("/session") @RequestMapping("/session")
public R getCurrYisheng(HttpServletRequest request){ public R getCurrYisheng(HttpServletRequest request){
Integer id = (Integer)request.getSession().getAttribute("userId"); // 获取session中的用户ID Integer id = (Integer)request.getSession().getAttribute("userId");
YishengEntity yisheng = yishengService.selectById(id); // 查询用户信息 YishengEntity yisheng = yishengService.selectById(id);
if(yisheng !=null){ if(yisheng !=null){
//entity转view //entity转view
YishengView view = new YishengView(); YishengView view = new YishengView();
BeanUtils.copyProperties( yisheng , view ); // 复制属性到view BeanUtils.copyProperties( yisheng , view );//把实体数据重构到view中
//修改对应字典表字段 //修改对应字典表字段
dictionaryService.dictionaryConvert(view, request); // 转换字典字段 dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view); // 返回用户信息 return R.ok().put("data", view);
}else { }else {
return R.error(511,"查不到数据"); // 查询不到返回错误 return R.error(511,"查不到数据");
} }
} }
/** /**
* 退 * 退
*/ */
@GetMapping(value = "logout") @GetMapping(value = "logout")
public R logout(HttpServletRequest request) { public R logout(HttpServletRequest request) {
request.getSession().invalidate(); // 使session失效 request.getSession().invalidate();
return R.ok("退出成功"); // 返回退出成功 return R.ok("退出成功");
} }
/** /**
* *
*/ */
@IgnoreAuth @IgnoreAuth
@RequestMapping("/list") @RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){ public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
@ -382,55 +417,60 @@ public class YishengController {
if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){ if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
params.put("orderBy","id"); params.put("orderBy","id");
} }
PageUtils page = yishengService.queryPage(params); // 分页查询 PageUtils page = yishengService.queryPage(params);
//字典表数据转换 //字典表数据转换
List<YishengView> list =(List<YishengView>)page.getList(); List<YishengView> list =(List<YishengView>)page.getList();
for(YishengView c:list) for(YishengView c:list)
dictionaryService.dictionaryConvert(c, request); // 转换字典字段 dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
return R.ok().put("data", page); // 返回分页数据 return R.ok().put("data", page);
} }
/** /**
* *
*/ */
@RequestMapping("/detail/{id}") @RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id, HttpServletRequest request){ public R detail(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id); logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
YishengEntity yisheng = yishengService.selectById(id); // 根据ID查询 YishengEntity yisheng = yishengService.selectById(id);
if(yisheng !=null){ if(yisheng !=null){
//entity转view
YishengView view = new YishengView();
BeanUtils.copyProperties( yisheng , view ); // 复制属性到view
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request); // 转换字典字段 //entity转view
return R.ok().put("data", view); // 返回详情 YishengView view = new YishengView();
}else { BeanUtils.copyProperties( yisheng , view );//把实体数据重构到view中
return R.error(511,"查不到数据"); // 查询不到返回错误
} //修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
} }
/** /**
* *
*/ */
@RequestMapping("/add") @RequestMapping("/add")
public R add(@RequestBody YishengEntity yisheng, HttpServletRequest request){ public R add(@RequestBody YishengEntity yisheng, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,yisheng:{}",this.getClass().getName(),yisheng.toString()); logger.debug("add方法:,,Controller:{},,yisheng:{}",this.getClass().getName(),yisheng.toString());
// 构建查询条件:用户名或手机号
Wrapper<YishengEntity> queryWrapper = new EntityWrapper<YishengEntity>() Wrapper<YishengEntity> queryWrapper = new EntityWrapper<YishengEntity>()
.eq("username", yisheng.getUsername()) .eq("username", yisheng.getUsername())
.or() .or()
.eq("yisheng_phone", yisheng.getYishengPhone()); .eq("yisheng_phone", yisheng.getYishengPhone())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment()); logger.info("sql语句:"+queryWrapper.getSqlSegment());
YishengEntity yishengEntity = yishengService.selectOne(queryWrapper); // 查询是否已存在 YishengEntity yishengEntity = yishengService.selectOne(queryWrapper);
if(yishengEntity==null){ if(yishengEntity==null){
yisheng.setCreateTime(new Date()); // 设置创建时间 yisheng.setCreateTime(new Date());
yisheng.setPassword("123456"); // 设置默认密码 yisheng.setPassword("123456");
yishengService.insert(yisheng); // 插入新医生 yishengService.insert(yisheng);
return R.ok(); // 返回成功 return R.ok();
}else { }else {
return R.error(511,"账户或者联系方式已经被使用"); // 已存在返回错误 return R.error(511,"账户或者联系方式已经被使用");
} }
} }
}
}

@ -32,11 +32,11 @@ import com.utils.R;
import com.alibaba.fastjson.*; import com.alibaba.fastjson.*;
/** /**
* *
* *
* @author * @author
* @email * @email
*/ */
@RestController @RestController
@Controller @Controller
@RequestMapping("/yonghu") @RequestMapping("/yonghu")
@ -44,69 +44,61 @@ public class YonghuController {
private static final Logger logger = LoggerFactory.getLogger(YonghuController.class); private static final Logger logger = LoggerFactory.getLogger(YonghuController.class);
@Autowired @Autowired
private YonghuService yonghuService; // 用户服务 private YonghuService yonghuService;
@Autowired @Autowired
private TokenService tokenService; // token服务 private TokenService tokenService;
@Autowired @Autowired
private DictionaryService dictionaryService; // 字典服务 private DictionaryService dictionaryService; // 字典服务
//级联表service //级联表service
@Autowired @Autowired
private YishengService yishengService; // 医生服务 private YishengService yishengService;
/** /**
* *
* */
*/
@RequestMapping("/page") @RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){ public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params)); logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role")); String role = String.valueOf(request.getSession().getAttribute("role"));
// 权限控制
if(false) if(false)
return R.error(511,"永不会进入"); return R.error(511,"永不会进入");
else if("用户".equals(role)) else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId")); // 如果是用户角色,只查询自己的数据 params.put("yonghuId",request.getSession().getAttribute("userId"));
else if("医生".equals(role)) else if("医生".equals(role))
params.put("yishengId",request.getSession().getAttribute("userId")); // 如果是医生角色添加医生ID参数 params.put("yishengId",request.getSession().getAttribute("userId"));
// 设置查询未删除的用户删除状态为1表示未删除
params.put("yonghuDeleteStart",1);params.put("yonghuDeleteEnd",1); params.put("yonghuDeleteStart",1);params.put("yonghuDeleteEnd",1);
// 默认按id排序
if(params.get("orderBy")==null || params.get("orderBy")==""){ if(params.get("orderBy")==null || params.get("orderBy")==""){
params.put("orderBy","id"); params.put("orderBy","id");
} }
// 调用服务层查询分页数据
PageUtils page = yonghuService.queryPage(params); PageUtils page = yonghuService.queryPage(params);
// 字典表数据转换 //字典表数据转换
List<YonghuView> list =(List<YonghuView>)page.getList(); List<YonghuView> list =(List<YonghuView>)page.getList();
for(YonghuView c:list){ for(YonghuView c:list){
// 修改对应字典表字段 //修改对应字典表字段
dictionaryService.dictionaryConvert(c, request); dictionaryService.dictionaryConvert(c, request);
} }
return R.ok().put("data", page); return R.ok().put("data", page);
} }
/** /**
* *
* ID */
*/
@RequestMapping("/info/{id}") @RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){ public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id); logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
// 根据ID查询用户
YonghuEntity yonghu = yonghuService.selectById(id); YonghuEntity yonghu = yonghuService.selectById(id);
if(yonghu !=null){ if(yonghu !=null){
// entity转view //entity转view
YonghuView view = new YonghuView(); YonghuView view = new YonghuView();
BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中 BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中
// 修改对应字典表字段 //修改对应字典表字段
dictionaryService.dictionaryConvert(view, request); dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view); return R.ok().put("data", view);
}else { }else {
@ -115,9 +107,8 @@ public class YonghuController {
} }
/** /**
* *
* */
*/
@RequestMapping("/save") @RequestMapping("/save")
public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){ public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString()); logger.debug("save方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
@ -126,24 +117,23 @@ public class YonghuController {
if(false) if(false)
return R.error(511,"永远不会进入"); return R.error(511,"永远不会进入");
// 构建查询条件:检查用户名、手机号、身份证号是否已存在
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>() Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
.eq("username", yonghu.getUsername()) .eq("username", yonghu.getUsername())
.or() .or()
.eq("yonghu_phone", yonghu.getYonghuPhone()) .eq("yonghu_phone", yonghu.getYonghuPhone())
.or() .or()
.eq("yonghu_id_number", yonghu.getYonghuIdNumber()) .eq("yonghu_id_number", yonghu.getYonghuIdNumber())
.andNew() .andNew()
.eq("yonghu_delete", 1) // 未删除的用户 .eq("yonghu_delete", 1)
; ;
logger.info("sql语句:"+queryWrapper.getSqlSegment()); logger.info("sql语句:"+queryWrapper.getSqlSegment());
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper); YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
if(yonghuEntity==null){ if(yonghuEntity==null){
yonghu.setYonghuDelete(1); // 设置未删除状态 yonghu.setYonghuDelete(1);
yonghu.setCreateTime(new Date()); // 设置创建时间 yonghu.setCreateTime(new Date());
yonghu.setPassword("123456"); // 设置默认密码 yonghu.setPassword("123456");
yonghuService.insert(yonghu); // 插入新用户 yonghuService.insert(yonghu);
return R.ok(); return R.ok();
}else { }else {
return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用"); return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用");
@ -151,32 +141,32 @@ public class YonghuController {
} }
/** /**
* *
* */
*/
@RequestMapping("/update") @RequestMapping("/update")
public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request){ public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString()); logger.debug("update方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
String role = String.valueOf(request.getSession().getAttribute("role")); String role = String.valueOf(request.getSession().getAttribute("role"));
// 构建查询条件:检查其他用户是否已使用要修改的用户名、手机号或身份证号 // if(false)
// return R.error(511,"永远不会进入");
//根据字段查询是否有相同数据
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>() Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
.notIn("id",yonghu.getId()) // 排除当前用户 .notIn("id",yonghu.getId())
.andNew() .andNew()
.eq("username", yonghu.getUsername()) .eq("username", yonghu.getUsername())
.or() .or()
.eq("yonghu_phone", yonghu.getYonghuPhone()) .eq("yonghu_phone", yonghu.getYonghuPhone())
.or() .or()
.eq("yonghu_id_number", yonghu.getYonghuIdNumber()) .eq("yonghu_id_number", yonghu.getYonghuIdNumber())
.andNew() .andNew()
.eq("yonghu_delete", 1) // 未删除的用户 .eq("yonghu_delete", 1)
; ;
logger.info("sql语句:"+queryWrapper.getSqlSegment()); logger.info("sql语句:"+queryWrapper.getSqlSegment());
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper); YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
// 处理空照片
if("".equals(yonghu.getYonghuPhoto()) || "null".equals(yonghu.getYonghuPhoto())){ if("".equals(yonghu.getYonghuPhoto()) || "null".equals(yonghu.getYonghuPhoto())){
yonghu.setYonghuPhoto(null); yonghu.setYonghuPhoto(null);
} }
if(yonghuEntity==null){ if(yonghuEntity==null){
yonghuService.updateById(yonghu);//根据id更新 yonghuService.updateById(yonghu);//根据id更新
@ -187,9 +177,8 @@ public class YonghuController {
} }
/** /**
* *
* 2 */
*/
@RequestMapping("/delete") @RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){ public R delete(@RequestBody Integer[] ids){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
@ -197,18 +186,17 @@ public class YonghuController {
for(Integer id:ids){ for(Integer id:ids){
YonghuEntity yonghuEntity = new YonghuEntity(); YonghuEntity yonghuEntity = new YonghuEntity();
yonghuEntity.setId(id); yonghuEntity.setId(id);
yonghuEntity.setYonghuDelete(2); // 设置删除状态为2 yonghuEntity.setYonghuDelete(2);
list.add(yonghuEntity); list.add(yonghuEntity);
} }
if(list != null && list.size() >0){ if(list != null && list.size() >0){
yonghuService.updateBatchById(list); // 批量更新 yonghuService.updateBatchById(list);
} }
return R.ok(); return R.ok();
} }
/** /**
* *
* Excel
*/ */
@RequestMapping("/batchInsert") @RequestMapping("/batchInsert")
public R save( String fileName){ public R save( String fileName){
@ -235,41 +223,52 @@ public class YonghuController {
for(List<String> data:dataList){ for(List<String> data:dataList){
//循环 //循环
YonghuEntity yonghuEntity = new YonghuEntity(); YonghuEntity yonghuEntity = new YonghuEntity();
// 这里注释掉的代码是示例实际应该根据Excel列映射字段 // 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); yonghuList.add(yonghuEntity);
//把要查询是否重复的字段放入map中 //把要查询是否重复的字段放入map中
//账户 //账户
if(seachFields.containsKey("username")){ if(seachFields.containsKey("username")){
List<String> username = seachFields.get("username"); List<String> username = seachFields.get("username");
username.add(data.get(0));//要改的 username.add(data.get(0));//要改的
}else{ }else{
List<String> username = new ArrayList<>(); List<String> username = new ArrayList<>();
username.add(data.get(0));//要改的 username.add(data.get(0));//要改的
seachFields.put("username",username); seachFields.put("username",username);
} }
//用户手机号 //用户手机号
if(seachFields.containsKey("yonghuPhone")){ if(seachFields.containsKey("yonghuPhone")){
List<String> yonghuPhone = seachFields.get("yonghuPhone"); List<String> yonghuPhone = seachFields.get("yonghuPhone");
yonghuPhone.add(data.get(0));//要改的 yonghuPhone.add(data.get(0));//要改的
}else{ }else{
List<String> yonghuPhone = new ArrayList<>(); List<String> yonghuPhone = new ArrayList<>();
yonghuPhone.add(data.get(0));//要改的 yonghuPhone.add(data.get(0));//要改的
seachFields.put("yonghuPhone",yonghuPhone); seachFields.put("yonghuPhone",yonghuPhone);
} }
//用户身份证号 //用户身份证号
if(seachFields.containsKey("yonghuIdNumber")){ if(seachFields.containsKey("yonghuIdNumber")){
List<String> yonghuIdNumber = seachFields.get("yonghuIdNumber"); List<String> yonghuIdNumber = seachFields.get("yonghuIdNumber");
yonghuIdNumber.add(data.get(0));//要改的 yonghuIdNumber.add(data.get(0));//要改的
}else{ }else{
List<String> yonghuIdNumber = new ArrayList<>(); List<String> yonghuIdNumber = new ArrayList<>();
yonghuIdNumber.add(data.get(0));//要改的 yonghuIdNumber.add(data.get(0));//要改的
seachFields.put("yonghuIdNumber",yonghuIdNumber); seachFields.put("yonghuIdNumber",yonghuIdNumber);
} }
} }
//查询是否重复 //查询是否重复
//账户 //账户
List<YonghuEntity> yonghuEntities_username = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("username", seachFields.get("username")).eq("yonghu_delete", 1)); List<YonghuEntity> yonghuEntities_username = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("username", seachFields.get("username")).eq("yonghu_delete", 1));
if(yonghuEntities_username.size() >0 ){ if(yonghuEntities_username.size() >0 ){
ArrayList<String> repeatFields = new ArrayList<>(); ArrayList<String> repeatFields = new ArrayList<>();
@ -278,7 +277,7 @@ public class YonghuController {
} }
return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString()); return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());
} }
//用户手机号 //用户手机号
List<YonghuEntity> yonghuEntities_yonghuPhone = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_phone", seachFields.get("yonghuPhone")).eq("yonghu_delete", 1)); List<YonghuEntity> yonghuEntities_yonghuPhone = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_phone", seachFields.get("yonghuPhone")).eq("yonghu_delete", 1));
if(yonghuEntities_yonghuPhone.size() >0 ){ if(yonghuEntities_yonghuPhone.size() >0 ){
ArrayList<String> repeatFields = new ArrayList<>(); ArrayList<String> repeatFields = new ArrayList<>();
@ -287,7 +286,7 @@ public class YonghuController {
} }
return R.error(511,"数据库的该表中的 [用户手机号] 字段已经存在 存在数据为:"+repeatFields.toString()); return R.error(511,"数据库的该表中的 [用户手机号] 字段已经存在 存在数据为:"+repeatFields.toString());
} }
//用户身份证号 //用户身份证号
List<YonghuEntity> yonghuEntities_yonghuIdNumber = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_id_number", seachFields.get("yonghuIdNumber")).eq("yonghu_delete", 1)); List<YonghuEntity> yonghuEntities_yonghuIdNumber = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_id_number", seachFields.get("yonghuIdNumber")).eq("yonghu_delete", 1));
if(yonghuEntities_yonghuIdNumber.size() >0 ){ if(yonghuEntities_yonghuIdNumber.size() >0 ){
ArrayList<String> repeatFields = new ArrayList<>(); ArrayList<String> repeatFields = new ArrayList<>();
@ -307,20 +306,21 @@ public class YonghuController {
} }
/** /**
* *
* */
*/
@IgnoreAuth @IgnoreAuth
@RequestMapping(value = "/login") @RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) { public R login(String username, String password, String captcha, HttpServletRequest request) {
// 根据用户名查询用户
YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username)); YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));
if(yonghu==null || !yonghu.getPassword().equals(password)) if(yonghu==null || !yonghu.getPassword().equals(password))
return R.error("账号或密码不正确"); return R.error("账号或密码不正确");
else if(yonghu.getYonghuDelete() != 1) else if(yonghu.getYonghuDelete() != 1)
return R.error("账户已被删除"); return R.error("账户已被删除");
// // 获取监听器中的字典表
// 生成token // ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
// Map<String, Map<Integer, String>> dictionaryMap= (Map<String, Map<Integer, String>>) servletContext.getAttribute("dictionaryMap");
// Map<Integer, String> role_types = dictionaryMap.get("role_types");
// role_types.get(.getRoleTypes());
String token = tokenService.generateToken(yonghu.getId(),username, "yonghu", "用户"); String token = tokenService.generateToken(yonghu.getId(),username, "yonghu", "用户");
R r = R.ok(); R r = R.ok();
r.put("token", token); r.put("token", token);
@ -332,27 +332,24 @@ public class YonghuController {
} }
/** /**
* *
* */
*/
@IgnoreAuth @IgnoreAuth
@PostMapping(value = "/register") @PostMapping(value = "/register")
public R register(@RequestBody YonghuEntity yonghu){ public R register(@RequestBody YonghuEntity yonghu){
// 检查用户名、手机号、身份证号是否已存在 // ValidatorUtils.validateEntity(user);
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>() Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
.eq("username", yonghu.getUsername()) .eq("username", yonghu.getUsername())
.or() .or()
.eq("yonghu_phone", yonghu.getYonghuPhone()) .eq("yonghu_phone", yonghu.getYonghuPhone())
.or() .or()
.eq("yonghu_id_number", yonghu.getYonghuIdNumber()) .eq("yonghu_id_number", yonghu.getYonghuIdNumber())
.andNew() .andNew()
.eq("yonghu_delete", 1) .eq("yonghu_delete", 1)
; ;
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper); YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
if(yonghuEntity != null) if(yonghuEntity != null)
return R.error("账户或者用户手机号或者用户身份证号已经被使用"); return R.error("账户或者用户手机号或者用户身份证号已经被使用");
// 设置默认值
yonghu.setNewMoney(0.0); yonghu.setNewMoney(0.0);
yonghu.setYonghuDelete(1); yonghu.setYonghuDelete(1);
yonghu.setCreateTime(new Date()); yonghu.setCreateTime(new Date());
@ -362,41 +359,40 @@ public class YonghuController {
/** /**
* *
* 123456
*/ */
@GetMapping(value = "/resetPassword") @GetMapping(value = "/resetPassword")
public R resetPassword(Integer id){ public R resetPassword(Integer id){
YonghuEntity yonghu = new YonghuEntity(); YonghuEntity yonghu = new YonghuEntity();
yonghu.setPassword("123456"); // 设置默认密码 yonghu.setPassword("123456");
yonghu.setId(id); yonghu.setId(id);
yonghuService.updateById(yonghu); yonghuService.updateById(yonghu);
return R.ok(); return R.ok();
} }
/** /**
* *
*
*/ */
@IgnoreAuth @IgnoreAuth
@RequestMapping(value = "/resetPass") @RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request) { public R resetPass(String username, HttpServletRequest request) {
YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username)); YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));
if(yonghu!=null){ if(yonghu!=null){
yonghu.setPassword("123456"); // 重置为默认密码 yonghu.setPassword("123456");
boolean b = yonghuService.updateById(yonghu); boolean b = yonghuService.updateById(yonghu);
if(!b){ if(!b){
return R.error(); return R.error();
} }
}else{ }else{
return R.error("账号不存在"); return R.error("账号不存在");
} }
return R.ok(); return R.ok();
} }
/** /**
* session * session
* */
*/
@RequestMapping("/session") @RequestMapping("/session")
public R getCurrYonghu(HttpServletRequest request){ public R getCurrYonghu(HttpServletRequest request){
Integer id = (Integer)request.getSession().getAttribute("userId"); Integer id = (Integer)request.getSession().getAttribute("userId");
@ -414,20 +410,22 @@ public class YonghuController {
} }
} }
/** /**
* 退 * 退
* */
*/
@GetMapping(value = "logout") @GetMapping(value = "logout")
public R logout(HttpServletRequest request) { public R logout(HttpServletRequest request) {
request.getSession().invalidate(); // 使session失效 request.getSession().invalidate();
return R.ok("退出成功"); return R.ok("退出成功");
} }
/** /**
* *
* 使 */
*/
@IgnoreAuth @IgnoreAuth
@RequestMapping("/list") @RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){ public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
@ -447,53 +445,55 @@ public class YonghuController {
} }
/** /**
* *
* 使 */
*/
@RequestMapping("/detail/{id}") @RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id, HttpServletRequest request){ public R detail(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id); logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
YonghuEntity yonghu = yonghuService.selectById(id); YonghuEntity yonghu = yonghuService.selectById(id);
if(yonghu !=null){ if(yonghu !=null){
//entity转view
YonghuView view = new YonghuView();
BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request); //entity转view
return R.ok().put("data", view); YonghuView view = new YonghuView();
}else { BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中
return R.error(511,"查不到数据");
} //修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
} }
/** /**
* *
* 使 */
*/
@RequestMapping("/add") @RequestMapping("/add")
public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){ public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString()); logger.debug("add方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
// 检查用户名、手机号、身份证号是否已存在
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>() Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
.eq("username", yonghu.getUsername()) .eq("username", yonghu.getUsername())
.or() .or()
.eq("yonghu_phone", yonghu.getYonghuPhone()) .eq("yonghu_phone", yonghu.getYonghuPhone())
.or() .or()
.eq("yonghu_id_number", yonghu.getYonghuIdNumber()) .eq("yonghu_id_number", yonghu.getYonghuIdNumber())
.andNew() .andNew()
.eq("yonghu_delete", 1) .eq("yonghu_delete", 1)
; ;
logger.info("sql语句:"+queryWrapper.getSqlSegment()); logger.info("sql语句:"+queryWrapper.getSqlSegment());
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper); YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
if(yonghuEntity==null){ if(yonghuEntity==null){
yonghu.setYonghuDelete(1); // 设置未删除状态 yonghu.setYonghuDelete(1);
yonghu.setCreateTime(new Date()); // 设置创建时间 yonghu.setCreateTime(new Date());
yonghu.setPassword("123456"); // 设置默认密码 yonghu.setPassword("123456");
yonghuService.insert(yonghu); yonghuService.insert(yonghu);
return R.ok(); return R.ok();
}else { }else {
return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用"); return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用");
} }
} }
}
}

@ -1,277 +1,310 @@
package com.entity; package com.entity;
// 导入 MyBatis-Plus 用于指定主键的注解
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotations.TableId;
// 导入 MyBatis-Plus 用于指定数据库表名的注解
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
// 导入 JSR 303 验证注解,确保字段不为空字符串
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
// 导入 JSR 303 验证注解,确保集合或数组不为空
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
// 导入 JSR 303 验证注解,确保字段不为 null
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
// 导入 Jackson 注解,用于忽略 JSON 序列化和反序列化时的某些属性
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
// 导入反射调用可能抛出的异常类
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
// 导入序列化接口
import java.io.Serializable; import java.io.Serializable;
// 导入日期类
import java.util.Date; import java.util.Date;
// 导入列表集合类
import java.util.List; import java.util.List;
// 导入 Spring 框架用于日期格式化的注解
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
// 导入 Jackson 用于 JSON 序列化时日期格式化的注解
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
// 导入 Apache Commons BeanUtils 工具类,用于对象属性复制
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
// 导入 MyBatis-Plus 用于指定字段的注解
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotations.TableField;
// 导入 MyBatis-Plus 字段填充策略枚举
import com.baomidou.mybatisplus.enums.FieldFill; import com.baomidou.mybatisplus.enums.FieldFill;
// 导入 MyBatis-Plus 主键生成策略枚举
import com.baomidou.mybatisplus.enums.IdType; import com.baomidou.mybatisplus.enums.IdType;
/** /**
* 线 * 线
* *
* @author * @author
* @email * @email
*/ */
// 指定该类对应数据库中的 chat 表
@TableName("chat") @TableName("chat")
// 实现 Serializable 接口,使该类的对象可以进行序列化和反序列化操作
public class ChatEntity<T> implements Serializable { public class ChatEntity<T> implements Serializable {
// 序列化版本号,确保序列化和反序列化的兼容性
private static final long serialVersionUID = 1L; 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) @TableId(type = IdType.AUTO)
// 指定该字段对应数据库表中的 id 字段
@TableField(value = "id") @TableField(value = "id")
// 主键,用于唯一标识一条在线咨询记录
private Integer id; private Integer id;
/** /**
* *
*/ */
// 指定该字段对应数据库表中的 yonghu_id 字段
@TableField(value = "yonghu_id") @TableField(value = "yonghu_id")
// 提问用户的 ID关联用户表
private Integer yonghuId; private Integer yonghuId;
/** /**
* *
*/ */
// 指定该字段对应数据库表中的 chat_issue 字段
@TableField(value = "chat_issue") @TableField(value = "chat_issue")
// 用户提出的问题内容
private String chatIssue; private String chatIssue;
/** /**
* *
*/ */
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss"
@DateTimeFormat @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
// 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象
@DateTimeFormat
// 指定该字段对应数据库表中的 issue_time 字段
@TableField(value = "issue_time") @TableField(value = "issue_time")
// 用户提出问题的时间
private Date issueTime; private Date issueTime;
/** /**
* *
*/ */
// 指定该字段对应数据库表中的 chat_reply 字段
@TableField(value = "chat_reply") @TableField(value = "chat_reply")
// 针对用户问题的回复内容
private String chatReply; private String chatReply;
/** /**
* *
*/ */
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss"
@DateTimeFormat @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
// 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象
@DateTimeFormat
// 指定该字段对应数据库表中的 reply_time 字段
@TableField(value = "reply_time") @TableField(value = "reply_time")
// 回复用户问题的时间
private Date replyTime; private Date replyTime;
/** /**
* *
*/ */
// 指定该字段对应数据库表中的 zhuangtai_types 字段
@TableField(value = "zhuangtai_types") @TableField(value = "zhuangtai_types")
// 在线咨询的状态,可能用整数表示不同状态,如 0 表示待回复1 表示已回复等
private Integer zhuangtaiTypes; private Integer zhuangtaiTypes;
/** /**
* *
*/ */
// 指定该字段对应数据库表中的 chat_types 字段
@TableField(value = "chat_types") @TableField(value = "chat_types")
// 在线咨询的数据类型,可能用整数表示不同类型,如 1 表示文字咨询2 表示图片咨询等
private Integer chatTypes; private Integer chatTypes;
/** /**
* *
*/ */
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss"
@DateTimeFormat @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(value = "insert_time",fill = FieldFill.INSERT) // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象
@DateTimeFormat
// 指定该字段对应数据库表中的 insert_time 字段,且在插入数据时自动填充
@TableField(value = "insert_time", fill = FieldFill.INSERT)
// 该条在线咨询记录的创建时间
private Date insertTime; private Date insertTime;
/** /**
* *
*/ */
// 获取主键的方法
public Integer getId() { public Integer getId() {
return id; return id;
} }
/** /**
* *
*/ */
// 设置主键的方法
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
/** /**
* *
*/ */
// 获取提问用户 ID 的方法
public Integer getYonghuId() { public Integer getYonghuId() {
return yonghuId; return yonghuId;
} }
/** /**
* *
*/ */
// 设置提问用户 ID 的方法
public void setYonghuId(Integer yonghuId) { public void setYonghuId(Integer yonghuId) {
this.yonghuId = yonghuId; this.yonghuId = yonghuId;
} }
/** /**
* *
*/ */
// 获取问题内容的方法
public String getChatIssue() { public String getChatIssue() {
return chatIssue; return chatIssue;
} }
/** /**
* *
*/ */
// 设置问题内容的方法
public void setChatIssue(String chatIssue) { public void setChatIssue(String chatIssue) {
this.chatIssue = chatIssue; this.chatIssue = chatIssue;
} }
/** /**
* *
*/ */
// 获取问题时间的方法
public Date getIssueTime() { public Date getIssueTime() {
return issueTime; return issueTime;
} }
/** /**
* *
*/ */
// 设置问题时间的方法
public void setIssueTime(Date issueTime) { public void setIssueTime(Date issueTime) {
this.issueTime = issueTime; this.issueTime = issueTime;
} }
/** /**
* *
*/ */
// 获取回复内容的方法
public String getChatReply() { public String getChatReply() {
return chatReply; return chatReply;
} }
/** /**
* *
*/ */
// 设置回复内容的方法
public void setChatReply(String chatReply) { public void setChatReply(String chatReply) {
this.chatReply = chatReply; this.chatReply = chatReply;
} }
/** /**
* *
*/ */
// 获取回复时间的方法
public Date getReplyTime() { public Date getReplyTime() {
return replyTime; return replyTime;
} }
/** /**
* *
*/ */
// 设置回复时间的方法
public void setReplyTime(Date replyTime) { public void setReplyTime(Date replyTime) {
this.replyTime = replyTime; this.replyTime = replyTime;
} }
/** /**
* *
*/ */
// 获取状态的方法
public Integer getZhuangtaiTypes() { public Integer getZhuangtaiTypes() {
return zhuangtaiTypes; return zhuangtaiTypes;
} }
/** /**
* *
*/ */
// 设置状态的方法
public void setZhuangtaiTypes(Integer zhuangtaiTypes) { public void setZhuangtaiTypes(Integer zhuangtaiTypes) {
this.zhuangtaiTypes = zhuangtaiTypes; this.zhuangtaiTypes = zhuangtaiTypes;
} }
/** /**
* *
*/ */
// 获取数据类型的方法
public Integer getChatTypes() { public Integer getChatTypes() {
return chatTypes; return chatTypes;
} }
/** /**
* *
*/ */
// 设置数据类型的方法
public void setChatTypes(Integer chatTypes) { public void setChatTypes(Integer chatTypes) {
this.chatTypes = chatTypes; this.chatTypes = chatTypes;
} }
/** /**
* *
*/ */
// 获取创建时间的方法
public Date getInsertTime() { public Date getInsertTime() {
return insertTime; return insertTime;
} }
/** /**
* *
*/ */
// 设置创建时间的方法
public void setInsertTime(Date insertTime) { public void setInsertTime(Date insertTime) {
this.insertTime = insertTime; this.insertTime = insertTime;
} }
// 重写 toString 方法,方便打印对象信息
@Override @Override
public String toString() { public String toString() {
return "Chat{" + return "Chat{" +
"id=" + id + "id=" + id +
", yonghuId=" + yonghuId + ", yonghuId=" + yonghuId +
", chatIssue=" + chatIssue + ", chatIssue=" + chatIssue +
", issueTime=" + issueTime + ", issueTime=" + issueTime +
", chatReply=" + chatReply + ", chatReply=" + chatReply +
", replyTime=" + replyTime + ", replyTime=" + replyTime +
", zhuangtaiTypes=" + zhuangtaiTypes + ", zhuangtaiTypes=" + zhuangtaiTypes +
", chatTypes=" + chatTypes + ", chatTypes=" + chatTypes +
", insertTime=" + insertTime + ", insertTime=" + insertTime +
"}"; "}";
} }
} }

@ -7,22 +7,21 @@ import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType; import com.baomidou.mybatisplus.enums.IdType;
/** /**
* @author yangliyuan * @author yangliyuan
* @version 202027 8:36:05 * @version 202027 8:36:05
* : * :
*/ */
@TableName("config") @TableName("config")
public class ConfigEntity implements Serializable{ public class ConfigEntity implements Serializable{
private static final long serialVersionUID = 1L; // 定义主键字段
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private Long id; private Long id;
/** /**
* key * name
*/ */
private String name; private String name;
/** /**
* value * value
*/ */
@ -51,5 +50,4 @@ private static final long serialVersionUID = 1L;
public void setValue(String value) { public void setValue(String value) {
this.value = value; this.value = value;
} }
}
}

@ -1,249 +1,276 @@
package com.entity; package com.entity;
// 导入 MyBatis-Plus 用于指定主键的注解
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotations.TableId;
// 导入 MyBatis-Plus 用于指定数据库表名的注解
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
// 导入 JSR 303 验证注解(在当前代码中未实际使用)
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
// 导入 Jackson 注解(在当前代码中未实际使用)
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
// 导入反射调用可能抛出的异常类
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
// 导入序列化接口
import java.io.Serializable; import java.io.Serializable;
// 导入日期类
import java.util.Date; import java.util.Date;
// 导入列表集合类(在当前代码中未实际使用)
import java.util.List; import java.util.List;
// 导入 Spring 框架用于日期格式化的注解
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
// 导入 Jackson 用于 JSON 序列化时日期格式化的注解
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
// 导入 Apache Commons BeanUtils 工具类,用于对象属性复制
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
// 导入 MyBatis-Plus 用于指定字段的注解
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotations.TableField;
// 导入 MyBatis-Plus 字段填充策略枚举
import com.baomidou.mybatisplus.enums.FieldFill; import com.baomidou.mybatisplus.enums.FieldFill;
// 导入 MyBatis-Plus 主键生成策略枚举
import com.baomidou.mybatisplus.enums.IdType; import com.baomidou.mybatisplus.enums.IdType;
/** /**
* *
* *
* @author * @author
* @email * @email
*/ */
// 使用 TableName 注解指定该类对应的数据库表名为 "dictionary"
@TableName("dictionary") @TableName("dictionary")
// 定义泛型类 DictionaryEntity实现 Serializable 接口,以便对象可以进行序列化和反序列化
public class DictionaryEntity<T> implements Serializable { public class DictionaryEntity<T> implements Serializable {
// 定义序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性
private static final long serialVersionUID = 1L; 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) @TableId(type = IdType.AUTO)
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "id"
@TableField(value = "id") @TableField(value = "id")
// 存储字典表记录的主键值,用于唯一标识一条记录
private Integer id; private Integer id;
/** /**
* *
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "dic_code"
@TableField(value = "dic_code") @TableField(value = "dic_code")
// 存储字典表中的字段代码,可能用于标识不同的字典项类别等
private String dicCode; private String dicCode;
/** /**
* *
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "dic_name"
@TableField(value = "dic_name") @TableField(value = "dic_name")
// 存储字典表中字段的名称,与 dicCode 对应,提供更易读的名称标识
private String dicName; private String dicName;
/** /**
* *
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "code_index"
@TableField(value = "code_index") @TableField(value = "code_index")
// 存储字典表中某一字典项的编码值,可能用于内部编码或排序等用途
private Integer codeIndex; private Integer codeIndex;
/** /**
* *
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "index_name"
@TableField(value = "index_name") @TableField(value = "index_name")
// 存储编码对应的名称,与 codeIndex 对应,提供更详细的编码描述
private String indexName; private String indexName;
/** /**
* id * id
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "super_id"
@TableField(value = "super_id") @TableField(value = "super_id")
// 存储当前字典项的父字段 ID用于表示字典项之间的层级关系
private Integer superId; private Integer superId;
/** /**
* *
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "beizhu"
@TableField(value = "beizhu") @TableField(value = "beizhu")
// 存储关于当前字典项的备注信息,用于记录额外的说明或注意事项
private String beizhu; private String beizhu;
/** /**
* *
*/ */
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss"
@DateTimeFormat @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(value = "create_time",fill = FieldFill.INSERT) // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象
@DateTimeFormat
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "create_time"
// 并设置在插入数据时自动填充当前时间
@TableField(value = "create_time", fill = FieldFill.INSERT)
// 存储字典表记录的创建时间,用于记录数据的创建时间戳
private Date createTime; private Date createTime;
/** /**
* *
*/ */
// 获取主键值的方法,外部可以通过调用该方法获取 id 字段的值
public Integer getId() { public Integer getId() {
return id; return id;
} }
/** /**
* *
*/ */
// 设置主键值的方法,外部可以通过调用该方法设置 id 字段的值
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
/** /**
* *
*/ */
// 获取字段代码值的方法,外部可以通过调用该方法获取 dicCode 字段的值
public String getDicCode() { public String getDicCode() {
return dicCode; return dicCode;
} }
/** /**
* *
*/ */
// 设置字段代码值的方法,外部可以通过调用该方法设置 dicCode 字段的值
public void setDicCode(String dicCode) { public void setDicCode(String dicCode) {
this.dicCode = dicCode; this.dicCode = dicCode;
} }
/** /**
* *
*/ */
// 获取字段名称值的方法,外部可以通过调用该方法获取 dicName 字段的值
public String getDicName() { public String getDicName() {
return dicName; return dicName;
} }
/** /**
* *
*/ */
// 设置字段名称值的方法,外部可以通过调用该方法设置 dicName 字段的值
public void setDicName(String dicName) { public void setDicName(String dicName) {
this.dicName = dicName; this.dicName = dicName;
} }
/** /**
* *
*/ */
// 获取编码值的方法,外部可以通过调用该方法获取 codeIndex 字段的值
public Integer getCodeIndex() { public Integer getCodeIndex() {
return codeIndex; return codeIndex;
} }
/** /**
* *
*/ */
// 设置编码值的方法,外部可以通过调用该方法设置 codeIndex 字段的值
public void setCodeIndex(Integer codeIndex) { public void setCodeIndex(Integer codeIndex) {
this.codeIndex = codeIndex; this.codeIndex = codeIndex;
} }
/** /**
* *
*/ */
// 获取编码名称值的方法,外部可以通过调用该方法获取 indexName 字段的值
public String getIndexName() { public String getIndexName() {
return indexName; return indexName;
} }
/** /**
* *
*/ */
// 设置编码名称值的方法,外部可以通过调用该方法设置 indexName 字段的值
public void setIndexName(String indexName) { public void setIndexName(String indexName) {
this.indexName = indexName; this.indexName = indexName;
} }
/** /**
* id * id
*/ */
// 获取父字段 ID 值的方法,外部可以通过调用该方法获取 superId 字段的值
public Integer getSuperId() { public Integer getSuperId() {
return superId; return superId;
} }
/** /**
* id * id
*/ */
// 设置父字段 ID 值的方法,外部可以通过调用该方法设置 superId 字段的值
public void setSuperId(Integer superId) { public void setSuperId(Integer superId) {
this.superId = superId; this.superId = superId;
} }
/** /**
* *
*/ */
// 获取备注信息值的方法,外部可以通过调用该方法获取 beizhu 字段的值
public String getBeizhu() { public String getBeizhu() {
return beizhu; return beizhu;
} }
/** /**
* *
*/ */
// 设置备注信息值的方法,外部可以通过调用该方法设置 beizhu 字段的值
public void setBeizhu(String beizhu) { public void setBeizhu(String beizhu) {
this.beizhu = beizhu; this.beizhu = beizhu;
} }
/** /**
* *
*/ */
// 获取创建时间值的方法,外部可以通过调用该方法获取 createTime 字段的值
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
/** /**
* *
*/ */
// 设置创建时间值的方法,外部可以通过调用该方法设置 createTime 字段的值
public void setCreateTime(Date createTime) { public void setCreateTime(Date createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
// 重写 toString 方法,返回对象的字符串表示,方便调试和日志记录
@Override @Override
public String toString() { public String toString() {
return "Dictionary{" + return "Dictionary{" +
"id=" + id + "id=" + id +
", dicCode=" + dicCode + ", dicCode=" + dicCode +
", dicName=" + dicName + ", dicName=" + dicName +
", codeIndex=" + codeIndex + ", codeIndex=" + codeIndex +
", indexName=" + indexName + ", indexName=" + indexName +
", superId=" + superId + ", superId=" + superId +
", beizhu=" + beizhu + ", beizhu=" + beizhu +
", createTime=" + createTime + ", createTime=" + createTime +
"}"; "}";
} }
} }

@ -1,52 +1,64 @@
package com.entity; package com.entity;
/** /**
* *
*/ */
// 定义一个名为EIException的类它继承自RuntimeException表明这是一个运行时异常类
public class EIException extends RuntimeException { public class EIException extends RuntimeException {
// 定义序列化版本号,用于在序列化和反序列化过程中确保兼容性
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String msg; // 用于存储异常的详细信息,描述异常发生的情况
private int code = 500; private String msg;
// 用于存储异常的状态码默认值为500通常表示服务器内部错误
public EIException(String msg) { private int code = 500;
// 构造函数接受一个字符串参数msg将其设置为异常信息并调用父类的构造函数传递异常信息
public EIException(String msg) {
super(msg); super(msg);
this.msg = msg; this.msg = msg;
} }
// 构造函数接受一个字符串参数msg和一个Throwable对象e
// 将msg设置为异常信息调用父类的构造函数传递异常信息和异常原因
public EIException(String msg, Throwable e) { public EIException(String msg, Throwable e) {
super(msg, e); super(msg, e);
this.msg = msg; this.msg = msg;
} }
// 构造函数接受一个字符串参数msg和一个整数参数code
// 将msg设置为异常信息code设置为异常状态码并调用父类的构造函数传递异常信息
public EIException(String msg, int code) { public EIException(String msg, int code) {
super(msg); super(msg);
this.msg = msg; this.msg = msg;
this.code = code; this.code = code;
} }
// 构造函数接受一个字符串参数msg、一个整数参数code和一个Throwable对象e
// 将msg设置为异常信息code设置为异常状态码调用父类的构造函数传递异常信息和异常原因
public EIException(String msg, int code, Throwable e) { public EIException(String msg, int code, Throwable e) {
super(msg, e); super(msg, e);
this.msg = msg; this.msg = msg;
this.code = code; this.code = code;
} }
// 获取异常信息的方法,返回存储的异常信息字符串
public String getMsg() { public String getMsg() {
return msg; return msg;
} }
// 设置异常信息的方法,将传入的字符串设置为新的异常信息
public void setMsg(String msg) { public void setMsg(String msg) {
this.msg = msg; this.msg = msg;
} }
// 获取异常状态码的方法,返回存储的异常状态码
public int getCode() { public int getCode() {
return code; return code;
} }
// 设置异常状态码的方法,将传入的整数设置为新的异常状态码
public void setCode(int code) { public void setCode(int code) {
this.code = code; this.code = code;
} }
}
}

@ -1,299 +1,330 @@
package com.entity; package com.entity;
// 导入 MyBatis-Plus 用于指定主键的注解
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotations.TableId;
// 导入 MyBatis-Plus 用于指定数据库表名的注解
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
// 导入 JSR 303 验证注解(在当前代码中未实际使用)
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
// 导入 Jackson 注解(在当前代码中未实际使用)
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
// 导入反射调用可能抛出的异常类
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
// 导入序列化接口
import java.io.Serializable; import java.io.Serializable;
// 导入日期类
import java.util.Date; import java.util.Date;
// 导入列表集合类(在当前代码中未实际使用)
import java.util.List; import java.util.List;
// 导入 Spring 框架用于日期格式化的注解
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
// 导入 Jackson 用于 JSON 序列化时日期格式化的注解
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
// 导入 Apache Commons BeanUtils 工具类,用于对象属性复制
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
// 导入 MyBatis-Plus 用于指定字段的注解
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotations.TableField;
// 导入 MyBatis-Plus 字段填充策略枚举
import com.baomidou.mybatisplus.enums.FieldFill; import com.baomidou.mybatisplus.enums.FieldFill;
// 导入 MyBatis-Plus 主键生成策略枚举
import com.baomidou.mybatisplus.enums.IdType; import com.baomidou.mybatisplus.enums.IdType;
/** /**
* *
* *
* @author * @author
* @email * @email
*/ */
// 使用 TableName 注解指定该类对应的数据库表名为 "guahao"
@TableName("guahao") @TableName("guahao")
// 定义泛型类 GuahaoEntity实现 Serializable 接口,以便对象可以进行序列化和反序列化
public class GuahaoEntity<T> implements Serializable { public class GuahaoEntity<T> implements Serializable {
// 定义序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性
private static final long serialVersionUID = 1L; 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) @TableId(type = IdType.AUTO)
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "id"
@TableField(value = "id") @TableField(value = "id")
// 存储挂号记录的主键值,用于唯一标识一条挂号记录
private Integer id; private Integer id;
/** /**
* *
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "yisheng_id"
@TableField(value = "yisheng_id") @TableField(value = "yisheng_id")
// 存储挂号对应的医生 ID关联医生表
private Integer yishengId; private Integer yishengId;
/** /**
* *
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "yonghu_id"
@TableField(value = "yonghu_id") @TableField(value = "yonghu_id")
// 存储挂号的用户 ID关联用户表
private Integer yonghuId; private Integer yonghuId;
/** /**
* *
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "guahao_uuin_number"
@TableField(value = "guahao_uuin_number") @TableField(value = "guahao_uuin_number")
// 存储就诊的唯一识别码,用于标识具体的就诊记录
private String guahaoUuinNumber; private String guahaoUuinNumber;
/** /**
* *
*/ */
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd") // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd"
@DateTimeFormat @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd")
// 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象
@DateTimeFormat
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "guahao_time"
@TableField(value = "guahao_time") @TableField(value = "guahao_time")
// 存储挂号的具体时间
private Date guahaoTime; private Date guahaoTime;
/** /**
* *
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "guahao_types"
@TableField(value = "guahao_types") @TableField(value = "guahao_types")
// 存储挂号的时间类型,可能表示上午、下午、晚上等不同时间段,用整数标识
private Integer guahaoTypes; private Integer guahaoTypes;
/** /**
* *
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "guahao_status_types"
@TableField(value = "guahao_status_types") @TableField(value = "guahao_status_types")
// 存储挂号的状态,例如已挂号、已取消、已就诊等,用整数标识不同状态
private Integer guahaoStatusTypes; private Integer guahaoStatusTypes;
/** /**
* *
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "guahao_yesno_types"
@TableField(value = "guahao_yesno_types") @TableField(value = "guahao_yesno_types")
// 存储挂号审核的结果,可能表示通过、不通过等,用整数标识
private Integer guahaoYesnoTypes; private Integer guahaoYesnoTypes;
/** /**
* *
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "guahao_yesno_text"
@TableField(value = "guahao_yesno_text") @TableField(value = "guahao_yesno_text")
// 存储挂号审核结果的具体文本描述,例如不通过的原因等
private String guahaoYesnoText; private String guahaoYesnoText;
/** /**
* *
*/ */
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss"
@DateTimeFormat @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(value = "create_time",fill = FieldFill.INSERT) // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象
@DateTimeFormat
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "create_time"
// 并设置在插入数据时自动填充当前时间
@TableField(value = "create_time", fill = FieldFill.INSERT)
// 存储挂号记录的创建时间,用于记录数据的创建时间戳
private Date createTime; private Date createTime;
/** /**
* *
*/ */
// 获取主键值的方法,外部可以通过调用该方法获取 id 字段的值
public Integer getId() { public Integer getId() {
return id; return id;
} }
/** /**
* *
*/ */
// 设置主键值的方法,外部可以通过调用该方法设置 id 字段的值
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
/** /**
* *
*/ */
// 获取医生 ID 值的方法,外部可以通过调用该方法获取 yishengId 字段的值
public Integer getYishengId() { public Integer getYishengId() {
return yishengId; return yishengId;
} }
/** /**
* *
*/ */
// 设置医生 ID 值的方法,外部可以通过调用该方法设置 yishengId 字段的值
public void setYishengId(Integer yishengId) { public void setYishengId(Integer yishengId) {
this.yishengId = yishengId; this.yishengId = yishengId;
} }
/** /**
* *
*/ */
// 获取用户 ID 值的方法,外部可以通过调用该方法获取 yonghuId 字段的值
public Integer getYonghuId() { public Integer getYonghuId() {
return yonghuId; return yonghuId;
} }
/** /**
* *
*/ */
// 设置用户 ID 值的方法,外部可以通过调用该方法设置 yonghuId 字段的值
public void setYonghuId(Integer yonghuId) { public void setYonghuId(Integer yonghuId) {
this.yonghuId = yonghuId; this.yonghuId = yonghuId;
} }
/** /**
* *
*/ */
// 获取就诊识别码值的方法,外部可以通过调用该方法获取 guahaoUuinNumber 字段的值
public String getGuahaoUuinNumber() { public String getGuahaoUuinNumber() {
return guahaoUuinNumber; return guahaoUuinNumber;
} }
/** /**
* *
*/ */
// 设置就诊识别码值的方法,外部可以通过调用该方法设置 guahaoUuinNumber 字段的值
public void setGuahaoUuinNumber(String guahaoUuinNumber) { public void setGuahaoUuinNumber(String guahaoUuinNumber) {
this.guahaoUuinNumber = guahaoUuinNumber; this.guahaoUuinNumber = guahaoUuinNumber;
} }
/** /**
* *
*/ */
// 获取挂号时间值的方法,外部可以通过调用该方法获取 guahaoTime 字段的值
public Date getGuahaoTime() { public Date getGuahaoTime() {
return guahaoTime; return guahaoTime;
} }
/** /**
* *
*/ */
// 设置挂号时间值的方法,外部可以通过调用该方法设置 guahaoTime 字段的值
public void setGuahaoTime(Date guahaoTime) { public void setGuahaoTime(Date guahaoTime) {
this.guahaoTime = guahaoTime; this.guahaoTime = guahaoTime;
} }
/** /**
* *
*/ */
// 获取时间类型值的方法,外部可以通过调用该方法获取 guahaoTypes 字段的值
public Integer getGuahaoTypes() { public Integer getGuahaoTypes() {
return guahaoTypes; return guahaoTypes;
} }
/** /**
* *
*/ */
// 设置时间类型值的方法,外部可以通过调用该方法设置 guahaoTypes 字段的值
public void setGuahaoTypes(Integer guahaoTypes) { public void setGuahaoTypes(Integer guahaoTypes) {
this.guahaoTypes = guahaoTypes; this.guahaoTypes = guahaoTypes;
} }
/** /**
* *
*/ */
// 获取挂号状态值的方法,外部可以通过调用该方法获取 guahaoStatusTypes 字段的值
public Integer getGuahaoStatusTypes() { public Integer getGuahaoStatusTypes() {
return guahaoStatusTypes; return guahaoStatusTypes;
} }
/** /**
* *
*/ */
// 设置挂号状态值的方法,外部可以通过调用该方法设置 guahaoStatusTypes 字段的值
public void setGuahaoStatusTypes(Integer guahaoStatusTypes) { public void setGuahaoStatusTypes(Integer guahaoStatusTypes) {
this.guahaoStatusTypes = guahaoStatusTypes; this.guahaoStatusTypes = guahaoStatusTypes;
} }
/** /**
* *
*/ */
// 获取挂号审核值的方法,外部可以通过调用该方法获取 guahaoYesnoTypes 字段的值
public Integer getGuahaoYesnoTypes() { public Integer getGuahaoYesnoTypes() {
return guahaoYesnoTypes; return guahaoYesnoTypes;
} }
/** /**
* *
*/ */
// 设置挂号审核值的方法,外部可以通过调用该方法设置 guahaoYesnoTypes 字段的值
public void setGuahaoYesnoTypes(Integer guahaoYesnoTypes) { public void setGuahaoYesnoTypes(Integer guahaoYesnoTypes) {
this.guahaoYesnoTypes = guahaoYesnoTypes; this.guahaoYesnoTypes = guahaoYesnoTypes;
} }
/** /**
* *
*/ */
// 获取审核结果值的方法,外部可以通过调用该方法获取 guahaoYesnoText 字段的值
public String getGuahaoYesnoText() { public String getGuahaoYesnoText() {
return guahaoYesnoText; return guahaoYesnoText;
} }
/** /**
* *
*/ */
// 设置审核结果值的方法,外部可以通过调用该方法设置 guahaoYesnoText 字段的值
public void setGuahaoYesnoText(String guahaoYesnoText) { public void setGuahaoYesnoText(String guahaoYesnoText) {
this.guahaoYesnoText = guahaoYesnoText; this.guahaoYesnoText = guahaoYesnoText;
} }
/** /**
* *
*/ */
// 获取创建时间值的方法,外部可以通过调用该方法获取 createTime 字段的值
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
/** /**
* *
*/ */
// 设置创建时间值的方法,外部可以通过调用该方法设置 createTime 字段的值
public void setCreateTime(Date createTime) { public void setCreateTime(Date createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
// 重写 toString 方法,返回对象的字符串表示,方便调试和日志记录
@Override @Override
public String toString() { public String toString() {
return "Guahao{" + return "Guahao{" +
"id=" + id + "id=" + id +
", yishengId=" + yishengId + ", yishengId=" + yishengId +
", yonghuId=" + yonghuId + ", yonghuId=" + yonghuId +
", guahaoUuinNumber=" + guahaoUuinNumber + ", guahaoUuinNumber=" + guahaoUuinNumber +
", guahaoTime=" + guahaoTime + ", guahaoTime=" + guahaoTime +
", guahaoTypes=" + guahaoTypes + ", guahaoTypes=" + guahaoTypes +
", guahaoStatusTypes=" + guahaoStatusTypes + ", guahaoStatusTypes=" + guahaoStatusTypes +
", guahaoYesnoTypes=" + guahaoYesnoTypes + ", guahaoYesnoTypes=" + guahaoYesnoTypes +
", guahaoYesnoText=" + guahaoYesnoText + ", guahaoYesnoText=" + guahaoYesnoText +
", createTime=" + createTime + ", createTime=" + createTime +
"}"; "}";
} }
} }

@ -1,251 +1,279 @@
package com.entity; package com.entity;
// 导入 MyBatis-Plus 用于指定主键的注解
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotations.TableId;
// 导入 MyBatis-Plus 用于指定数据库表名的注解
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
// 导入 JSR 303 验证注解,可用于字段验证,当前代码未使用这些注解进行实际验证
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
// 导入 Jackson 注解,可用于忽略 JSON 序列化和反序列化时的某些属性,当前代码未使用
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
// 导入反射调用可能抛出的异常类
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
// 导入序列化接口,使该类的对象可以进行序列化和反序列化操作
import java.io.Serializable; import java.io.Serializable;
// 导入日期类
import java.util.Date; import java.util.Date;
// 导入列表集合类,当前代码未使用
import java.util.List; import java.util.List;
// 导入 Spring 框架用于日期格式化的注解,用于将字符串日期转换为 Date 对象
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
// 导入 Jackson 用于 JSON 序列化时日期格式化的注解
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
// 导入 Apache Commons BeanUtils 工具类,用于对象属性复制
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
// 导入 MyBatis-Plus 用于指定字段的注解
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotations.TableField;
// 导入 MyBatis-Plus 字段填充策略枚举
import com.baomidou.mybatisplus.enums.FieldFill; import com.baomidou.mybatisplus.enums.FieldFill;
// 导入 MyBatis-Plus 主键生成策略枚举
import com.baomidou.mybatisplus.enums.IdType; import com.baomidou.mybatisplus.enums.IdType;
/** /**
* *
* *
* @author * @author
* @email * @email
*/ */
// 指定该类对应数据库中的 jiankangjiaoyu 表
@TableName("jiankangjiaoyu") @TableName("jiankangjiaoyu")
// 定义泛型类,实现 Serializable 接口
public class JiankangjiaoyuEntity<T> implements Serializable { public class JiankangjiaoyuEntity<T> implements Serializable {
// 序列化版本号,确保序列化和反序列化的兼容性
private static final long serialVersionUID = 1L; 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) @TableId(type = IdType.AUTO)
// 指定该字段对应数据库表中的 id 字段
@TableField(value = "id") @TableField(value = "id")
// 主键,用于唯一标识一条健康教育记录
private Integer id; private Integer id;
/** /**
* *
*/ */
// 指定该字段对应数据库表中的 jiankangjiaoyu_name 字段
@TableField(value = "jiankangjiaoyu_name") @TableField(value = "jiankangjiaoyu_name")
// 健康教育的标题
private String jiankangjiaoyuName; private String jiankangjiaoyuName;
/** /**
* *
*/ */
// 指定该字段对应数据库表中的 jiankangjiaoyu_types 字段
@TableField(value = "jiankangjiaoyu_types") @TableField(value = "jiankangjiaoyu_types")
// 健康教育的类型,用整数表示不同类型
private Integer jiankangjiaoyuTypes; private Integer jiankangjiaoyuTypes;
/** /**
* *
*/ */
// 指定该字段对应数据库表中的 jiankangjiaoyu_photo 字段
@TableField(value = "jiankangjiaoyu_photo") @TableField(value = "jiankangjiaoyu_photo")
// 健康教育相关图片的存储路径
private String jiankangjiaoyuPhoto; private String jiankangjiaoyuPhoto;
/** /**
* *
*/ */
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss"
@DateTimeFormat @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(value = "insert_time",fill = FieldFill.INSERT) // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象
@DateTimeFormat
// 指定该字段对应数据库表中的 insert_time 字段,且在插入数据时自动填充
@TableField(value = "insert_time", fill = FieldFill.INSERT)
// 健康教育的时间
private Date insertTime; private Date insertTime;
/** /**
* *
*/ */
// 指定该字段对应数据库表中的 jiankangjiaoyu_content 字段
@TableField(value = "jiankangjiaoyu_content") @TableField(value = "jiankangjiaoyu_content")
// 健康教育的详细内容
private String jiankangjiaoyuContent; private String jiankangjiaoyuContent;
/** /**
* *
*/ */
// 指定该字段对应数据库表中的 jiankangjiaoyu_delete 字段
@TableField(value = "jiankangjiaoyu_delete") @TableField(value = "jiankangjiaoyu_delete")
// 假删除标记,用整数表示是否删除,如 0 表示未删除1 表示已删除
private Integer jiankangjiaoyuDelete; private Integer jiankangjiaoyuDelete;
/** /**
* *
*/ */
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss"
@DateTimeFormat @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(value = "create_time",fill = FieldFill.INSERT) // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象
@DateTimeFormat
// 指定该字段对应数据库表中的 create_time 字段,且在插入数据时自动填充
@TableField(value = "create_time", fill = FieldFill.INSERT)
// 该条健康教育记录的创建时间
private Date createTime; private Date createTime;
/** /**
* *
*/ */
// 获取主键的方法
public Integer getId() { public Integer getId() {
return id; return id;
} }
/** /**
* *
*/ */
// 设置主键的方法
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
/** /**
* *
*/ */
// 获取健康教育标题的方法
public String getJiankangjiaoyuName() { public String getJiankangjiaoyuName() {
return jiankangjiaoyuName; return jiankangjiaoyuName;
} }
/** /**
* *
*/ */
// 设置健康教育标题的方法
public void setJiankangjiaoyuName(String jiankangjiaoyuName) { public void setJiankangjiaoyuName(String jiankangjiaoyuName) {
this.jiankangjiaoyuName = jiankangjiaoyuName; this.jiankangjiaoyuName = jiankangjiaoyuName;
} }
/** /**
* *
*/ */
// 获取健康教育类型的方法
public Integer getJiankangjiaoyuTypes() { public Integer getJiankangjiaoyuTypes() {
return jiankangjiaoyuTypes; return jiankangjiaoyuTypes;
} }
/** /**
* *
*/ */
// 设置健康教育类型的方法
public void setJiankangjiaoyuTypes(Integer jiankangjiaoyuTypes) { public void setJiankangjiaoyuTypes(Integer jiankangjiaoyuTypes) {
this.jiankangjiaoyuTypes = jiankangjiaoyuTypes; this.jiankangjiaoyuTypes = jiankangjiaoyuTypes;
} }
/** /**
* *
*/ */
// 获取健康教育图片路径的方法
public String getJiankangjiaoyuPhoto() { public String getJiankangjiaoyuPhoto() {
return jiankangjiaoyuPhoto; return jiankangjiaoyuPhoto;
} }
/** /**
* *
*/ */
// 设置健康教育图片路径的方法
public void setJiankangjiaoyuPhoto(String jiankangjiaoyuPhoto) { public void setJiankangjiaoyuPhoto(String jiankangjiaoyuPhoto) {
this.jiankangjiaoyuPhoto = jiankangjiaoyuPhoto; this.jiankangjiaoyuPhoto = jiankangjiaoyuPhoto;
} }
/** /**
* *
*/ */
// 获取健康教育时间的方法
public Date getInsertTime() { public Date getInsertTime() {
return insertTime; return insertTime;
} }
/** /**
* *
*/ */
// 设置健康教育时间的方法
public void setInsertTime(Date insertTime) { public void setInsertTime(Date insertTime) {
this.insertTime = insertTime; this.insertTime = insertTime;
} }
/** /**
* *
*/ */
// 获取健康教育详情的方法
public String getJiankangjiaoyuContent() { public String getJiankangjiaoyuContent() {
return jiankangjiaoyuContent; return jiankangjiaoyuContent;
} }
/** /**
* *
*/ */
// 设置健康教育详情的方法
public void setJiankangjiaoyuContent(String jiankangjiaoyuContent) { public void setJiankangjiaoyuContent(String jiankangjiaoyuContent) {
this.jiankangjiaoyuContent = jiankangjiaoyuContent; this.jiankangjiaoyuContent = jiankangjiaoyuContent;
} }
/** /**
* *
*/ */
// 获取假删除标记的方法
public Integer getJiankangjiaoyuDelete() { public Integer getJiankangjiaoyuDelete() {
return jiankangjiaoyuDelete; return jiankangjiaoyuDelete;
} }
/** /**
* *
*/ */
// 设置假删除标记的方法
public void setJiankangjiaoyuDelete(Integer jiankangjiaoyuDelete) { public void setJiankangjiaoyuDelete(Integer jiankangjiaoyuDelete) {
this.jiankangjiaoyuDelete = jiankangjiaoyuDelete; this.jiankangjiaoyuDelete = jiankangjiaoyuDelete;
} }
/** /**
* *
*/ */
// 获取创建时间的方法
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
/** /**
* *
*/ */
// 设置创建时间的方法
public void setCreateTime(Date createTime) { public void setCreateTime(Date createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
// 重写 toString 方法,方便打印对象信息
@Override @Override
public String toString() { public String toString() {
return "Jiankangjiaoyu{" + return "Jiankangjiaoyu{" +
"id=" + id + "id=" + id +
", jiankangjiaoyuName=" + jiankangjiaoyuName + ", jiankangjiaoyuName=" + jiankangjiaoyuName +
", jiankangjiaoyuTypes=" + jiankangjiaoyuTypes + ", jiankangjiaoyuTypes=" + jiankangjiaoyuTypes +
", jiankangjiaoyuPhoto=" + jiankangjiaoyuPhoto + ", jiankangjiaoyuPhoto=" + jiankangjiaoyuPhoto +
", insertTime=" + insertTime + ", insertTime=" + insertTime +
", jiankangjiaoyuContent=" + jiankangjiaoyuContent + ", jiankangjiaoyuContent=" + jiankangjiaoyuContent +
", jiankangjiaoyuDelete=" + jiankangjiaoyuDelete + ", jiankangjiaoyuDelete=" + jiankangjiaoyuDelete +
", createTime=" + createTime + ", createTime=" + createTime +
"}"; "}";
} }
} }

@ -1,227 +1,256 @@
package com.entity; package com.entity;
// 导入 MyBatis-Plus 用于指定主键的注解
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotations.TableId;
// 导入 MyBatis-Plus 用于指定数据库表名的注解
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
// 导入 JSR 303 验证注解(当前未实际使用)
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
// 导入 Jackson 用于忽略属性的注解(当前未实际使用)
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
// 导入反射调用可能抛出的异常类
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
// 导入序列化接口
import java.io.Serializable; import java.io.Serializable;
// 导入日期类
import java.util.Date; import java.util.Date;
// 导入列表类(当前未实际使用)
import java.util.List; import java.util.List;
// 导入 Spring 用于日期格式化的注解
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
// 导入 Jackson 用于 JSON 序列化时日期格式化的注解
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
// 导入 Apache Commons BeanUtils 工具类,用于对象属性复制
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
// 导入 MyBatis-Plus 用于指定字段的注解
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotations.TableField;
// 导入 MyBatis-Plus 字段填充策略枚举
import com.baomidou.mybatisplus.enums.FieldFill; import com.baomidou.mybatisplus.enums.FieldFill;
// 导入 MyBatis-Plus 主键生成策略枚举
import com.baomidou.mybatisplus.enums.IdType; import com.baomidou.mybatisplus.enums.IdType;
/** /**
* *
* *
* @author * @author
* @email * @email
*/ */
// 使用 TableName 注解指定该类对应的数据库表名为 "news"
@TableName("news") @TableName("news")
// 定义泛型类 NewsEntity实现 Serializable 接口,用于对象的序列化和反序列化
public class NewsEntity<T> implements Serializable { public class NewsEntity<T> implements Serializable {
// 定义序列化版本号,保证序列化和反序列化的兼容性
private static final long serialVersionUID = 1L; 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) @TableId(type = IdType.AUTO)
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "id"
@TableField(value = "id") @TableField(value = "id")
// 存储公告信息记录的主键值,用于唯一标识一条公告记录
private Integer id; private Integer id;
/** /**
* *
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "news_name"
@TableField(value = "news_name") @TableField(value = "news_name")
// 存储公告的名称
private String newsName; private String newsName;
/** /**
* *
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "news_photo"
@TableField(value = "news_photo") @TableField(value = "news_photo")
// 存储公告相关图片的路径或标识
private String newsPhoto; private String newsPhoto;
/** /**
* *
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "news_types"
@TableField(value = "news_types") @TableField(value = "news_types")
// 存储公告的类型,用整数表示不同的公告类型,如通知、公告等
private Integer newsTypes; private Integer newsTypes;
/** /**
* *
*/ */
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss"
@DateTimeFormat @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(value = "insert_time",fill = FieldFill.INSERT) // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象
@DateTimeFormat
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "insert_time"
// 并设置在插入数据时自动填充当前时间
@TableField(value = "insert_time", fill = FieldFill.INSERT)
// 存储公告的发布时间
private Date insertTime; private Date insertTime;
/** /**
* *
*/ */
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "news_content"
@TableField(value = "news_content") @TableField(value = "news_content")
// 存储公告的详细内容
private String newsContent; private String newsContent;
/** /**
* *
*/ */
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") // 设置 JSON 序列化时日期的格式,使用中文环境,时区为东八区,格式为 "yyyy-MM-dd HH:mm:ss"
@DateTimeFormat @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(value = "create_time",fill = FieldFill.INSERT) // 用于 Spring MVC 接收表单数据时将日期字符串转换为 Date 对象
@DateTimeFormat
// 使用 TableField 注解指定该字段在数据库表中对应的字段名为 "create_time"
// 并设置在插入数据时自动填充当前时间
@TableField(value = "create_time", fill = FieldFill.INSERT)
// 存储公告记录的创建时间,用于记录数据的创建时间戳
private Date createTime; private Date createTime;
/** /**
* *
*/ */
// 获取主键值的方法
public Integer getId() { public Integer getId() {
return id; return id;
} }
/** /**
* *
*/ */
// 设置主键值的方法
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
/** /**
* *
*/ */
// 获取公告名称值的方法
public String getNewsName() { public String getNewsName() {
return newsName; return newsName;
} }
/** /**
* *
*/ */
// 设置公告名称值的方法
public void setNewsName(String newsName) { public void setNewsName(String newsName) {
this.newsName = newsName; this.newsName = newsName;
} }
/** /**
* *
*/ */
// 获取公告图片路径值的方法
public String getNewsPhoto() { public String getNewsPhoto() {
return newsPhoto; return newsPhoto;
} }
/** /**
* *
*/ */
// 设置公告图片路径值的方法
public void setNewsPhoto(String newsPhoto) { public void setNewsPhoto(String newsPhoto) {
this.newsPhoto = newsPhoto; this.newsPhoto = newsPhoto;
} }
/** /**
* *
*/ */
// 获取公告类型值的方法
public Integer getNewsTypes() { public Integer getNewsTypes() {
return newsTypes; return newsTypes;
} }
/** /**
* *
*/ */
// 设置公告类型值的方法
public void setNewsTypes(Integer newsTypes) { public void setNewsTypes(Integer newsTypes) {
this.newsTypes = newsTypes; this.newsTypes = newsTypes;
} }
/** /**
* *
*/ */
// 获取公告发布时间值的方法
public Date getInsertTime() { public Date getInsertTime() {
return insertTime; return insertTime;
} }
/** /**
* *
*/ */
// 设置公告发布时间值的方法
public void setInsertTime(Date insertTime) { public void setInsertTime(Date insertTime) {
this.insertTime = insertTime; this.insertTime = insertTime;
} }
/** /**
* *
*/ */
// 获取公告详情值的方法
public String getNewsContent() { public String getNewsContent() {
return newsContent; return newsContent;
} }
/** /**
* *
*/ */
// 设置公告详情值的方法
public void setNewsContent(String newsContent) { public void setNewsContent(String newsContent) {
this.newsContent = newsContent; this.newsContent = newsContent;
} }
/** /**
* *
*/ */
// 获取创建时间值的方法
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
/** /**
* *
*/ */
// 设置创建时间值的方法
public void setCreateTime(Date createTime) { public void setCreateTime(Date createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
// 重写 toString 方法,返回对象的字符串表示,方便调试和日志记录
@Override @Override
public String toString() { public String toString() {
return "News{" + return "News{" +
"id=" + id + "id=" + id +
", newsName=" + newsName + ", newsName=" + newsName +
", newsPhoto=" + newsPhoto + ", newsPhoto=" + newsPhoto +
", newsTypes=" + newsTypes + ", newsTypes=" + newsTypes +
", insertTime=" + insertTime + ", insertTime=" + insertTime +
", newsContent=" + newsContent + ", newsContent=" + newsContent +
", createTime=" + createTime + ", createTime=" + createTime +
"}"; "}";
} }
} }

@ -1,122 +1,156 @@
package com.entity; package com.entity;
// 导入序列化接口,使该类的对象可以进行序列化和反序列化
import java.io.Serializable; import java.io.Serializable;
// 导入日期类,用于处理日期相关的操作
import java.util.Date; import java.util.Date;
// 导入 MyBatis-Plus 用于指定主键的注解
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotations.TableId;
// 导入 MyBatis-Plus 用于指定数据库表名的注解
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
// 导入 MyBatis-Plus 主键生成策略枚举
import com.baomidou.mybatisplus.enums.IdType; import com.baomidou.mybatisplus.enums.IdType;
/** /**
* token * token
*/ */
// 使用 TableName 注解指定该类对应的数据库表名为 "token"
@TableName("token") @TableName("token")
//定义 TokenEntity 类,实现 Serializable 接口,以支持对象的序列化和反序列化
public class TokenEntity implements Serializable { public class TokenEntity implements Serializable {
// 定义序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// 使用 TableId 注解指定该字段为主键主键生成策略为自动增长AUTO
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
// 存储记录的主键值,用于唯一标识一条 token 记录
private Integer id; private Integer id;
/** /**
* id * id
*/ */
// 存储与该 token 相关联的用户 ID
private Integer userid; private Integer userid;
/** /**
* *
*/ */
// 存储与该 token 相关联的用户名
private String username; private String username;
/** /**
* *
*/ */
// 存储与该 token 相关的表名(具体用途可能根据业务需求而定)
private String tablename; private String tablename;
/** /**
* *
*/ */
// 存储用户的角色信息,用于权限控制等
private String role; private String role;
/** /**
* token * token
*/ */
// 存储具体的 token 值,用于身份验证和授权
private String token; private String token;
/** /**
* *
*/ */
// 存储该 token 的过期时间,用于判断 token 是否有效
private Date expiratedtime; private Date expiratedtime;
/** /**
* *
*/ */
// 存储该 token 记录的创建时间,用于记录数据的生成时间戳
private Date addtime; private Date addtime;
// 获取主键值的方法
public Integer getId() { public Integer getId() {
return id; return id;
} }
// 设置主键值的方法
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
// 获取用户 ID 的方法
public Integer getUserid() { public Integer getUserid() {
return userid; return userid;
} }
// 设置用户 ID 的方法
public void setUserid(Integer userid) { public void setUserid(Integer userid) {
this.userid = userid; this.userid = userid;
} }
// 获取角色信息的方法
public String getRole() { public String getRole() {
return role; return role;
} }
// 设置角色信息的方法
public void setRole(String role) { public void setRole(String role) {
this.role = role; this.role = role;
} }
// 获取 token 值的方法
public String getToken() { public String getToken() {
return token; return token;
} }
// 获取表名的方法
public String getTablename() { public String getTablename() {
return tablename; return tablename;
} }
// 设置表名的方法
public void setTablename(String tablename) { public void setTablename(String tablename) {
this.tablename = tablename; this.tablename = tablename;
} }
// 设置 token 值的方法
public void setToken(String token) { public void setToken(String token) {
this.token = token; this.token = token;
} }
// 获取过期时间的方法
public Date getExpiratedtime() { public Date getExpiratedtime() {
return expiratedtime; return expiratedtime;
} }
// 设置过期时间的方法
public void setExpiratedtime(Date expiratedtime) { public void setExpiratedtime(Date expiratedtime) {
this.expiratedtime = expiratedtime; this.expiratedtime = expiratedtime;
} }
// 获取新增时间的方法
public Date getAddtime() { public Date getAddtime() {
return addtime; return addtime;
} }
// 设置新增时间的方法
public void setAddtime(Date addtime) { public void setAddtime(Date addtime) {
this.addtime = addtime; this.addtime = addtime;
} }
// 获取用户名的方法
public String getUsername() { public String getUsername() {
return username; return username;
} }
// 设置用户名的方法
public void setUsername(String username) { public void setUsername(String username) {
this.username = 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(); super();
this.userid = userid; this.userid = userid;
this.username = username; this.username = username;
@ -125,8 +159,8 @@ public class TokenEntity implements Serializable {
this.token = token; this.token = token;
this.expiratedtime = expiratedtime; this.expiratedtime = expiratedtime;
} }
// 无参构造函数,用于创建 TokenEntity 对象的实例
public TokenEntity() { public TokenEntity() {
} }
}
}

@ -1,77 +1,100 @@
package com.entity; package com.entity;
// 导入序列化接口,使该类的对象可以进行序列化和反序列化操作
import java.io.Serializable; import java.io.Serializable;
// 导入日期类,用于处理与日期相关的操作
import java.util.Date; import java.util.Date;
// 导入 MyBatis-Plus 用于指定主键的注解
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotations.TableId;
// 导入 MyBatis-Plus 用于指定数据库表名的注解
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
// 导入 MyBatis-Plus 主键生成策略枚举
import com.baomidou.mybatisplus.enums.IdType; import com.baomidou.mybatisplus.enums.IdType;
/** /**
* *
*/ */
// 使用 TableName 注解指定该类对应的数据库表名为 "users"
@TableName("users") @TableName("users")
// 定义 UsersEntity 类,实现 Serializable 接口,以支持对象的序列化和反序列化
public class UsersEntity implements Serializable { public class UsersEntity implements Serializable {
// 定义序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// 使用 TableId 注解指定该字段为主键主键生成策略为自动增长AUTO
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
// 存储用户记录的主键值,用于唯一标识一条用户记录
private Integer id; private Integer id;
/** /**
* *
*/ */
// 存储用户的账号信息,用于登录等操作
private String username; private String username;
/** /**
* *
*/ */
// 存储用户的密码信息,用于验证用户身份
private String password; private String password;
/** /**
* *
*/ */
// 存储用户的类型信息,例如普通用户、管理员等,用于权限控制等
private String role; private String role;
// 存储用户记录的创建时间,用于记录数据的生成时间戳
private Date addtime; private Date addtime;
// 获取用户账号的方法
public String getUsername() { public String getUsername() {
return username; return username;
} }
// 设置用户账号的方法
public void setUsername(String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
// 获取用户密码的方法
public String getPassword() { public String getPassword() {
return password; return password;
} }
// 设置用户密码的方法
public void setPassword(String password) { public void setPassword(String password) {
this.password = password; this.password = password;
} }
// 获取用户类型的方法
public String getRole() { public String getRole() {
return role; return role;
} }
// 设置用户类型的方法
public void setRole(String role) { public void setRole(String role) {
this.role = role; this.role = role;
} }
// 获取用户记录创建时间的方法
public Date getAddtime() { public Date getAddtime() {
return addtime; return addtime;
} }
// 设置用户记录创建时间的方法
public void setAddtime(Date addtime) { public void setAddtime(Date addtime) {
this.addtime = addtime; this.addtime = addtime;
} }
// 获取用户记录主键的方法
public Integer getId() { public Integer getId() {
return id; return id;
} }
// 设置用户记录主键的方法
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
}
}

@ -1,445 +1,393 @@
package com.entity; package com.entity;
// 导入 MyBatis-Plus 用于指定主键的注解
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotations.TableId;
// 导入 MyBatis-Plus 用于指定数据库表名的注解
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
// 导入 JSR 303 验证注解(在当前代码中未实际使用)
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
// 导入 Jackson 注解(在当前代码中未实际使用)
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
// 导入反射调用可能抛出的异常类
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
// 导入序列化接口
import java.io.Serializable; import java.io.Serializable;
// 导入日期类
import java.util.Date; import java.util.Date;
// 导入列表集合类(在当前代码中未实际使用)
import java.util.List; import java.util.List;
// 导入 Spring 框架用于日期格式化的注解
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
// 导入 Jackson 用于 JSON 序列化时日期格式化的注解
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
// 导入 Apache Commons BeanUtils 工具类,用于对象属性复制
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
// 导入 MyBatis-Plus 用于指定字段的注解
import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotations.TableField;
// 导入 MyBatis-Plus 字段填充策略枚举
import com.baomidou.mybatisplus.enums.FieldFill; import com.baomidou.mybatisplus.enums.FieldFill;
// 导入 MyBatis-Plus 主键生成策略枚举
import com.baomidou.mybatisplus.enums.IdType; import com.baomidou.mybatisplus.enums.IdType;
/** /**
* *
* Serializable 便
* *
* @author * @author
* @email * @email
*/ */
@TableName("yisheng") // 表明该实体类对应数据库中的表名为 "yisheng" @TableName("yisheng")
public class YishengEntity<T> implements Serializable { public class YishengEntity<T> implements Serializable {
// 序列化版本号,用于保证序列化和反序列化过程中对象版本的一致性
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**
*
* YishengEntity
*/
public YishengEntity() {
} public YishengEntity() {
/**
*
* t YishengEntity
*
* @param t
*/
public YishengEntity(T t) {
try {
// 使用 BeanUtils 工具类将对象 t 的属性复制到当前对象
BeanUtils.copyProperties(this, t);
} catch (IllegalAccessException | InvocationTargetException e) {
// 若复制属性过程中出现异常,打印异常堆栈信息
e.printStackTrace();
}
} }
public YishengEntity(T t) {
try {
BeanUtils.copyProperties(this, t);
} catch (IllegalAccessException | InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/** /**
* *
*
*/ */
@TableId(type = IdType.AUTO) // 表示该字段为主键,且采用自增方式生成 @TableId(type = IdType.AUTO)
@TableField(value = "id") // 表明该属性对应数据库表中的字段名为 "id" @TableField(value = "id")
private Integer id; private Integer id;
/** /**
* *
*
*/ */
@TableField(value = "yisheng_uuid_number") // 表明该属性对应数据库表中的字段名为 "yisheng_uuid_number" @TableField(value = "yisheng_uuid_number")
private String yishengUuidNumber; private String yishengUuidNumber;
/** /**
* *
* 使
*/ */
@TableField(value = "username") // 表明该属性对应数据库表中的字段名为 "username" @TableField(value = "username")
private String username; private String username;
/** /**
* *
* 使
*/ */
@TableField(value = "password") // 表明该属性对应数据库表中的字段名为 "password" @TableField(value = "password")
private String password; private String password;
/** /**
* *
*
*/ */
@TableField(value = "yisheng_name") // 表明该属性对应数据库表中的字段名为 "yisheng_name" @TableField(value = "yisheng_name")
private String yishengName; private String yishengName;
/** /**
* *
*
*/ */
@TableField(value = "yisheng_types") // 表明该属性对应数据库表中的字段名为 "yisheng_types" @TableField(value = "yisheng_types")
private Integer yishengTypes; private Integer yishengTypes;
/** /**
* *
*
*/ */
@TableField(value = "zhiwei_types") // 表明该属性对应数据库表中的字段名为 "zhiwei_types" @TableField(value = "zhiwei_types")
private Integer zhiweiTypes; private Integer zhiweiTypes;
/** /**
* *
*
*/ */
@TableField(value = "yisheng_zhichneg") // 表明该属性对应数据库表中的字段名为 "yisheng_zhichneg" @TableField(value = "yisheng_zhichneg")
private String yishengZhichneg; private String yishengZhichneg;
/** /**
* *
*
*/ */
@TableField(value = "yisheng_photo") // 表明该属性对应数据库表中的字段名为 "yisheng_photo" @TableField(value = "yisheng_photo")
private String yishengPhoto; private String yishengPhoto;
/** /**
* *
*
*/ */
@TableField(value = "yisheng_phone") // 表明该属性对应数据库表中的字段名为 "yisheng_phone" @TableField(value = "yisheng_phone")
private String yishengPhone; private String yishengPhone;
/** /**
* *
*
*/ */
@TableField(value = "yisheng_guahao") // 表明该属性对应数据库表中的字段名为 "yisheng_guahao" @TableField(value = "yisheng_guahao")
private String yishengGuahao; private String yishengGuahao;
/** /**
* *
*
*/ */
@TableField(value = "yisheng_email") // 表明该属性对应数据库表中的字段名为 "yisheng_email" @TableField(value = "yisheng_email")
private String yishengEmail; private String yishengEmail;
/** /**
* *
*
*/ */
@TableField(value = "yisheng_new_money") // 表明该属性对应数据库表中的字段名为 "yisheng_new_money" @TableField(value = "yisheng_new_money")
private Double yishengNewMoney; private Double yishengNewMoney;
/** /**
* *
*
*/ */
@TableField(value = "yisheng_content") // 表明该属性对应数据库表中的字段名为 "yisheng_content" @TableField(value = "yisheng_content")
private String yishengContent; private String yishengContent;
/** /**
* *
*
*/ */
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") // 用于将日期格式化为指定格式,方便前端展示 @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@DateTimeFormat // 用于将前端传递的日期字符串解析为 Date 类型 @DateTimeFormat
@TableField(value = "create_time",fill = FieldFill.INSERT) // 表明该属性对应数据库表中的字段名为 "create_time",且在插入数据时自动填充 @TableField(value = "create_time",fill = FieldFill.INSERT)
private Date createTime; private Date createTime;
/** /**
* *
* */
* @return
*/
public Integer getId() { public Integer getId() {
return id; return id;
} }
/** /**
* *
* */
* @param id
*/
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
/** /**
* *
* */
* @return
*/
public String getYishengUuidNumber() { public String getYishengUuidNumber() {
return yishengUuidNumber; return yishengUuidNumber;
} }
/** /**
* *
* */
* @param yishengUuidNumber
*/
public void setYishengUuidNumber(String yishengUuidNumber) { public void setYishengUuidNumber(String yishengUuidNumber) {
this.yishengUuidNumber = yishengUuidNumber; this.yishengUuidNumber = yishengUuidNumber;
} }
/** /**
* *
* */
* @return
*/
public String getUsername() { public String getUsername() {
return username; return username;
} }
/** /**
* *
* */
* @param username
*/
public void setUsername(String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
/** /**
* *
* */
* @return
*/
public String getPassword() { public String getPassword() {
return password; return password;
} }
/** /**
* *
* */
* @param password
*/
public void setPassword(String password) { public void setPassword(String password) {
this.password = password; this.password = password;
} }
/** /**
* *
* */
* @return
*/
public String getYishengName() { public String getYishengName() {
return yishengName; return yishengName;
} }
/** /**
* *
* */
* @param yishengName
*/
public void setYishengName(String yishengName) { public void setYishengName(String yishengName) {
this.yishengName = yishengName; this.yishengName = yishengName;
} }
/** /**
* *
* */
* @return
*/
public Integer getYishengTypes() { public Integer getYishengTypes() {
return yishengTypes; return yishengTypes;
} }
/** /**
* *
* */
* @param yishengTypes
*/
public void setYishengTypes(Integer yishengTypes) { public void setYishengTypes(Integer yishengTypes) {
this.yishengTypes = yishengTypes; this.yishengTypes = yishengTypes;
} }
/** /**
* *
* */
* @return
*/
public Integer getZhiweiTypes() { public Integer getZhiweiTypes() {
return zhiweiTypes; return zhiweiTypes;
} }
/** /**
* *
* */
* @param zhiweiTypes
*/
public void setZhiweiTypes(Integer zhiweiTypes) { public void setZhiweiTypes(Integer zhiweiTypes) {
this.zhiweiTypes = zhiweiTypes; this.zhiweiTypes = zhiweiTypes;
} }
/** /**
* *
* */
* @return
*/
public String getYishengZhichneg() { public String getYishengZhichneg() {
return yishengZhichneg; return yishengZhichneg;
} }
/** /**
* *
* */
* @param yishengZhichneg
*/
public void setYishengZhichneg(String yishengZhichneg) { public void setYishengZhichneg(String yishengZhichneg) {
this.yishengZhichneg = yishengZhichneg; this.yishengZhichneg = yishengZhichneg;
} }
/** /**
* *
* */
* @return
*/
public String getYishengPhoto() { public String getYishengPhoto() {
return yishengPhoto; return yishengPhoto;
} }
/** /**
* *
* */
* @param yishengPhoto
*/
public void setYishengPhoto(String yishengPhoto) { public void setYishengPhoto(String yishengPhoto) {
this.yishengPhoto = yishengPhoto; this.yishengPhoto = yishengPhoto;
} }
/** /**
* *
* */
* @return
*/
public String getYishengPhone() { public String getYishengPhone() {
return yishengPhone; return yishengPhone;
} }
/** /**
* *
* */
* @param yishengPhone
*/
public void setYishengPhone(String yishengPhone) { public void setYishengPhone(String yishengPhone) {
this.yishengPhone = yishengPhone; this.yishengPhone = yishengPhone;
} }
/** /**
* *
* */
* @return
*/
public String getYishengGuahao() { public String getYishengGuahao() {
return yishengGuahao; return yishengGuahao;
} }
/** /**
* *
* */
* @param yishengGuahao
*/
public void setYishengGuahao(String yishengGuahao) { public void setYishengGuahao(String yishengGuahao) {
this.yishengGuahao = yishengGuahao; this.yishengGuahao = yishengGuahao;
} }
/** /**
* *
* */
* @return
*/
public String getYishengEmail() { public String getYishengEmail() {
return yishengEmail; return yishengEmail;
} }
/** /**
* *
* */
* @param yishengEmail
*/
public void setYishengEmail(String yishengEmail) { public void setYishengEmail(String yishengEmail) {
this.yishengEmail = yishengEmail; this.yishengEmail = yishengEmail;
} }
/** /**
* *
* */
* @return
*/
public Double getYishengNewMoney() { public Double getYishengNewMoney() {
return yishengNewMoney; return yishengNewMoney;
} }
/** /**
* *
* */
* @param yishengNewMoney
*/
public void setYishengNewMoney(Double yishengNewMoney) { public void setYishengNewMoney(Double yishengNewMoney) {
this.yishengNewMoney = yishengNewMoney; this.yishengNewMoney = yishengNewMoney;
} }
/** /**
* *
* */
* @return
*/
public String getYishengContent() { public String getYishengContent() {
return yishengContent; return yishengContent;
} }
/** /**
* *
* */
* @param yishengContent
*/
public void setYishengContent(String yishengContent) { public void setYishengContent(String yishengContent) {
this.yishengContent = yishengContent; this.yishengContent = yishengContent;
} }
/** /**
* *
* */
* @return
*/
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
/** /**
* *
* */
* @param createTime
*/
public void setCreateTime(Date createTime) { public void setCreateTime(Date createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
/**
* toString
* 便
*
* @return
*/
@Override @Override
public String toString() { public String toString() {
return "Yisheng{" + return "Yisheng{" +

@ -27,311 +27,299 @@ import com.baomidou.mybatisplus.enums.IdType;
* @author * @author
* @email * @email
*/ */
@TableName("yonghu") // 指定对应的数据库表名 @TableName("yonghu")
public class YonghuEntity<T> implements Serializable { public class YonghuEntity<T> implements Serializable {
private static final long serialVersionUID = 1L; // 序列化版本UID private static final long serialVersionUID = 1L;
/**
*
*/
public YonghuEntity() {
} public YonghuEntity() {
/**
*
* BeanUtils
* @param t
*/
public YonghuEntity(T t) {
try {
BeanUtils.copyProperties(this, t); // 使用BeanUtils进行属性拷贝
} catch (IllegalAccessException | InvocationTargetException e) {
// 打印异常堆栈
e.printStackTrace();
}
} }
public YonghuEntity(T t) {
try {
BeanUtils.copyProperties(this, t);
} catch (IllegalAccessException | InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/** /**
* ID * ID
* *
*/ */
@TableId(type = IdType.AUTO) // 主键自增 @TableId(type = IdType.AUTO)
@TableField(value = "id") // 对应数据库字段名 @TableField(value = "id")
private Integer id; private Integer id;
/** /**
* / * /
* *
*/ */
@TableField(value = "username") // 对应数据库字段名 @TableField(value = "username")
private String username; private String username;
/** /**
* *
* *
*/ */
@TableField(value = "password") // 对应数据库字段名 @TableField(value = "password")
private String password; private String password;
/** /**
* *
*/ */
@TableField(value = "yonghu_name") // 对应数据库字段名 @TableField(value = "yonghu_name")
private String yonghuName; private String yonghuName;
/** /**
* *
* *
*/ */
@TableField(value = "yonghu_photo") // 对应数据库字段名 @TableField(value = "yonghu_photo")
private String yonghuPhoto; private String yonghuPhoto;
/** /**
* *
*/ */
@TableField(value = "yonghu_phone") // 对应数据库字段名 @TableField(value = "yonghu_phone")
private String yonghuPhone; private String yonghuPhone;
/** /**
* *
*/ */
@TableField(value = "yonghu_id_number") // 对应数据库字段名 @TableField(value = "yonghu_id_number")
private String yonghuIdNumber; private String yonghuIdNumber;
/** /**
* *
*/ */
@TableField(value = "yonghu_email") // 对应数据库字段名 @TableField(value = "yonghu_email")
private String yonghuEmail; private String yonghuEmail;
/** /**
* *
* 使 * 使
*/ */
@TableField(value = "sex_types") // 对应数据库字段名 @TableField(value = "sex_types")
private Integer sexTypes; private Integer sexTypes;
/** /**
* *
*/ */
@TableField(value = "new_money") // 对应数据库字段名 @TableField(value = "new_money")
private Double newMoney; private Double newMoney;
/** /**
* *
* 1-2- * 1-2-
*/ */
@TableField(value = "yonghu_delete") // 对应数据库字段名 @TableField(value = "yonghu_delete")
private Integer yonghuDelete; private Integer yonghuDelete;
/** /**
* *
* yyyy-MM-dd HH:mm:ss * yyyy-MM-dd HH:mm:ss
*/ */
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") // 日期格式化 @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@DateTimeFormat // 日期格式 @DateTimeFormat
@TableField(value = "create_time",fill = FieldFill.INSERT) // 插入时自动填充 @TableField(value = "create_time",fill = FieldFill.INSERT)
private Date createTime; private Date createTime;
// ================ getter和setter方法 ================
/** /**
* ID *
* @return id ID */
*/
public Integer getId() { public Integer getId() {
return id; return id;
} }
/** /**
* ID *
* @param id ID */
*/
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
/** /**
* / *
* @return username */
*/
public String getUsername() { public String getUsername() {
return username; return username;
} }
/** /**
* / *
* @param username */
*/
public void setUsername(String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
/** /**
* *
* @return password */
*/
public String getPassword() { public String getPassword() {
return password; return password;
} }
/** /**
* *
* @param password */
*/
public void setPassword(String password) { public void setPassword(String password) {
this.password = password; this.password = password;
} }
/** /**
* *
* @return yonghuName */
*/
public String getYonghuName() { public String getYonghuName() {
return yonghuName; return yonghuName;
} }
/** /**
* *
* @param yonghuName */
*/
public void setYonghuName(String yonghuName) { public void setYonghuName(String yonghuName) {
this.yonghuName = yonghuName; this.yonghuName = yonghuName;
} }
/** /**
* *
* @return yonghuPhoto */
*/
public String getYonghuPhoto() { public String getYonghuPhoto() {
return yonghuPhoto; return yonghuPhoto;
} }
/** /**
* *
* @param yonghuPhoto */
*/
public void setYonghuPhoto(String yonghuPhoto) { public void setYonghuPhoto(String yonghuPhoto) {
this.yonghuPhoto = yonghuPhoto; this.yonghuPhoto = yonghuPhoto;
} }
/** /**
* *
* @return yonghuPhone */
*/
public String getYonghuPhone() { public String getYonghuPhone() {
return yonghuPhone; return yonghuPhone;
} }
/** /**
* *
* @param yonghuPhone */
*/
public void setYonghuPhone(String yonghuPhone) { public void setYonghuPhone(String yonghuPhone) {
this.yonghuPhone = yonghuPhone; this.yonghuPhone = yonghuPhone;
} }
/** /**
* *
* @return yonghuIdNumber */
*/
public String getYonghuIdNumber() { public String getYonghuIdNumber() {
return yonghuIdNumber; return yonghuIdNumber;
} }
/** /**
* *
* @param yonghuIdNumber */
*/
public void setYonghuIdNumber(String yonghuIdNumber) { public void setYonghuIdNumber(String yonghuIdNumber) {
this.yonghuIdNumber = yonghuIdNumber; this.yonghuIdNumber = yonghuIdNumber;
} }
/** /**
* *
* @return yonghuEmail */
*/
public String getYonghuEmail() { public String getYonghuEmail() {
return yonghuEmail; return yonghuEmail;
} }
/** /**
* *
* @param yonghuEmail */
*/
public void setYonghuEmail(String yonghuEmail) { public void setYonghuEmail(String yonghuEmail) {
this.yonghuEmail = yonghuEmail; this.yonghuEmail = yonghuEmail;
} }
/** /**
* *
* @return sexTypes */
*/
public Integer getSexTypes() { public Integer getSexTypes() {
return sexTypes; return sexTypes;
} }
/** /**
* *
* @param sexTypes */
*/
public void setSexTypes(Integer sexTypes) { public void setSexTypes(Integer sexTypes) {
this.sexTypes = sexTypes; this.sexTypes = sexTypes;
} }
/** /**
* *
* @return newMoney */
*/
public Double getNewMoney() { public Double getNewMoney() {
return newMoney; return newMoney;
} }
/** /**
* *
* @param newMoney */
*/
public void setNewMoney(Double newMoney) { public void setNewMoney(Double newMoney) {
this.newMoney = newMoney; this.newMoney = newMoney;
} }
/** /**
* *
* @return yonghuDelete (1-2-) */
*/
public Integer getYonghuDelete() { public Integer getYonghuDelete() {
return yonghuDelete; return yonghuDelete;
} }
/** /**
* *
* @param yonghuDelete (1-2-) */
*/
public void setYonghuDelete(Integer yonghuDelete) { public void setYonghuDelete(Integer yonghuDelete) {
this.yonghuDelete = yonghuDelete; this.yonghuDelete = yonghuDelete;
} }
/** /**
* *
* @return createTime */
*/
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
/** /**
* *
* @param createTime */
*/
public void setCreateTime(Date createTime) { public void setCreateTime(Date createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
/**
* toString
* @return
*/
@Override @Override
public String toString() { public String toString() {
return "Yonghu{" + return "Yonghu{" +

@ -8,7 +8,6 @@ import java.util.Date;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
/** /**
* 线 * 线
* *
@ -16,196 +15,216 @@ import java.io.Serializable;
* ModelAndView model * ModelAndView model
*/ */
public class ChatModel implements Serializable { public class ChatModel implements Serializable {
// 序列化版本号,用于保证序列化和反序列化的兼容性
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* *
*/ */
// 用于唯一标识一条在线咨询记录的主键
private Integer id; private Integer id;
/** /**
* *
*/ */
// 发起咨询问题的用户的ID
private Integer yonghuId; private Integer yonghuId;
/** /**
* *
*/ */
// 用户提出的咨询问题内容
private String chatIssue; private String chatIssue;
/** /**
* *
*/ */
// 设置JSON序列化时日期的格式使用中文环境时区为东八区格式为 "yyyy-MM-dd HH:mm:ss"
@JsonFormat(locale="zh", timezone="GMT+8", pattern="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 Date issueTime;
/** /**
* *
*/ */
// 针对用户咨询问题给出的回复内容
private String chatReply; private String chatReply;
/** /**
* *
*/ */
// 设置JSON序列化时日期的格式使用中文环境时区为东八区格式为 "yyyy-MM-dd HH:mm:ss"
@JsonFormat(locale="zh", timezone="GMT+8", pattern="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 Date replyTime;
/** /**
* *
*/ */
// 表示该在线咨询记录的状态,使用整数类型表示不同状态
private Integer zhuangtaiTypes; private Integer zhuangtaiTypes;
/** /**
* *
*/ */
// 表示该在线咨询记录的数据类型,使用整数类型表示不同类型
private Integer chatTypes; private Integer chatTypes;
/** /**
* *
*/ */
// 设置JSON序列化时日期的格式使用中文环境时区为东八区格式为 "yyyy-MM-dd HH:mm:ss"
@JsonFormat(locale="zh", timezone="GMT+8", pattern="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 Date insertTime;
/** /**
* *
*/ */
// 获取主键ID的方法
public Integer getId() { public Integer getId() {
return id; return id;
} }
/** /**
* *
*/ */
// 设置主键ID的方法
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
/** /**
* *
*/ */
// 获取提问用户ID的方法
public Integer getYonghuId() { public Integer getYonghuId() {
return yonghuId; return yonghuId;
} }
/** /**
* *
*/ */
// 设置提问用户ID的方法
public void setYonghuId(Integer yonghuId) { public void setYonghuId(Integer yonghuId) {
this.yonghuId = yonghuId; this.yonghuId = yonghuId;
} }
/** /**
* *
*/ */
// 获取咨询问题内容的方法
public String getChatIssue() { public String getChatIssue() {
return chatIssue; return chatIssue;
} }
/** /**
* *
*/ */
// 设置咨询问题内容的方法
public void setChatIssue(String chatIssue) { public void setChatIssue(String chatIssue) {
this.chatIssue = chatIssue; this.chatIssue = chatIssue;
} }
/** /**
* *
*/ */
// 获取用户提出问题时间的方法
public Date getIssueTime() { public Date getIssueTime() {
return issueTime; return issueTime;
} }
/** /**
* *
*/ */
// 设置用户提出问题时间的方法
public void setIssueTime(Date issueTime) { public void setIssueTime(Date issueTime) {
this.issueTime = issueTime; this.issueTime = issueTime;
} }
/** /**
* *
*/ */
// 获取咨询问题回复内容的方法
public String getChatReply() { public String getChatReply() {
return chatReply; return chatReply;
} }
/** /**
* *
*/ */
// 设置咨询问题回复内容的方法
public void setChatReply(String chatReply) { public void setChatReply(String chatReply) {
this.chatReply = chatReply; this.chatReply = chatReply;
} }
/** /**
* *
*/ */
// 获取给出回复时间的方法
public Date getReplyTime() { public Date getReplyTime() {
return replyTime; return replyTime;
} }
/** /**
* *
*/ */
// 设置给出回复时间的方法
public void setReplyTime(Date replyTime) { public void setReplyTime(Date replyTime) {
this.replyTime = replyTime; this.replyTime = replyTime;
} }
/** /**
* *
*/ */
// 获取咨询记录状态的方法
public Integer getZhuangtaiTypes() { public Integer getZhuangtaiTypes() {
return zhuangtaiTypes; return zhuangtaiTypes;
} }
/** /**
* *
*/ */
// 设置咨询记录状态的方法
public void setZhuangtaiTypes(Integer zhuangtaiTypes) { public void setZhuangtaiTypes(Integer zhuangtaiTypes) {
this.zhuangtaiTypes = zhuangtaiTypes; this.zhuangtaiTypes = zhuangtaiTypes;
} }
/** /**
* *
*/ */
// 获取咨询记录数据类型的方法
public Integer getChatTypes() { public Integer getChatTypes() {
return chatTypes; return chatTypes;
} }
/** /**
* *
*/ */
// 设置咨询记录数据类型的方法
public void setChatTypes(Integer chatTypes) { public void setChatTypes(Integer chatTypes) {
this.chatTypes = chatTypes; this.chatTypes = chatTypes;
} }
/** /**
* *
*/ */
// 获取咨询记录创建时间的方法
public Date getInsertTime() { public Date getInsertTime() {
return insertTime; return insertTime;
} }
/** /**
* *
*/ */
// 设置咨询记录创建时间的方法
public void setInsertTime(Date insertTime) { public void setInsertTime(Date insertTime) {
this.insertTime = insertTime; this.insertTime = insertTime;
} }
}
}

@ -1,187 +1,206 @@
package com.entity.model; package com.entity.model;
// 引入字典表实体类,可能用于与数据库实体交互或类型转换等操作
import com.entity.DictionaryEntity; import com.entity.DictionaryEntity;
// 该注解用于指定实体类对应的数据库表名,不过在当前代码中未实际使用该功能
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
// 用于在将对象序列化为JSON时对日期类型的字段进行格式化处理
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date; import java.util.Date;
// 用于在Spring MVC中将前端传递的日期字符串绑定到Java对象的日期字段时进行格式化
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
// 实现该接口意味着这个类的对象可以被序列化和反序列化,方便在网络传输或存储时使用
import java.io.Serializable; import java.io.Serializable;
/** /**
* *
* *
* entity * entity
* ModelAndView model * ModelAndView model
*/ */
// 定义一个名为DictionaryModel的类实现Serializable接口用于接收字典表相关的参数
public class DictionaryModel implements Serializable { public class DictionaryModel implements Serializable {
// 序列化版本号,用于在反序列化时验证版本一致性,避免不同版本类之间反序列化出错
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* *
*/ */
// 用于唯一标识字典表中的每一条记录,在数据库操作中常作为主键使用
private Integer id; private Integer id;
/** /**
* *
*/ */
// 表示字典表中的某个字段,可能用于存储特定的数据标识
private String dicCode; private String dicCode;
/** /**
* *
*/ */
// 该字段的名称用于更直观地描述dicCode所代表的含义
private String dicName; private String dicName;
/** /**
* *
*/ */
// 可能是对该字段的一种编码表示,方便数据的分类和查询
private Integer codeIndex; private Integer codeIndex;
/** /**
* *
*/ */
// 编码对应的名称,用于更清晰地展示编码的具体含义
private String indexName; private String indexName;
/** /**
* id * id
*/ */
// 用于关联父字段,可能用于构建字典表的层级结构
private Integer superId; private Integer superId;
/** /**
* *
*/ */
// 对该条字典记录的额外说明信息,可用于记录一些特殊情况或备注
private String beizhu; private String beizhu;
/** /**
* *
*/ */
// 对日期进行JSON序列化时指定日期的格式、语言环境和时区
@JsonFormat(locale="zh", timezone="GMT+8", pattern="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; private Date createTime;
/** /**
* *
*/ */
// 定义一个公共的获取主键的方法供外部调用获取id的值
public Integer getId() { public Integer getId() {
return id; return id;
} }
/** /**
* *
*/ */
// 定义一个公共的设置主键的方法供外部调用设置id的值
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
/** /**
* *
*/ */
// 定义一个公共的获取字段标识的方法供外部调用获取dicCode的值
public String getDicCode() { public String getDicCode() {
return dicCode; return dicCode;
} }
/** /**
* *
*/ */
// 定义一个公共的设置字段标识的方法供外部调用设置dicCode的值
public void setDicCode(String dicCode) { public void setDicCode(String dicCode) {
this.dicCode = dicCode; this.dicCode = dicCode;
} }
/** /**
* *
*/ */
// 定义一个公共的获取字段名称的方法供外部调用获取dicName的值
public String getDicName() { public String getDicName() {
return dicName; return dicName;
} }
/** /**
* *
*/ */
// 定义一个公共的设置字段名称的方法供外部调用设置dicName的值
public void setDicName(String dicName) { public void setDicName(String dicName) {
this.dicName = dicName; this.dicName = dicName;
} }
/** /**
* *
*/ */
// 定义一个公共的获取编码的方法供外部调用获取codeIndex的值
public Integer getCodeIndex() { public Integer getCodeIndex() {
return codeIndex; return codeIndex;
} }
/** /**
* *
*/ */
// 定义一个公共的设置编码的方法供外部调用设置codeIndex的值
public void setCodeIndex(Integer codeIndex) { public void setCodeIndex(Integer codeIndex) {
this.codeIndex = codeIndex; this.codeIndex = codeIndex;
} }
/** /**
* *
*/ */
// 定义一个公共的获取编码名称的方法供外部调用获取indexName的值
public String getIndexName() { public String getIndexName() {
return indexName; return indexName;
} }
/** /**
* *
*/ */
// 定义一个公共的设置编码名称的方法供外部调用设置indexName的值
public void setIndexName(String indexName) { public void setIndexName(String indexName) {
this.indexName = indexName; this.indexName = indexName;
} }
/** /**
* id * id
*/ */
// 定义一个公共的获取父字段ID的方法供外部调用获取superId的值
public Integer getSuperId() { public Integer getSuperId() {
return superId; return superId;
} }
/** /**
* id * id
*/ */
// 定义一个公共的设置父字段ID的方法供外部调用设置superId的值
public void setSuperId(Integer superId) { public void setSuperId(Integer superId) {
this.superId = superId; this.superId = superId;
} }
/** /**
* *
*/ */
// 定义一个公共的获取备注信息的方法供外部调用获取beizhu的值
public String getBeizhu() { public String getBeizhu() {
return beizhu; return beizhu;
} }
/** /**
* *
*/ */
// 定义一个公共的设置备注信息的方法供外部调用设置beizhu的值
public void setBeizhu(String beizhu) { public void setBeizhu(String beizhu) {
this.beizhu = beizhu; this.beizhu = beizhu;
} }
/** /**
* *
*/ */
// 定义一个公共的获取创建时间的方法供外部调用获取createTime的值
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
/** /**
* *
*/ */
// 定义一个公共的设置创建时间的方法供外部调用设置createTime的值
public void setCreateTime(Date createTime) { public void setCreateTime(Date createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
}
}

@ -1,229 +1,253 @@
package com.entity.model; package com.entity.model;
// 导入GuahaoEntity类可能用于实体之间的转换或关联操作
import com.entity.GuahaoEntity; import com.entity.GuahaoEntity;
// 导入MyBatis-Plus的TableName注解这里可能用于指定数据库表名但代码中未实际使用
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
// 导入Jackson的JsonFormat注解用于在JSON序列化和反序列化时格式化日期类型字段
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date; import java.util.Date;
// 导入Spring的DateTimeFormat注解用于在处理表单数据时格式化日期类型字段
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
/** /**
* *
* *
* entity * entity
* ModelAndView model * ModelAndView model
*/ */
// 定义一个名为GuahaoModel的类实现Serializable接口使其对象可序列化
public class GuahaoModel implements Serializable { public class GuahaoModel implements Serializable {
// 定义序列化版本号,确保在不同版本的类之间进行序列化和反序列化时的兼容性
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* *
*/ */
// 用于唯一标识挂号记录的主键,在数据库操作中通常作为唯一标识
private Integer id; private Integer id;
/** /**
* *
*/ */
// 表示进行挂号的医生的ID用于关联医生信息
private Integer yishengId; private Integer yishengId;
/** /**
* *
*/ */
// 表示进行挂号的用户的ID用于关联用户信息
private Integer yonghuId; private Integer yonghuId;
/** /**
* *
*/ */
// 可能是用于识别就诊记录的唯一编码,具体用途可能根据业务需求而定
private Integer guahaoUuinNumber; private Integer guahaoUuinNumber;
/** /**
* *
*/ */
// 设置JSON序列化时日期的格式使用中文环境时区为东八区格式为 "yyyy-MM-dd HH:mm:ss"
@JsonFormat(locale="zh", timezone="GMT+8", pattern="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 Date guahaoTime;
/** /**
* *
*/ */
// 可能用于区分不同类型的挂号时间,例如预约时间、实际挂号时间等
private Integer guahaoTypes; private Integer guahaoTypes;
/** /**
* *
*/ */
// 用于表示挂号的当前状态,例如已挂号、已取消、已就诊等
private Integer guahaoStatusTypes; private Integer guahaoStatusTypes;
/** /**
* *
*/ */
// 用于表示挂号是否经过审核可能是0未审核、1审核通过、2审核不通过
private Integer guahaoYesnoTypes; private Integer guahaoYesnoTypes;
/** /**
* *
*/ */
// 当挂号经过审核后,记录审核的具体结果信息,例如审核不通过的原因等
private String guahaoYesnoText; private String guahaoYesnoText;
/** /**
* *
*/ */
// 设置JSON序列化时日期的格式使用中文环境时区为东八区格式为 "yyyy-MM-dd HH:mm:ss"
@JsonFormat(locale="zh", timezone="GMT+8", pattern="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; private Date createTime;
/** /**
* *
*/ */
// 获取主键ID的方法供外部调用以获取该挂号记录的唯一标识
public Integer getId() { public Integer getId() {
return id; return id;
} }
/** /**
* *
*/ */
// 设置主键ID的方法供外部调用以设置该挂号记录的唯一标识
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
/** /**
* *
*/ */
// 获取进行挂号的医生ID的方法供外部调用以获取医生的标识
public Integer getYishengId() { public Integer getYishengId() {
return yishengId; return yishengId;
} }
/** /**
* *
*/ */
// 设置进行挂号的医生ID的方法供外部调用以设置医生的标识
public void setYishengId(Integer yishengId) { public void setYishengId(Integer yishengId) {
this.yishengId = yishengId; this.yishengId = yishengId;
} }
/** /**
* *
*/ */
// 获取进行挂号的用户ID的方法供外部调用以获取用户的标识
public Integer getYonghuId() { public Integer getYonghuId() {
return yonghuId; return yonghuId;
} }
/** /**
* *
*/ */
// 设置进行挂号的用户ID的方法供外部调用以设置用户的标识
public void setYonghuId(Integer yonghuId) { public void setYonghuId(Integer yonghuId) {
this.yonghuId = yonghuId; this.yonghuId = yonghuId;
} }
/** /**
* *
*/ */
// 获取就诊识别码的方法,供外部调用以获取该挂号记录的识别编码
public Integer getGuahaoUuinNumber() { public Integer getGuahaoUuinNumber() {
return guahaoUuinNumber; return guahaoUuinNumber;
} }
/** /**
* *
*/ */
// 设置就诊识别码的方法,供外部调用以设置该挂号记录的识别编码
public void setGuahaoUuinNumber(Integer guahaoUuinNumber) { public void setGuahaoUuinNumber(Integer guahaoUuinNumber) {
this.guahaoUuinNumber = guahaoUuinNumber; this.guahaoUuinNumber = guahaoUuinNumber;
} }
/** /**
* *
*/ */
// 获取挂号时间的方法,供外部调用以获取挂号操作的具体时间
public Date getGuahaoTime() { public Date getGuahaoTime() {
return guahaoTime; return guahaoTime;
} }
/** /**
* *
*/ */
// 设置挂号时间的方法,供外部调用以设置挂号操作的具体时间
public void setGuahaoTime(Date guahaoTime) { public void setGuahaoTime(Date guahaoTime) {
this.guahaoTime = guahaoTime; this.guahaoTime = guahaoTime;
} }
/** /**
* *
*/ */
// 获取时间类型的方法,供外部调用以获取该挂号记录的时间类型
public Integer getGuahaoTypes() { public Integer getGuahaoTypes() {
return guahaoTypes; return guahaoTypes;
} }
/** /**
* *
*/ */
// 设置时间类型的方法,供外部调用以设置该挂号记录的时间类型
public void setGuahaoTypes(Integer guahaoTypes) { public void setGuahaoTypes(Integer guahaoTypes) {
this.guahaoTypes = guahaoTypes; this.guahaoTypes = guahaoTypes;
} }
/** /**
* *
*/ */
// 获取挂号状态的方法,供外部调用以获取该挂号记录的当前状态
public Integer getGuahaoStatusTypes() { public Integer getGuahaoStatusTypes() {
return guahaoStatusTypes; return guahaoStatusTypes;
} }
/** /**
* *
*/ */
// 设置挂号状态的方法,供外部调用以设置该挂号记录的当前状态
public void setGuahaoStatusTypes(Integer guahaoStatusTypes) { public void setGuahaoStatusTypes(Integer guahaoStatusTypes) {
this.guahaoStatusTypes = guahaoStatusTypes; this.guahaoStatusTypes = guahaoStatusTypes;
} }
/** /**
* *
*/ */
// 获取挂号审核状态的方法,供外部调用以获取该挂号记录的审核状态
public Integer getGuahaoYesnoTypes() { public Integer getGuahaoYesnoTypes() {
return guahaoYesnoTypes; return guahaoYesnoTypes;
} }
/** /**
* *
*/ */
// 设置挂号审核状态的方法,供外部调用以设置该挂号记录的审核状态
public void setGuahaoYesnoTypes(Integer guahaoYesnoTypes) { public void setGuahaoYesnoTypes(Integer guahaoYesnoTypes) {
this.guahaoYesnoTypes = guahaoYesnoTypes; this.guahaoYesnoTypes = guahaoYesnoTypes;
} }
/** /**
* *
*/ */
// 获取审核结果的方法,供外部调用以获取该挂号记录的审核具体结果信息
public String getGuahaoYesnoText() { public String getGuahaoYesnoText() {
return guahaoYesnoText; return guahaoYesnoText;
} }
/** /**
* *
*/ */
// 设置审核结果的方法,供外部调用以设置该挂号记录的审核具体结果信息
public void setGuahaoYesnoText(String guahaoYesnoText) { public void setGuahaoYesnoText(String guahaoYesnoText) {
this.guahaoYesnoText = guahaoYesnoText; this.guahaoYesnoText = guahaoYesnoText;
} }
/** /**
* *
*/ */
// 获取创建时间的方法,供外部调用以获取该挂号记录的创建时间
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
/** /**
* *
*/ */
// 设置创建时间的方法,供外部调用以设置该挂号记录的创建时间
public void setCreateTime(Date createTime) { public void setCreateTime(Date createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
}
}

@ -1,189 +1,209 @@
package com.entity.model; package com.entity.model;
// 导入JiankangjiaoyuEntity类可能用于与数据库实体进行交互或数据转换等操作
import com.entity.JiankangjiaoyuEntity; import com.entity.JiankangjiaoyuEntity;
// 导入MyBatis-Plus的TableName注解通常用于指定数据库表名但在当前代码中未实际使用该注解
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
// 导入Jackson的JsonFormat注解用于在JSON序列化和反序列化时对日期类型字段进行格式化处理
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date; import java.util.Date;
// 导入Spring的DateTimeFormat注解用于在处理表单数据时对日期类型字段进行格式化
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
/** /**
* *
* *
* entity * entity
* ModelAndView model * ModelAndView model
*/ */
// 定义一个名为JiankangjiaoyuModel的类实现Serializable接口使该类的对象可以被序列化和反序列化
public class JiankangjiaoyuModel implements Serializable { public class JiankangjiaoyuModel implements Serializable {
// 定义序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* *
*/ */
// 用于唯一标识健康教育记录的主键,在数据库操作中通常作为唯一标识字段
private Integer id; private Integer id;
/** /**
* *
*/ */
// 存储健康教育内容的标题,用于展示和区分不同的健康教育信息
private String jiankangjiaoyuName; private String jiankangjiaoyuName;
/** /**
* *
*/ */
// 表示健康教育的具体类型,可能是如疾病预防、健康生活方式等不同分类,以整数类型存储
private Integer jiankangjiaoyuTypes; private Integer jiankangjiaoyuTypes;
/** /**
* *
*/ */
// 存储健康教育相关的图片路径或标识,用于展示相关的图片内容
private String jiankangjiaoyuPhoto; private String jiankangjiaoyuPhoto;
/** /**
* *
*/ */
// 设置JSON序列化时日期的格式使用中文环境时区为东八区格式为 "yyyy-MM-dd HH:mm:ss"
@JsonFormat(locale="zh", timezone="GMT+8", pattern="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 Date insertTime;
/** /**
* *
*/ */
// 存储健康教育的详细内容,如具体的健康知识、建议等文本信息
private String jiankangjiaoyuContent; private String jiankangjiaoyuContent;
/** /**
* *
*/ */
// 用于实现逻辑删除的字段可能0表示未删除1表示已删除假删以整数类型存储
private Integer jiankangjiaoyuDelete; private Integer jiankangjiaoyuDelete;
/** /**
* show1 show2 nameShow * show1 show2 nameShow
*/ */
// 设置JSON序列化时日期的格式使用中文环境时区为东八区格式为 "yyyy-MM-dd HH:mm:ss"
@JsonFormat(locale="zh", timezone="GMT+8", pattern="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; private Date createTime;
/** /**
* *
*/ */
// 获取主键ID的方法供外部调用以获取该健康教育记录的唯一标识
public Integer getId() { public Integer getId() {
return id; return id;
} }
/** /**
* *
*/ */
// 设置主键ID的方法供外部调用以设置该健康教育记录的唯一标识
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
/** /**
* *
*/ */
// 获取健康教育标题的方法,供外部调用以获取该记录的标题信息
public String getJiankangjiaoyuName() { public String getJiankangjiaoyuName() {
return jiankangjiaoyuName; return jiankangjiaoyuName;
} }
/** /**
* *
*/ */
// 设置健康教育标题的方法,供外部调用以修改该记录的标题信息
public void setJiankangjiaoyuName(String jiankangjiaoyuName) { public void setJiankangjiaoyuName(String jiankangjiaoyuName) {
this.jiankangjiaoyuName = jiankangjiaoyuName; this.jiankangjiaoyuName = jiankangjiaoyuName;
} }
/** /**
* *
*/ */
// 获取健康教育类型的方法,供外部调用以获取该记录的类型信息
public Integer getJiankangjiaoyuTypes() { public Integer getJiankangjiaoyuTypes() {
return jiankangjiaoyuTypes; return jiankangjiaoyuTypes;
} }
/** /**
* *
*/ */
// 设置健康教育类型的方法,供外部调用以修改该记录的类型信息
public void setJiankangjiaoyuTypes(Integer jiankangjiaoyuTypes) { public void setJiankangjiaoyuTypes(Integer jiankangjiaoyuTypes) {
this.jiankangjiaoyuTypes = jiankangjiaoyuTypes; this.jiankangjiaoyuTypes = jiankangjiaoyuTypes;
} }
/** /**
* *
*/ */
// 获取健康教育图片相关信息的方法,供外部调用以获取图片路径或标识
public String getJiankangjiaoyuPhoto() { public String getJiankangjiaoyuPhoto() {
return jiankangjiaoyuPhoto; return jiankangjiaoyuPhoto;
} }
/** /**
* *
*/ */
// 设置健康教育图片相关信息的方法,供外部调用以修改图片路径或标识
public void setJiankangjiaoyuPhoto(String jiankangjiaoyuPhoto) { public void setJiankangjiaoyuPhoto(String jiankangjiaoyuPhoto) {
this.jiankangjiaoyuPhoto = jiankangjiaoyuPhoto; this.jiankangjiaoyuPhoto = jiankangjiaoyuPhoto;
} }
/** /**
* *
*/ */
// 获取健康教育内容插入时间的方法,供外部调用以获取该记录的插入时间
public Date getInsertTime() { public Date getInsertTime() {
return insertTime; return insertTime;
} }
/** /**
* *
*/ */
// 设置健康教育内容插入时间的方法,供外部调用以修改该记录的插入时间
public void setInsertTime(Date insertTime) { public void setInsertTime(Date insertTime) {
this.insertTime = insertTime; this.insertTime = insertTime;
} }
/** /**
* *
*/ */
// 获取健康教育详细内容的方法,供外部调用以获取该记录的详细文本信息
public String getJiankangjiaoyuContent() { public String getJiankangjiaoyuContent() {
return jiankangjiaoyuContent; return jiankangjiaoyuContent;
} }
/** /**
* *
*/ */
// 设置健康教育详细内容的方法,供外部调用以修改该记录的详细文本信息
public void setJiankangjiaoyuContent(String jiankangjiaoyuContent) { public void setJiankangjiaoyuContent(String jiankangjiaoyuContent) {
this.jiankangjiaoyuContent = jiankangjiaoyuContent; this.jiankangjiaoyuContent = jiankangjiaoyuContent;
} }
/** /**
* *
*/ */
// 获取逻辑删除标识的方法,供外部调用以获取该记录的假删状态
public Integer getJiankangjiaoyuDelete() { public Integer getJiankangjiaoyuDelete() {
return jiankangjiaoyuDelete; return jiankangjiaoyuDelete;
} }
/** /**
* *
*/ */
// 设置逻辑删除标识的方法,供外部调用以修改该记录的假删状态
public void setJiankangjiaoyuDelete(Integer jiankangjiaoyuDelete) { public void setJiankangjiaoyuDelete(Integer jiankangjiaoyuDelete) {
this.jiankangjiaoyuDelete = jiankangjiaoyuDelete; this.jiankangjiaoyuDelete = jiankangjiaoyuDelete;
} }
/** /**
* show1 show2 nameShow * show1 show2 nameShow
*/ */
// 获取健康教育记录创建时间的方法,供外部调用以获取该记录的实际创建时间
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
/** /**
* show1 show2 nameShow * show1 show2 nameShow
*/ */
// 设置健康教育记录创建时间的方法,供外部调用以修改该记录的实际创建时间
public void setCreateTime(Date createTime) { public void setCreateTime(Date createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
}
}

@ -1,169 +1,188 @@
package com.entity.model; package com.entity.model;
// 导入NewsEntity类可能用于与数据库实体交互或进行数据转换
import com.entity.NewsEntity; import com.entity.NewsEntity;
// 导入MyBatis-Plus的TableName注解通常用于指定实体类对应的数据库表名但此代码未实际使用
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
// 导入Jackson的JsonFormat注解用于在JSON序列化和反序列化时对日期类型字段进行格式化
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date; import java.util.Date;
// 导入Spring的DateTimeFormat注解用于在处理表单数据时对日期类型字段进行格式化
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
// 导入Serializable接口实现该接口意味着该类的对象可以被序列化和反序列化
import java.io.Serializable; import java.io.Serializable;
/** /**
* *
* *
* entity * entity
* ModelAndView model * ModelAndView model
*/ */
// 定义一个名为NewsModel的类实现Serializable接口
public class NewsModel implements Serializable { public class NewsModel implements Serializable {
// 序列化版本号,用于保证序列化和反序列化过程中类的兼容性
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* *
*/ */
// 用于唯一标识每条公告信息的主键
private Integer id; private Integer id;
/** /**
* *
*/ */
// 存储公告的名称,用于在列表等地方显示公告的标题
private String newsName; private String newsName;
/** /**
* *
*/ */
// 存储公告相关图片的路径或标识
private String newsPhoto; private String newsPhoto;
/** /**
* *
*/ */
// 用整数表示公告的类型,不同的数值可能代表不同的公告分类
private Integer newsTypes; private Integer newsTypes;
/** /**
* *
*/ */
// 设置JSON序列化时日期的格式使用中文环境时区为东八区格式为 "yyyy-MM-dd HH:mm:ss"
@JsonFormat(locale="zh", timezone="GMT+8", pattern="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 Date insertTime;
/** /**
* *
*/ */
// 存储公告的详细内容,如具体的通知信息等
private String newsContent; private String newsContent;
/** /**
* show1 show2 nameShow * show1 show2 nameShow
*/ */
// 设置JSON序列化时日期的格式使用中文环境时区为东八区格式为 "yyyy-MM-dd HH:mm:ss"
@JsonFormat(locale="zh", timezone="GMT+8", pattern="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; private Date createTime;
/** /**
* *
*/ */
// 获取主键ID的公共方法供外部调用获取公告的唯一标识
public Integer getId() { public Integer getId() {
return id; return id;
} }
/** /**
* *
*/ */
// 设置主键ID的公共方法供外部调用设置公告的唯一标识
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
/** /**
* *
*/ */
// 获取公告名称的公共方法,供外部调用获取公告的标题
public String getNewsName() { public String getNewsName() {
return newsName; return newsName;
} }
/** /**
* *
*/ */
// 设置公告名称的公共方法,供外部调用修改公告的标题
public void setNewsName(String newsName) { public void setNewsName(String newsName) {
this.newsName = newsName; this.newsName = newsName;
} }
/** /**
* *
*/ */
// 获取公告图片路径或标识的公共方法,供外部调用获取公告的图片信息
public String getNewsPhoto() { public String getNewsPhoto() {
return newsPhoto; return newsPhoto;
} }
/** /**
* *
*/ */
// 设置公告图片路径或标识的公共方法,供外部调用修改公告的图片信息
public void setNewsPhoto(String newsPhoto) { public void setNewsPhoto(String newsPhoto) {
this.newsPhoto = newsPhoto; this.newsPhoto = newsPhoto;
} }
/** /**
* *
*/ */
// 获取公告类型的公共方法,供外部调用获取公告的分类信息
public Integer getNewsTypes() { public Integer getNewsTypes() {
return newsTypes; return newsTypes;
} }
/** /**
* *
*/ */
// 设置公告类型的公共方法,供外部调用修改公告的分类信息
public void setNewsTypes(Integer newsTypes) { public void setNewsTypes(Integer newsTypes) {
this.newsTypes = newsTypes; this.newsTypes = newsTypes;
} }
/** /**
* *
*/ */
// 获取公告发布时间的公共方法,供外部调用获取公告的发布时间
public Date getInsertTime() { public Date getInsertTime() {
return insertTime; return insertTime;
} }
/** /**
* *
*/ */
// 设置公告发布时间的公共方法,供外部调用修改公告的发布时间
public void setInsertTime(Date insertTime) { public void setInsertTime(Date insertTime) {
this.insertTime = insertTime; this.insertTime = insertTime;
} }
/** /**
* *
*/ */
// 获取公告详细内容的公共方法,供外部调用获取公告的具体信息
public String getNewsContent() { public String getNewsContent() {
return newsContent; return newsContent;
} }
/** /**
* *
*/ */
// 设置公告详细内容的公共方法,供外部调用修改公告的具体信息
public void setNewsContent(String newsContent) { public void setNewsContent(String newsContent) {
this.newsContent = newsContent; this.newsContent = newsContent;
} }
/** /**
* show1 show2 nameShow * show1 show2 nameShow
*/ */
// 获取公告创建时间的公共方法,供外部调用获取公告在系统中的创建时间
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
/** /**
* show1 show2 nameShow * show1 show2 nameShow
*/ */
// 设置公告创建时间的公共方法,供外部调用修改公告在系统中的创建时间
public void setCreateTime(Date createTime) { public void setCreateTime(Date createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
}
}

@ -15,7 +15,10 @@ import java.io.Serializable;
* ModelAndView model * ModelAndView model
*/ */
public class YishengModel implements Serializable { public class YishengModel implements Serializable {
private static final long serialVersionUID = 1L; // 序列化版本UID用于版本控制 private static final long serialVersionUID = 1L;
/** /**
* *
@ -97,245 +100,215 @@ public class YishengModel implements Serializable {
* 使@JsonFormat@DateTimeFormat * 使@JsonFormat@DateTimeFormat
*/ */
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@DateTimeFormat @DateTimeFormat
private Date createTime; private Date createTime;
/** /**
* ID *
* @return ID */
*/
public Integer getId() { public Integer getId() {
return id; return id;
} }
/** /**
* ID *
* @param id ID */
*/
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
/** /**
* *
* @return */
*/
public String getYishengUuidNumber() { public String getYishengUuidNumber() {
return yishengUuidNumber; return yishengUuidNumber;
} }
/** /**
* *
* @param yishengUuidNumber */
*/
public void setYishengUuidNumber(String yishengUuidNumber) { public void setYishengUuidNumber(String yishengUuidNumber) {
this.yishengUuidNumber = yishengUuidNumber; this.yishengUuidNumber = yishengUuidNumber;
} }
/** /**
* *
* @return */
*/
public String getUsername() { public String getUsername() {
return username; return username;
} }
/** /**
* *
* @param username */
*/
public void setUsername(String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
/** /**
* *
* @return */
*/
public String getPassword() { public String getPassword() {
return password; return password;
} }
/** /**
* *
* @param password */
*/
public void setPassword(String password) { public void setPassword(String password) {
this.password = password; this.password = password;
} }
/** /**
* *
* @return */
*/
public String getYishengName() { public String getYishengName() {
return yishengName; return yishengName;
} }
/** /**
* *
* @param yishengName */
*/
public void setYishengName(String yishengName) { public void setYishengName(String yishengName) {
this.yishengName = yishengName; this.yishengName = yishengName;
} }
/** /**
* *
* @return */
*/
public Integer getYishengTypes() { public Integer getYishengTypes() {
return yishengTypes; return yishengTypes;
} }
/** /**
* *
* @param yishengTypes */
*/
public void setYishengTypes(Integer yishengTypes) { public void setYishengTypes(Integer yishengTypes) {
this.yishengTypes = yishengTypes; this.yishengTypes = yishengTypes;
} }
/** /**
* *
* @return */
*/
public Integer getZhiweiTypes() { public Integer getZhiweiTypes() {
return zhiweiTypes; return zhiweiTypes;
} }
/** /**
* *
* @param zhiweiTypes */
*/
public void setZhiweiTypes(Integer zhiweiTypes) { public void setZhiweiTypes(Integer zhiweiTypes) {
this.zhiweiTypes = zhiweiTypes; this.zhiweiTypes = zhiweiTypes;
} }
/** /**
* *
* @return */
*/
public String getYishengZhichneg() { public String getYishengZhichneg() {
return yishengZhichneg; return yishengZhichneg;
} }
/** /**
* *
* @param yishengZhichneg */
*/
public void setYishengZhichneg(String yishengZhichneg) { public void setYishengZhichneg(String yishengZhichneg) {
this.yishengZhichneg = yishengZhichneg; this.yishengZhichneg = yishengZhichneg;
} }
/** /**
* *
* @return */
*/
public String getYishengPhoto() { public String getYishengPhoto() {
return yishengPhoto; return yishengPhoto;
} }
/** /**
* *
* @param yishengPhoto */
*/
public void setYishengPhoto(String yishengPhoto) { public void setYishengPhoto(String yishengPhoto) {
this.yishengPhoto = yishengPhoto; this.yishengPhoto = yishengPhoto;
} }
/** /**
* *
* @return */
*/
public String getYishengPhone() { public String getYishengPhone() {
return yishengPhone; return yishengPhone;
} }
/** /**
* *
* @param yishengPhone */
*/
public void setYishengPhone(String yishengPhone) { public void setYishengPhone(String yishengPhone) {
this.yishengPhone = yishengPhone; this.yishengPhone = yishengPhone;
} }
/** /**
* *
* @return */
*/
public String getYishengGuahao() { public String getYishengGuahao() {
return yishengGuahao; return yishengGuahao;
} }
/** /**
* *
* @param yishengGuahao */
*/
public void setYishengGuahao(String yishengGuahao) { public void setYishengGuahao(String yishengGuahao) {
this.yishengGuahao = yishengGuahao; this.yishengGuahao = yishengGuahao;
} }
/** /**
* *
* @return */
*/
public String getYishengEmail() { public String getYishengEmail() {
return yishengEmail; return yishengEmail;
} }
/** /**
* *
* @param yishengEmail */
*/
public void setYishengEmail(String yishengEmail) { public void setYishengEmail(String yishengEmail) {
this.yishengEmail = yishengEmail; this.yishengEmail = yishengEmail;
} }
/** /**
* *
* @return */
*/
public Double getYishengNewMoney() { public Double getYishengNewMoney() {
return yishengNewMoney; return yishengNewMoney;
} }
/** /**
* *
* @param yishengNewMoney */
*/
public void setYishengNewMoney(Double yishengNewMoney) { public void setYishengNewMoney(Double yishengNewMoney) {
this.yishengNewMoney = yishengNewMoney; this.yishengNewMoney = yishengNewMoney;
} }
/** /**
* *
* @return */
*/
public String getYishengContent() { public String getYishengContent() {
return yishengContent; return yishengContent;
} }
/** /**
* *
* @param yishengContent */
*/
public void setYishengContent(String yishengContent) { public void setYishengContent(String yishengContent) {
this.yishengContent = yishengContent; this.yishengContent = yishengContent;
} }
/** /**
* * show1 show2 photoShow
* @return */
*/
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
/** /**
* * show1 show2 photoShow
* @param createTime */
*/
public void setCreateTime(Date createTime) { public void setCreateTime(Date createTime) {
this.createTime = createTime; this.createTime = createTime;
} }

@ -1,14 +1,10 @@
package com.entity.model; package com.entity.model;
// 导入用户实体类
import com.entity.YonghuEntity; import com.entity.YonghuEntity;
// 导入MyBatis-Plus的表名注解
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
// 导入Jackson的日期格式化注解
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date; import java.util.Date;
// 导入Spring的日期格式化注解
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
@ -20,7 +16,6 @@ import java.io.Serializable;
* ModelAndView model * ModelAndView model
*/ */
public class YonghuModel implements Serializable { public class YonghuModel implements Serializable {
// 序列化版本号,用于保证序列化和反序列化的兼容性
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
@ -82,176 +77,174 @@ public class YonghuModel implements Serializable {
/** /**
* *
*/ */
// 用于JSON序列化时将日期格式化为指定的格式这里指定为中国时区格式为yyyy-MM-dd HH:mm:ss
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
// 用于Spring MVC接收表单数据时将字符串类型的日期转换为Date类型 @DateTimeFormat
@DateTimeFormat
private Date createTime; private Date createTime;
/** /**
* *
*/ */
public Integer getId() { public Integer getId() {
return id; return id;
} }
/** /**
* *
*/ */
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
/** /**
* *
*/ */
public String getUsername() { public String getUsername() {
return username; return username;
} }
/** /**
* *
*/ */
public void setUsername(String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
/** /**
* *
*/ */
public String getPassword() { public String getPassword() {
return password; return password;
} }
/** /**
* *
*/ */
public void setPassword(String password) { public void setPassword(String password) {
this.password = password; this.password = password;
} }
/** /**
* *
*/ */
public String getYonghuName() { public String getYonghuName() {
return yonghuName; return yonghuName;
} }
/** /**
* *
*/ */
public void setYonghuName(String yonghuName) { public void setYonghuName(String yonghuName) {
this.yonghuName = yonghuName; this.yonghuName = yonghuName;
} }
/** /**
* *
*/ */
public String getYonghuPhoto() { public String getYonghuPhoto() {
return yonghuPhoto; return yonghuPhoto;
} }
/** /**
* *
*/ */
public void setYonghuPhoto(String yonghuPhoto) { public void setYonghuPhoto(String yonghuPhoto) {
this.yonghuPhoto = yonghuPhoto; this.yonghuPhoto = yonghuPhoto;
} }
/** /**
* *
*/ */
public String getYonghuPhone() { public String getYonghuPhone() {
return yonghuPhone; return yonghuPhone;
} }
/** /**
* *
*/ */
public void setYonghuPhone(String yonghuPhone) { public void setYonghuPhone(String yonghuPhone) {
this.yonghuPhone = yonghuPhone; this.yonghuPhone = yonghuPhone;
} }
/** /**
* *
*/ */
public String getYonghuIdNumber() { public String getYonghuIdNumber() {
return yonghuIdNumber; return yonghuIdNumber;
} }
/** /**
* *
*/ */
public void setYonghuIdNumber(String yonghuIdNumber) { public void setYonghuIdNumber(String yonghuIdNumber) {
this.yonghuIdNumber = yonghuIdNumber; this.yonghuIdNumber = yonghuIdNumber;
} }
/** /**
* *
*/ */
public String getYonghuEmail() { public String getYonghuEmail() {
return yonghuEmail; return yonghuEmail;
} }
/** /**
* *
*/ */
public void setYonghuEmail(String yonghuEmail) { public void setYonghuEmail(String yonghuEmail) {
this.yonghuEmail = yonghuEmail; this.yonghuEmail = yonghuEmail;
} }
/** /**
* *
*/ */
public Integer getSexTypes() { public Integer getSexTypes() {
return sexTypes; return sexTypes;
} }
/** /**
* *
*/ */
public void setSexTypes(Integer sexTypes) { public void setSexTypes(Integer sexTypes) {
this.sexTypes = sexTypes; this.sexTypes = sexTypes;
} }
/** /**
* *
*/ */
public Double getNewMoney() { public Double getNewMoney() {
return newMoney; return newMoney;
} }
/** /**
* *
*/ */
public void setNewMoney(Double newMoney) { public void setNewMoney(Double newMoney) {
this.newMoney = newMoney; this.newMoney = newMoney;
} }
/** /**
* *
*/ */
public Integer getYonghuDelete() { public Integer getYonghuDelete() {
return yonghuDelete; return yonghuDelete;
} }
/** /**
* *
*/ */
public void setYonghuDelete(Integer yonghuDelete) { public void setYonghuDelete(Integer yonghuDelete) {
this.yonghuDelete = yonghuDelete; this.yonghuDelete = yonghuDelete;
} }
/** /**
* *
*/ */
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
/** /**
* *
*/ */
public void setCreateTime(Date createTime) { public void setCreateTime(Date createTime) {
this.createTime = createTime; this.createTime = createTime;
} }

@ -14,191 +14,226 @@ import java.util.Date;
* *
* 使 * 使
*/ */
// 使用TableName注解指定该类对应的数据库表名为 "chat"
@TableName("chat") @TableName("chat")
// ChatView类继承自ChatEntity类并实现了Serializable接口以便对象可以被序列化和反序列化
public class ChatView extends ChatEntity implements Serializable { public class ChatView extends ChatEntity implements Serializable {
private static final long serialVersionUID = 1L; // 序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性
private static final long serialVersionUID = 1L;
/**
* /**
*/ *
private String zhuangtaiValue; */
/** // 用于存储在线咨询相关的状态值,可能表示咨询的状态(如进行中、已结束等)
* private String zhuangtaiValue;
*/
private String chatValue; /**
*
*/
// 用于存储在线咨询的数据类型相关的值,具体含义可能根据业务需求而定
//级联表 yonghu private String chatValue;
/**
* // 级联表 yonghu
*/ /**
private String yonghuName; *
/** */
* // 存储与在线咨询相关联的用户的姓名信息
*/ private String yonghuName;
private String yonghuPhoto;
/** /**
* *
*/ */
private String yonghuPhone; // 存储与在线咨询相关联的用户的头像路径或标识
/** private String yonghuPhoto;
*
*/ /**
private String yonghuIdNumber; *
/** */
* // 存储与在线咨询相关联的用户的手机号码,用于联系用户
*/ private String yonghuPhone;
private String yonghuEmail;
/** /**
* *
*/ */
private Double newMoney; // 存储与在线咨询相关联的用户的身份证号码,用于身份验证等业务
/** private String yonghuIdNumber;
*
*/ /**
private Integer yonghuDelete; *
*/
// 存储与在线咨询相关联的用户的电子邮箱地址,可用于发送通知等
private String yonghuEmail;
/**
*
*/
// 存储与在线咨询相关联的用户的账户余额,可能与咨询费用等相关
private Double newMoney;
/**
*
*/
// 用于标识与在线咨询相关联的用户记录是否被逻辑删除假删0表示未删除1表示已删除
private Integer yonghuDelete;
// 无参构造函数用于创建ChatView对象
public ChatView() { public ChatView() {
} }
// 构造函数接受一个ChatEntity对象作为参数通过BeanUtils.copyProperties方法
// 将ChatEntity对象的属性值复制到当前ChatView对象中
public ChatView(ChatEntity chatEntity) { public ChatView(ChatEntity chatEntity) {
try { try {
BeanUtils.copyProperties(this, chatEntity); BeanUtils.copyProperties(this, chatEntity);
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
// TODO Auto-generated catch block // 如果在复制属性过程中出现异常,打印异常堆栈信息
e.printStackTrace(); 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() { // 获取用户身份证号的方法外部可以通过调用该方法获取yonghuIdNumber属性的值
return zhuangtaiValue; public String getYonghuIdNumber() {
} return yonghuIdNumber;
/** }
*
*/ /**
public void setZhuangtaiValue(String zhuangtaiValue) { *
this.zhuangtaiValue = zhuangtaiValue; */
} // 设置用户身份证号的方法外部可以通过调用该方法设置yonghuIdNumber属性的值
/** public void setYonghuIdNumber(String yonghuIdNumber) {
* this.yonghuIdNumber = yonghuIdNumber;
*/ }
public String getChatValue() {
return chatValue; /**
} *
/** */
* // 获取用户邮箱的方法外部可以通过调用该方法获取yonghuEmail属性的值
*/ public String getYonghuEmail() {
public void setChatValue(String chatValue) { return yonghuEmail;
this.chatValue = chatValue; }
}
/**
*
*/
// 设置用户邮箱的方法外部可以通过调用该方法设置yonghuEmail属性的值
public void setYonghuEmail(String yonghuEmail) {
this.yonghuEmail = yonghuEmail;
}
/**
*
*/
// 获取用户余额的方法外部可以通过调用该方法获取newMoney属性的值
public Double getNewMoney() {
return newMoney;
}
//级联表的get和set yonghu /**
/** *
* */
*/ // 设置用户余额的方法外部可以通过调用该方法设置newMoney属性的值
public String getYonghuName() { public void setNewMoney(Double newMoney) {
return yonghuName; this.newMoney = newMoney;
} }
/**
* /**
*/ *
public void setYonghuName(String yonghuName) { */
this.yonghuName = yonghuName; // 获取用户假删状态的方法外部可以通过调用该方法获取yonghuDelete属性的值
} public Integer getYonghuDelete() {
/** return yonghuDelete;
* }
*/
public String getYonghuPhoto() { /**
return yonghuPhoto; *
} */
/** // 设置用户假删状态的方法外部可以通过调用该方法设置yonghuDelete属性的值
* public void setYonghuDelete(Integer yonghuDelete) {
*/ this.yonghuDelete = yonghuDelete;
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;
}
}

@ -14,44 +14,29 @@ import java.util.Date;
* *
* 使 * 使
*/ */
// 使用TableName注解指定该类对应的数据库表名为 "dictionary"
@TableName("dictionary") @TableName("dictionary")
// DictionaryView类继承自DictionaryEntity类并实现了Serializable接口
// 使得该类的对象可以被序列化和反序列化,方便在网络传输或存储中使用
public class DictionaryView extends DictionaryEntity implements Serializable { public class DictionaryView extends DictionaryEntity implements Serializable {
private static final long serialVersionUID = 1L; // 序列化版本号,用于确保在不同版本的类之间进行序列化和反序列化时的兼容性
private static final long serialVersionUID = 1L;
// 无参构造函数用于创建DictionaryView对象在不需要初始化特定属性时使用
public DictionaryView() { public DictionaryView() {
} }
// 构造函数接受一个DictionaryEntity对象作为参数
// 通过BeanUtils.copyProperties方法将DictionaryEntity对象的属性值复制到当前DictionaryView对象中
// 这样可以方便地从Entity对象转换为View对象减少手动赋值的工作量
public DictionaryView(DictionaryEntity dictionaryEntity) { public DictionaryView(DictionaryEntity dictionaryEntity) {
try { try {
BeanUtils.copyProperties(this, dictionaryEntity); BeanUtils.copyProperties(this, dictionaryEntity);
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
// TODO Auto-generated catch block // 如果在复制属性过程中发生异常(例如属性访问权限问题或反射调用目标方法失败)
// 打印异常堆栈信息,以便开发人员调试和定位问题
e.printStackTrace(); e.printStackTrace();
} }
} }
}
}

@ -14,430 +14,499 @@ import java.util.Date;
* *
* 使 * 使
*/ */
// 使用TableName注解指定该类对应的数据库表名为 "guahao"
@TableName("guahao") @TableName("guahao")
// GuahaoView类继承自GuahaoEntity类并实现了Serializable接口
// 使得该类的对象可以被序列化和反序列化,便于在网络传输或存储中使用
public class GuahaoView extends GuahaoEntity implements Serializable { public class GuahaoView extends GuahaoEntity implements Serializable {
private static final long serialVersionUID = 1L; // 序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性
private static final long serialVersionUID = 1L;
/**
* /**
*/ *
private String guahaoValue; */
/** // 用于存储挂号相关的时间类型的值,可能表示不同的挂号时间分类等
* private String guahaoValue;
*/
private String guahaoStatusValue; /**
/** *
* */
*/ // 用于存储挂号状态的具体值,例如已挂号、已取消、已就诊等状态的描述
private String guahaoYesnoValue; private String guahaoStatusValue;
/**
*
//级联表 yisheng */
/** // 用于存储挂号审核结果的具体值,例如审核通过、审核不通过等描述
* private String guahaoYesnoValue;
*/
private String yishengUuidNumber; // 级联表 yisheng
/** /**
* *
*/ */
private String yishengName; // 存储与该挂号记录关联的医生的工号,用于唯一标识医生
/** private String yishengUuidNumber;
*
*/ /**
private Integer yishengTypes; *
/** */
* // 存储与该挂号记录关联的医生的姓名
*/ private String yishengName;
private String yishengValue;
/** /**
* *
*/ */
private Integer zhiweiTypes; // 用整数表示与该挂号记录关联的医生所属的科室
/** private Integer yishengTypes;
*
*/ /**
private String zhiweiValue; *
/** */
* // 存储科室的具体描述值可能是科室的名称等与yishengTypes配合使用
*/ private String yishengValue;
private String yishengZhichneg;
/** /**
* *
*/ */
private String yishengPhoto; // 用整数表示与该挂号记录关联的医生的职位
/** private Integer zhiweiTypes;
*
*/ /**
private String yishengPhone; *
/** */
* // 存储职位的具体描述值可能是职位的名称等与zhiweiTypes配合使用
*/ private String zhiweiValue;
private String yishengGuahao;
/** /**
* *
*/ */
private String yishengEmail; // 存储与该挂号记录关联的医生的职称信息
/** private String yishengZhichneg;
*
*/ /**
private Double yishengNewMoney; *
/** */
* // 存储与该挂号记录关联的医生的头像路径或标识
*/ private String yishengPhoto;
private String yishengContent;
/**
//级联表 yonghu *
/** */
* // 存储与该挂号记录关联的医生的联系电话或其他联系方式
*/ private String yishengPhone;
private String yonghuName;
/** /**
* *
*/ */
private String yonghuPhoto; // 存储与该医生相关的挂号注意事项和规定等信息
/** private String yishengGuahao;
*
*/ /**
private String yonghuPhone; *
/** */
* // 存储与该挂号记录关联的医生的电子邮箱地址
*/ private String yishengEmail;
private String yonghuIdNumber;
/** /**
* *
*/ */
private String yonghuEmail; // 存储该医生的挂号费用金额以Double类型表示
/** private Double yishengNewMoney;
*
*/ /**
private Double newMoney; *
/** */
* // 存储与该挂号记录关联的医生的个人履历和专业介绍等信息
*/ private String yishengContent;
private Integer yonghuDelete;
// 级联表 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() { public GuahaoView() {
} }
// 构造函数接受一个GuahaoEntity对象作为参数
// 通过BeanUtils.copyProperties方法将GuahaoEntity对象的属性值复制到当前GuahaoView对象中
public GuahaoView(GuahaoEntity guahaoEntity) { public GuahaoView(GuahaoEntity guahaoEntity) {
try { try {
BeanUtils.copyProperties(this, guahaoEntity); BeanUtils.copyProperties(this, guahaoEntity);
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
// TODO Auto-generated catch block // 如果在复制属性过程中出现异常,打印异常堆栈信息
e.printStackTrace(); 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() { // 获取挂号须知信息的方法外部可以通过调用该方法获取yishengGuahao属性的值
return guahaoValue; public String getYishengGuahao() {
} return yishengGuahao;
/** }
*
*/ /**
public void setGuahaoValue(String guahaoValue) { *
this.guahaoValue = guahaoValue; */
} // 设置挂号须知信息的方法外部可以通过调用该方法设置yishengGuahao属性的值
/** public void setYishengGuahao(String yishengGuahao) {
* this.yishengGuahao = yishengGuahao;
*/ }
public String getGuahaoStatusValue() {
return guahaoStatusValue; /**
} *
/** */
* // 获取医生邮箱地址的方法外部可以通过调用该方法获取yishengEmail属性的值
*/ public String getYishengEmail() {
public void setGuahaoStatusValue(String guahaoStatusValue) { return yishengEmail;
this.guahaoStatusValue = guahaoStatusValue; }
}
/** /**
* *
*/ */
public String getGuahaoYesnoValue() { // 设置医生邮箱地址的方法外部可以通过调用该方法设置yishengEmail属性的值
return guahaoYesnoValue; public void setYishengEmail(String yishengEmail) {
} this.yishengEmail = yishengEmail;
/** }
*
*/ /**
public void setGuahaoYesnoValue(String guahaoYesnoValue) { *
this.guahaoYesnoValue = guahaoYesnoValue; */
} // 获取挂号价格信息的方法外部可以通过调用该方法获取yishengNewMoney属性的值
public Double getYishengNewMoney() {
return yishengNewMoney;
}
/**
*
*/
// 设置挂号价格信息的方法外部可以通过调用该方法设置yishengNewMoney属性的值
public void setYishengNewMoney(Double yishengNewMoney) {
this.yishengNewMoney = yishengNewMoney;
}
/**
*
*/
// 获取医生履历介绍信息的方法外部可以通过调用该方法获取yishengContent属性的值
public String getYishengContent() {
return yishengContent;
}
//级联表的get和set yisheng
/** /**
* *
*/ */
public String getYishengUuidNumber() { // 设置医生履历介绍信息的方法外部可以通过调用该方法设置yishengContent属性的值
return yishengUuidNumber; public void setYishengContent(String yishengContent) {
} this.yishengContent = yishengContent;
/** }
*
*/ // 级联表的get和set yonghu
public void setYishengUuidNumber(String yishengUuidNumber) { /**
this.yishengUuidNumber = yishengUuidNumber; *
} */
/** // 获取用户姓名的方法外部可以通过调用该方法获取yonghuName属性的值
* public String getYonghuName() {
*/ return yonghuName;
public String getYishengName() { }
return yishengName;
} /**
/** *
* */
*/ // 设置用户姓名的方法外部可以通过调用该方法设置yonghuName属性的值
public void setYishengName(String yishengName) { public void setYonghuName(String yonghuName) {
this.yishengName = yishengName; this.yonghuName = yonghuName;
} }
/**
* /**
*/ *
public Integer getYishengTypes() { */
return yishengTypes; // 获取用户头像路径或标识的方法外部可以通过调用该方法获取yonghuPhoto属性的值
} public String getYonghuPhoto() {
/** return yonghuPhoto;
* }
*/
public void setYishengTypes(Integer yishengTypes) { /**
this.yishengTypes = yishengTypes; *
} */
// 设置用户头像路径或标识的方法外部可以通过调用该方法设置yonghuPhoto属性的值
public void setYonghuPhoto(String yonghuPhoto) {
/** this.yonghuPhoto = yonghuPhoto;
* }
*/
public String getYishengValue() { /**
return yishengValue; *
} */
/** // 获取用户手机号的方法外部可以通过调用该方法获取yonghuPhone属性的值
* public String getYonghuPhone() {
*/ return yonghuPhone;
public void setYishengValue(String yishengValue) { }
this.yishengValue = yishengValue;
} /**
/** *
* */
*/ // 设置用户手机号的方法外部可以通过调用该方法设置yonghuPhone属性的值
public Integer getZhiweiTypes() { public void setYonghuPhone(String yonghuPhone) {
return zhiweiTypes; this.yonghuPhone = yonghuPhone;
} }
/**
* /**
*/ *
public void setZhiweiTypes(Integer zhiweiTypes) { */
this.zhiweiTypes = zhiweiTypes; // 获取用户身份证号的方法外部可以通过调用该方法获取yonghuIdNumber属性的值
} public String getYonghuIdNumber() {
return yonghuIdNumber;
}
/**
* /**
*/ *
public String getZhiweiValue() { */
return zhiweiValue; // 设置用户身份证号的方法外部可以通过调用该方法设置yonghuIdNumber属性的值
} public void setYonghuIdNumber(String yonghuIdNumber) {
/** this.yonghuIdNumber = yonghuIdNumber;
* }
*/
public void setZhiweiValue(String zhiweiValue) { /**
this.zhiweiValue = zhiweiValue; *
} */
/** // 获取用户邮箱地址的方法外部可以通过调用该方法获取yonghuEmail属性的值
* public String getYonghuEmail() {
*/ return yonghuEmail;
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;
}
}

@ -14,52 +14,51 @@ import java.util.Date;
* *
* 使 * 使
*/ */
// 使用TableName注解指定该类对应的数据库表名为 "jiankangjiaoyu"
@TableName("jiankangjiaoyu") @TableName("jiankangjiaoyu")
// JiankangjiaoyuView类继承自JiankangjiaoyuEntity类并实现了Serializable接口
// 使得该类的对象可以被序列化和反序列化,方便在网络传输或存储中使用
public class JiankangjiaoyuView extends JiankangjiaoyuEntity implements Serializable { public class JiankangjiaoyuView extends JiankangjiaoyuEntity implements Serializable {
private static final long serialVersionUID = 1L; // 序列化版本号,用于保证在不同版本的类之间进行序列化和反序列化时的兼容性
private static final long serialVersionUID = 1L;
/**
*
*/
private String jiankangjiaoyuValue;
/**
*
*/
// 用于存储健康教育相关的类型值,可能表示不同的健康教育分类,如疾病预防、健康生活方式等
private String jiankangjiaoyuValue;
// 无参构造函数用于创建JiankangjiaoyuView对象在不需要初始化特定属性时使用
public JiankangjiaoyuView() { public JiankangjiaoyuView() {
} }
// 构造函数接受一个JiankangjiaoyuEntity对象作为参数
// 通过BeanUtils.copyProperties方法将JiankangjiaoyuEntity对象的属性值复制到当前JiankangjiaoyuView对象中
// 这样可以方便地从Entity对象转换为View对象减少手动赋值的工作量
public JiankangjiaoyuView(JiankangjiaoyuEntity jiankangjiaoyuEntity) { public JiankangjiaoyuView(JiankangjiaoyuEntity jiankangjiaoyuEntity) {
try { try {
BeanUtils.copyProperties(this, jiankangjiaoyuEntity); BeanUtils.copyProperties(this, jiankangjiaoyuEntity);
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
// TODO Auto-generated catch block // 如果在复制属性过程中发生异常(例如属性访问权限问题或反射调用目标方法失败),
// 打印异常堆栈信息,以便开发人员调试和定位问题
e.printStackTrace(); e.printStackTrace();
} }
} }
/**
*
*/
// 获取健康教育类型值的方法外部可以通过调用该方法获取jiankangjiaoyuValue属性的值
public String getJiankangjiaoyuValue() {
return jiankangjiaoyuValue;
}
/**
/** *
* */
*/ // 设置健康教育类型值的方法外部可以通过调用该方法设置jiankangjiaoyuValue属性的值
public String getJiankangjiaoyuValue() { public void setJiankangjiaoyuValue(String jiankangjiaoyuValue) {
return jiankangjiaoyuValue; this.jiankangjiaoyuValue = jiankangjiaoyuValue;
} }
/** }
*
*/
public void setJiankangjiaoyuValue(String jiankangjiaoyuValue) {
this.jiankangjiaoyuValue = jiankangjiaoyuValue;
}
}

@ -1,12 +1,20 @@
package com.entity.view; package com.entity.view;
// 导入公告信息实体类NewsView 会继承该类
import com.entity.NewsEntity; import com.entity.NewsEntity;
// 导入 MyBatis-Plus 用于指定数据库表名的注解
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
// 导入 Apache Commons BeanUtils 工具类,用于对象属性复制
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
// 导入反射调用可能抛出的异常类
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
// 导入 Spring 框架用于日期格式化的注解
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
// 导入 Jackson 用于 JSON 序列化时日期格式化的注解
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
// 导入序列化接口
import java.io.Serializable; import java.io.Serializable;
// 导入日期类
import java.util.Date; import java.util.Date;
/** /**
@ -14,52 +22,48 @@ import java.util.Date;
* *
* 使 * 使
*/ */
// 指定该类对应数据库中的 news 表
@TableName("news") @TableName("news")
// NewsView 类继承自 NewsEntity 类,并实现 Serializable 接口,可进行序列化操作
public class NewsView extends NewsEntity implements Serializable { public class NewsView extends NewsEntity implements Serializable {
private static final long serialVersionUID = 1L; // 序列化版本号,确保序列化和反序列化的兼容性
private static final long serialVersionUID = 1L;
/**
*
*/
private String newsValue;
/**
*
*/
// 存储公告类型的具体描述值,例如“紧急通知”“普通公告”等
private String newsValue;
// 无参构造函数,方便创建 NewsView 类的实例
public NewsView() { public NewsView() {
} }
// 带参构造函数,接收一个 NewsEntity 对象,将其属性复制到当前 NewsView 对象
public NewsView(NewsEntity newsEntity) { public NewsView(NewsEntity newsEntity) {
try { try {
// 使用 BeanUtils 工具类复制属性
BeanUtils.copyProperties(this, newsEntity); BeanUtils.copyProperties(this, newsEntity);
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
// TODO Auto-generated catch block // 若复制属性过程中出现异常,打印异常堆栈信息
e.printStackTrace(); e.printStackTrace();
} }
} }
/**
*
*/
// 获取公告类型值的方法
public String getNewsValue() {
return newsValue;
}
/**
/** *
* */
*/ // 设置公告类型值的方法
public String getNewsValue() { public void setNewsValue(String newsValue) {
return newsValue; this.newsValue = newsValue;
} }
/** }
*
*/
public void setNewsValue(String newsValue) {
this.newsValue = newsValue;
}
}

@ -29,19 +29,18 @@ public class AuthorizationInterceptor implements HandlerInterceptor {
public static final String LOGIN_TOKEN_KEY = "Token"; public static final String LOGIN_TOKEN_KEY = "Token";
@Autowired @Autowired
private TokenService tokenService; private TokenService tokenService; // 注入 TokenService
@Override
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String servletPath = request.getServletPath(); 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; 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-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Credentials", "true"); 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"); 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; return true;
} }
//从header中获取token // 从header中获取token
String token = request.getHeader(LOGIN_TOKEN_KEY); String token = request.getHeader(LOGIN_TOKEN_KEY);
/** /**
* *
*/ */
if(annotation!=null) { if (annotation != null) {
return true; return true;
} }
TokenEntity tokenEntity = null; TokenEntity tokenEntity = null;
if(StringUtils.isNotBlank(token)) { if (StringUtils.isNotBlank(token)) {
tokenEntity = tokenService.getTokenEntity(token); tokenEntity = tokenService.getTokenEntity(token);
} }
if(tokenEntity != null) { if (tokenEntity != null) {
request.getSession().setAttribute("userId", tokenEntity.getUserid()); request.getSession().setAttribute("userId", tokenEntity.getUserid());
request.getSession().setAttribute("role", tokenEntity.getRole()); request.getSession().setAttribute("role", tokenEntity.getRole());
request.getSession().setAttribute("tableName", tokenEntity.getTablename()); request.getSession().setAttribute("tableName", tokenEntity.getTablename());
request.getSession().setAttribute("username", tokenEntity.getUsername()); request.getSession().setAttribute("username", tokenEntity.getUsername());
return true; 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();
}
} }
// throw new EIException("请先登录", 401);
PrintWriter writer = null; return false;
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;
} }
} }

@ -1,31 +1,39 @@
package com.model.enums; package com.model.enums;
// 导入序列化接口,使枚举对象可以进行序列化和反序列化操作
import java.io.Serializable; import java.io.Serializable;
// 导入 MyBatis-Plus 的枚举接口,用于将枚举值映射到数据库字段
import com.baomidou.mybatisplus.enums.IEnum; import com.baomidou.mybatisplus.enums.IEnum;
/** /**
* IEnum spring-mybatis.xml typeEnumsPackage * IEnum spring-mybatis.xml typeEnumsPackage
*
*/ */
public enum TypeEnum implements IEnum { public enum TypeEnum implements IEnum {
// 定义枚举常量,分别表示禁用状态和正常状态
DISABLED(0, "禁用"), DISABLED(0, "禁用"),
NORMAL(1, "正常"); NORMAL(1, "正常");
// 用于存储枚举值对应的整数值,通常与数据库中的字段值对应
private final int value; private final int value;
// 用于存储枚举值对应的中文描述,方便在代码中使用和展示
private final String desc; private final String desc;
// 枚举类的构造函数,用于初始化枚举常量的 value 和 desc 属性
TypeEnum(final int value, final String desc) { TypeEnum(final int value, final String desc) {
this.value = value; this.value = value;
this.desc = desc; this.desc = desc;
} }
// 实现 IEnum 接口的方法,返回枚举值对应的整数值,用于与数据库字段进行映射
@Override @Override
public Serializable getValue() { public Serializable getValue() {
return this.value; return this.value;
} }
// Jackson 注解为 JsonValue 返回中文 json 描述 // 该方法用于获取枚举值的中文描述,使用 Jackson 注解时,可将该描述作为 JSON 序列化时的值
// 这样在进行 JSON 序列化时,会返回枚举值的中文描述而不是枚举名称
public String getDesc() { public String getDesc() {
return this.desc; return this.desc;
} }
} }

@ -1,74 +1,90 @@
/** /**
* 邮箱 * 验证输入的字符串是否为有效的邮箱地址
* @param {*} s * @param {*} s - 要验证的字符串预期为邮箱地址
* @returns {boolean} - 如果字符串是有效的邮箱地址返回 true否则返回 false当传入的 s null undefined 直接返回 true
*/ */
function isEmail(s) { function isEmail(s) {
if(s){ if (s) {
return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(s) // 使用正则表达式匹配邮箱地址的格式
return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(s);
} }
return true; return true;
} }
/** /**
* 手机号码 * 验证输入的字符串是否为有效的手机号码
* @param {*} s * @param {*} s - 要验证的字符串预期为手机号码
* @returns {boolean} - 如果字符串是有效的手机号码返回 true否则返回 false当传入的 s null undefined 直接返回 true
*/ */
function isMobile(s) { function isMobile(s) {
if(s){ if (s) {
return /^1[0-9]{10}$/.test(s) // 使用正则表达式匹配手机号码的格式(以 1 开头,后面跟着 10 位数字)
return /^1[0-9]{10}$/.test(s);
} }
return true; return true;
} }
/** /**
* 电话号码 * 验证输入的字符串是否为有效的电话号码
* @param {*} s * @param {*} s - 要验证的字符串预期为电话号码
* @returns {boolean} - 如果字符串是有效的电话号码返回 true否则返回 false当传入的 s null undefined 直接返回 true
*/ */
function isPhone(s) { function isPhone(s) {
if(s){ if (s) {
return /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(s) // 使用正则表达式匹配电话号码的格式(可以有 3 到 4 位区号,后面跟着 7 到 8 位号码,区号和号码之间用 - 分隔)
return /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(s);
} }
return true; return true;
} }
/** /**
* URL地址 * 验证输入的字符串是否为有效的 URL 地址
* @param {*} s * @param {*} s - 要验证的字符串预期为 URL 地址
* @returns {boolean} - 如果字符串是有效的 URL 地址返回 true否则返回 false当传入的 s null undefined 直接返回 true
*/ */
function isURL(s) { function isURL(s) {
if(s){ if (s) {
return /^http[s]?:\/\/.*/.test(s) // 使用正则表达式匹配 URL 地址的格式(以 http 或 https 开头)
return /^http[s]?:\/\/.*/.test(s);
} }
return true; return true;
} }
/** /**
* 匹配数字可以是小数不可以是负数,可以为空 * 验证输入的字符串是否为有效的数字可以是小数不能是负数可以为空
* @param {*} s * @param {*} s - 要验证的字符串预期为数字
* @returns {boolean} - 如果字符串是有效的数字符合指定格式返回 true否则返回 false当传入的 s null undefined 直接返回 true
*/ */
function isNumber(s) { function isNumber(s) {
if(s){ if (s) {
// 使用正则表达式匹配数字的格式,包括小数和科学计数法形式,不允许负数
return /(^-?[+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?[0-9]+)?$)|(^$)/.test(s); return /(^-?[+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?[0-9]+)?$)|(^$)/.test(s);
} }
return true; return true;
} }
/** /**
* 匹配整数可以为空 * 验证输入的字符串是否为有效的整数可以为空
* @param {*} s * @param {*} s - 要验证的字符串预期为整数
* @returns {boolean} - 如果字符串是有效的整数符合指定格式返回 true否则返回 false当传入的 s null undefined 直接返回 true
*/ */
function isIntNumer(s) { function isIntNumer(s) {
if(s){ if (s) {
// 使用正则表达式匹配整数的格式,包括正负整数和空字符串
return /(^-?\d+$)|(^$)/.test(s); return /(^-?\d+$)|(^$)/.test(s);
} }
return true; return true;
} }
/** /**
* 身份证校验 * 验证输入的字符串是否为有效的身份证号码
* @param {string} idcard - 要验证的字符串预期为身份证号码
* @returns {boolean} - 如果字符串是有效的身份证号码符合 15 18 位或 17 位加最后一位为 X x 的格式返回 true否则返回 false当传入的 idcard null undefined 直接返回 true
*/ */
function isIdentity(idcard) { function isIdentity(idcard) {
const regIdCard = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; const regIdCard = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
if(idcard){ if (idcard) {
return regIdCard.test(idcard); return regIdCard.test(idcard);
} }
return true; return true;
} }
Loading…
Cancel
Save