|
|
|
@ -1,5 +1,4 @@
|
|
|
|
|
|
|
|
|
|
ppackage com.controller;
|
|
|
|
|
package com.controller;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
@ -70,36 +69,37 @@ public class ChatController {
|
|
|
|
|
/**
|
|
|
|
|
* 后端列表
|
|
|
|
|
* 处理获取在线咨询后端列表数据的请求
|
|
|
|
|
* @param params 包含请求参数的 Map,如分页参数、排序参数等
|
|
|
|
|
*
|
|
|
|
|
* @param params 包含请求参数的 Map,如分页参数、排序参数等
|
|
|
|
|
* @param request HttpServletRequest 对象,包含请求的相关信息
|
|
|
|
|
* @return R 类型的响应对象,封装了请求处理的结果
|
|
|
|
|
*/
|
|
|
|
|
@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"));
|
|
|
|
|
// 这个条件永远为 false,这里的代码逻辑可能有误,正常不会进入此分支
|
|
|
|
|
if(false)
|
|
|
|
|
return R.error(511,"永不会进入");
|
|
|
|
|
if (false)
|
|
|
|
|
return R.error(511, "永不会进入");
|
|
|
|
|
// 如果用户角色是 "用户",则将用户 ID 添加到请求参数中
|
|
|
|
|
else if("用户".equals(role))
|
|
|
|
|
params.put("yonghuId",request.getSession().getAttribute("userId"));
|
|
|
|
|
else if ("用户".equals(role))
|
|
|
|
|
params.put("yonghuId", request.getSession().getAttribute("userId"));
|
|
|
|
|
// 如果用户角色是 "医生",则将医生 ID 添加到请求参数中
|
|
|
|
|
else if("医生".equals(role))
|
|
|
|
|
params.put("yishengId",request.getSession().getAttribute("userId"));
|
|
|
|
|
else if ("医生".equals(role))
|
|
|
|
|
params.put("yishengId", request.getSession().getAttribute("userId"));
|
|
|
|
|
// 如果请求参数中没有指定排序字段,则默认按 id 排序
|
|
|
|
|
if(params.get("orderBy")==null || params.get("orderBy")==""){
|
|
|
|
|
params.put("orderBy","id");
|
|
|
|
|
if (params.get("orderBy") == null || params.get("orderBy") == "") {
|
|
|
|
|
params.put("orderBy", "id");
|
|
|
|
|
}
|
|
|
|
|
// 调用 ChatService 的 queryPage 方法获取分页数据
|
|
|
|
|
PageUtils page = chatService.queryPage(params);
|
|
|
|
|
|
|
|
|
|
// 将分页数据中的列表转换为 ChatView 类型的列表
|
|
|
|
|
List<ChatView> list =(List<ChatView>)page.getList();
|
|
|
|
|
List<ChatView> list = (List<ChatView>) page.getList();
|
|
|
|
|
// 遍历列表,对每个 ChatView 对象进行字典表数据转换
|
|
|
|
|
for(ChatView c:list){
|
|
|
|
|
for (ChatView c : list) {
|
|
|
|
|
dictionaryService.dictionaryConvert(c, request);
|
|
|
|
|
}
|
|
|
|
|
// 返回成功响应,并将分页数据封装在 data 属性中
|
|
|
|
@ -109,28 +109,29 @@ public class ChatController {
|
|
|
|
|
/**
|
|
|
|
|
* 后端详情
|
|
|
|
|
* 处理获取在线咨询后端详情数据的请求
|
|
|
|
|
* @param id 要查询的在线咨询记录的 ID
|
|
|
|
|
*
|
|
|
|
|
* @param id 要查询的在线咨询记录的 ID
|
|
|
|
|
* @param request HttpServletRequest 对象,包含请求的相关信息
|
|
|
|
|
* @return R 类型的响应对象,封装了请求处理的结果
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/info/{id}")
|
|
|
|
|
public R info(@PathVariable("id") Long id, HttpServletRequest request){
|
|
|
|
|
public R info(@PathVariable("id") Long id, HttpServletRequest request) {
|
|
|
|
|
// 记录调试日志,输出方法名、控制器类名和要查询的 ID
|
|
|
|
|
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
|
|
|
|
|
logger.debug("info方法:,,Controller:{},,id:{}", this.getClass().getName(), id);
|
|
|
|
|
// 根据 ID 查询在线咨询记录
|
|
|
|
|
ChatEntity chat = chatService.selectById(id);
|
|
|
|
|
// 如果查询到记录
|
|
|
|
|
if(chat !=null){
|
|
|
|
|
if (chat != null) {
|
|
|
|
|
// 将 ChatEntity 转换为 ChatView
|
|
|
|
|
ChatView view = new ChatView();
|
|
|
|
|
// 使用 BeanUtils 将 ChatEntity 的属性复制到 ChatView 中
|
|
|
|
|
BeanUtils.copyProperties( chat , view );
|
|
|
|
|
BeanUtils.copyProperties(chat, view);
|
|
|
|
|
// 级联查询用户信息
|
|
|
|
|
YonghuEntity yonghu = yonghuService.selectById(chat.getYonghuId());
|
|
|
|
|
// 如果查询到用户信息
|
|
|
|
|
if(yonghu != null){
|
|
|
|
|
if (yonghu != null) {
|
|
|
|
|
// 将用户信息的部分属性复制到 ChatView 中,并排除指定字段
|
|
|
|
|
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});
|
|
|
|
|
BeanUtils.copyProperties(yonghu, view, new String[]{"id", "createTime", "insertTime", "updateTime"});
|
|
|
|
|
// 设置 ChatView 中的用户 ID
|
|
|
|
|
view.setYonghuId(yonghu.getId());
|
|
|
|
|
}
|
|
|
|
@ -139,9 +140,9 @@ public class ChatController {
|
|
|
|
|
dictionaryService.dictionaryConvert(view, request);
|
|
|
|
|
// 返回成功响应,并将处理后的 ChatView 数据封装在 data 属性中
|
|
|
|
|
return R.ok().put("data", view);
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
// 如果未查询到记录,返回错误响应
|
|
|
|
|
return R.error(511,"查不到数据");
|
|
|
|
|
return R.error(511, "查不到数据");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -149,22 +150,23 @@ public class ChatController {
|
|
|
|
|
/**
|
|
|
|
|
* 后端保存
|
|
|
|
|
* 处理保存在线咨询记录的请求
|
|
|
|
|
* @param chat 要保存的在线咨询实体对象
|
|
|
|
|
*
|
|
|
|
|
* @param chat 要保存的在线咨询实体对象
|
|
|
|
|
* @param request HttpServletRequest 对象,包含请求的相关信息
|
|
|
|
|
* @return R 类型的响应对象,封装了请求处理的结果
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/save")
|
|
|
|
|
public R save(@RequestBody ChatEntity chat, HttpServletRequest request){
|
|
|
|
|
public R save(@RequestBody ChatEntity chat, HttpServletRequest request) {
|
|
|
|
|
// 记录调试日志,输出方法名、控制器类名和要保存的 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"));
|
|
|
|
|
// 这个条件永远为 false,这里的代码逻辑可能有误,正常不会进入此分支
|
|
|
|
|
if(false)
|
|
|
|
|
return R.error(511,"永远不会进入");
|
|
|
|
|
if (false)
|
|
|
|
|
return R.error(511, "永远不会进入");
|
|
|
|
|
// 如果用户角色是 "用户",则设置在线咨询记录的用户 ID
|
|
|
|
|
else if("用户".equals(role))
|
|
|
|
|
else if ("用户".equals(role))
|
|
|
|
|
chat.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
|
|
|
|
|
|
|
|
|
|
// 创建查询条件,检查是否已存在相同数据
|
|
|
|
@ -173,38 +175,38 @@ public class ChatController {
|
|
|
|
|
.eq("chat_issue", chat.getChatIssue())
|
|
|
|
|
.eq("chat_reply", chat.getChatReply())
|
|
|
|
|
.eq("zhuangtai_types", chat.getZhuangtaiTypes())
|
|
|
|
|
.eq("chat_types", chat.getChatTypes())
|
|
|
|
|
;
|
|
|
|
|
.eq("chat_types", chat.getChatTypes());
|
|
|
|
|
|
|
|
|
|
// 记录查询条件的 SQL 片段日志
|
|
|
|
|
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
|
|
|
|
logger.info("sql语句:" + queryWrapper.getSqlSegment());
|
|
|
|
|
// 根据查询条件查询是否已存在相同数据
|
|
|
|
|
ChatEntity chatEntity = chatService.selectOne(queryWrapper);
|
|
|
|
|
// 如果不存在相同数据
|
|
|
|
|
if(chatEntity==null){
|
|
|
|
|
if (chatEntity == null) {
|
|
|
|
|
// 设置插入时间为当前时间
|
|
|
|
|
chat.setInsertTime(new Date());
|
|
|
|
|
// 插入在线咨询记录
|
|
|
|
|
chatService.insert(chat);
|
|
|
|
|
// 返回成功响应
|
|
|
|
|
return R.ok();
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
// 如果存在相同数据,返回错误响应
|
|
|
|
|
return R.error(511,"表中有相同数据");
|
|
|
|
|
return R.error(511, "表中有相同数据");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 后端修改
|
|
|
|
|
* 处理修改在线咨询记录的请求
|
|
|
|
|
* @param chat 要修改的在线咨询实体对象
|
|
|
|
|
*
|
|
|
|
|
* @param chat 要修改的在线咨询实体对象
|
|
|
|
|
* @param request HttpServletRequest 对象,包含请求的相关信息
|
|
|
|
|
* @return R 类型的响应对象,封装了请求处理的结果
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/update")
|
|
|
|
|
public R update(@RequestBody ChatEntity chat, HttpServletRequest request){
|
|
|
|
|
public R update(@RequestBody ChatEntity chat, HttpServletRequest request) {
|
|
|
|
|
// 记录调试日志,输出方法名、控制器类名和要修改的 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"));
|
|
|
|
@ -215,41 +217,41 @@ public class ChatController {
|
|
|
|
|
|
|
|
|
|
// 创建查询条件,检查是否已存在相同数据(排除当前要修改的记录)
|
|
|
|
|
Wrapper<ChatEntity> queryWrapper = new EntityWrapper<ChatEntity>()
|
|
|
|
|
.notIn("id",chat.getId())
|
|
|
|
|
.notIn("id", chat.getId())
|
|
|
|
|
.andNew()
|
|
|
|
|
.eq("yonghu_id", chat.getYonghuId())
|
|
|
|
|
.eq("chat_issue", chat.getChatIssue())
|
|
|
|
|
.eq("chat_reply", chat.getChatReply())
|
|
|
|
|
.eq("zhuangtai_types", chat.getZhuangtaiTypes())
|
|
|
|
|
.eq("chat_types", chat.getChatTypes())
|
|
|
|
|
;
|
|
|
|
|
.eq("chat_types", chat.getChatTypes());
|
|
|
|
|
|
|
|
|
|
// 记录查询条件的 SQL 片段日志
|
|
|
|
|
logger.info("sql语句:"+queryWrapper.getSqlSegment());
|
|
|
|
|
logger.info("sql语句:" + queryWrapper.getSqlSegment());
|
|
|
|
|
// 根据查询条件查询是否已存在相同数据
|
|
|
|
|
ChatEntity chatEntity = chatService.selectOne(queryWrapper);
|
|
|
|
|
// 如果不存在相同数据
|
|
|
|
|
if(chatEntity==null){
|
|
|
|
|
if (chatEntity == null) {
|
|
|
|
|
// 根据 ID 更新在线咨询记录
|
|
|
|
|
chatService.updateById(chat);
|
|
|
|
|
// 返回成功响应
|
|
|
|
|
return R.ok();
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
// 如果存在相同数据,返回错误响应
|
|
|
|
|
return R.error(511,"表中有相同数据");
|
|
|
|
|
return R.error(511, "表中有相同数据");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除
|
|
|
|
|
* 处理删除在线咨询记录的请求
|
|
|
|
|
*
|
|
|
|
|
* @param ids 要删除的在线咨询记录的 ID 数组
|
|
|
|
|
* @return R 类型的响应对象,封装了请求处理的结果
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/delete")
|
|
|
|
|
public R delete(@RequestBody Integer[] ids){
|
|
|
|
|
public R delete(@RequestBody Integer[] ids) {
|
|
|
|
|
// 记录调试日志,输出方法名、控制器类名和要删除的 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));
|
|
|
|
|
// 返回成功响应
|
|
|
|
@ -259,49 +261,50 @@ public class ChatController {
|
|
|
|
|
/**
|
|
|
|
|
* 批量上传
|
|
|
|
|
* 处理批量插入在线咨询记录的请求,从 Excel 文件中读取数据并插入
|
|
|
|
|
*
|
|
|
|
|
* @param fileName 上传的 Excel 文件的文件名
|
|
|
|
|
* @return R 类型的响应对象,封装了请求处理的结果
|
|
|
|
|
*/
|
|
|
|
|
@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 {
|
|
|
|
|
// 创建用于存储上传的在线咨询实体对象的列表
|
|
|
|
|
List<ChatEntity> chatList = new ArrayList<>();
|
|
|
|
|
// 创建用于存储要查询的字段的 Map
|
|
|
|
|
Map<String, List<String>> seachFields= new HashMap<>();
|
|
|
|
|
Map<String, List<String>> seachFields = new HashMap<>();
|
|
|
|
|
// 获取当前时间
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
// 获取文件名的后缀位置
|
|
|
|
|
int lastIndexOf = fileName.lastIndexOf(".");
|
|
|
|
|
// 如果没有找到后缀
|
|
|
|
|
if(lastIndexOf == -1){
|
|
|
|
|
if (lastIndexOf == -1) {
|
|
|
|
|
// 返回错误响应,提示文件没有后缀
|
|
|
|
|
return R.error(511,"该文件没有后缀");
|
|
|
|
|
}else{
|
|
|
|
|
return R.error(511, "该文件没有后缀");
|
|
|
|
|
} else {
|
|
|
|
|
// 获取文件后缀
|
|
|
|
|
String suffix = fileName.substring(lastIndexOf);
|
|
|
|
|
// 如果后缀不是.xls
|
|
|
|
|
if(!".xls".equals(suffix)){
|
|
|
|
|
if (!".xls".equals(suffix)) {
|
|
|
|
|
// 返回错误响应,提示只支持.xls 后缀的 Excel 文件
|
|
|
|
|
return R.error(511,"只支持后缀为xls的excel文件");
|
|
|
|
|
}else{
|
|
|
|
|
return R.error(511, "只支持后缀为xls的excel文件");
|
|
|
|
|
} else {
|
|
|
|
|
// 获取文件的 URL
|
|
|
|
|
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);
|
|
|
|
|
// 创建文件对象
|
|
|
|
|
File file = new File(resource.getFile());
|
|
|
|
|
// 如果文件不存在
|
|
|
|
|
if(!file.exists()){
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
// 返回错误响应,提示找不到上传文件
|
|
|
|
|
return R.error(511,"找不到上传文件,请联系管理员");
|
|
|
|
|
}else{
|
|
|
|
|
return R.error(511, "找不到上传文件,请联系管理员");
|
|
|
|
|
} else {
|
|
|
|
|
// 从 Excel 文件中读取数据
|
|
|
|
|
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());
|
|
|
|
|
// 删除第一行(通常是表头)
|
|
|
|
|
dataList.remove(0);
|
|
|
|
|
// 遍历数据列表
|
|
|
|
|
for(List<String> data:dataList){
|
|
|
|
|
for (List<String> data : dataList) {
|
|
|
|
|
// 创建在线咨询实体对象
|
|
|
|
|
ChatEntity chatEntity = new ChatEntity();
|
|
|
|
|
|
|
|
|
@ -317,34 +320,35 @@ 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 对象,包含请求的相关信息
|
|
|
|
|
* @return R 类型的响应对象,封装了请求处理的结果
|
|
|
|
|
*/
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@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 倒序排序
|
|
|
|
|
if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
|
|
|
|
|
params.put("orderBy","id");
|
|
|
|
|
if (StringUtil.isEmpty(String.valueOf(params.get("orderBy")))) {
|
|
|
|
|
params.put("orderBy", "id");
|
|
|
|
|
}
|
|
|
|
|
// 调用 ChatService 的 queryPage 方法获取分页数据
|
|
|
|
|
PageUtils page = chatService.queryPage(params);
|
|
|
|
|
// 将分页数据中的列表转换为 ChatView 类型的列表
|
|
|
|
|
List<ChatView> list =(List<ChatView>)page.getList();
|
|
|
|
|
List<ChatView> list = (List<ChatView>) page.getList();
|
|
|
|
|
// 遍历列表,对每个 ChatView 对象进行字典表数据转换
|
|
|
|
|
for(ChatView c:list)
|
|
|
|
|
for (ChatView c : list)
|
|
|
|
|
dictionaryService.dictionaryConvert(c, request);
|
|
|
|
|
// 返回成功响应,并将分页数据封装在 data 属性中
|
|
|
|
|
return R.ok().put("data", page);
|
|
|
|
@ -353,29 +357,30 @@ public class ChatController {
|
|
|
|
|
/**
|
|
|
|
|
* 前端详情
|
|
|
|
|
* 处理获取在线咨询前端详情数据的请求
|
|
|
|
|
* @param id 要查询的在线咨询记录的 ID
|
|
|
|
|
*
|
|
|
|
|
* @param id 要查询的在线咨询记录的 ID
|
|
|
|
|
* @param request HttpServletRequest 对象,包含请求的相关信息
|
|
|
|
|
* @return R 类型的响应对象,封装了请求处理的结果
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/detail/{id}")
|
|
|
|
|
public R detail(@PathVariable("id") Long id, HttpServletRequest request){
|
|
|
|
|
public R detail(@PathVariable("id") Long id, HttpServletRequest request) {
|
|
|
|
|
// 记录调试日志,输出方法名、控制器类名和要查询的 ID
|
|
|
|
|
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
|
|
|
|
|
logger.debug("detail方法:,,Controller:{},,id:{}", this.getClass().getName(), id);
|
|
|
|
|
// 根据 ID 查询在线咨询记录
|
|
|
|
|
ChatEntity chat = chatService.selectById(id);
|
|
|
|
|
// 如果查询到记录
|
|
|
|
|
if(chat !=null){
|
|
|
|
|
if (chat != null) {
|
|
|
|
|
// 将 ChatEntity 转换为 ChatView
|
|
|
|
|
ChatView view = new ChatView();
|
|
|
|
|
// 使用 BeanUtils 将 ChatEntity 的属性复制到 ChatView 中
|
|
|
|
|
BeanUtils.copyProperties( chat , view );
|
|
|
|
|
BeanUtils.copyProperties(chat, view);
|
|
|
|
|
|
|
|
|
|
// 级联查询用户信息
|
|
|
|
|
YonghuEntity yonghu = yonghuService.selectById(chat.getYonghuId());
|
|
|
|
|
// 如果查询到用户信息
|
|
|
|
|
if(yonghu != null){
|
|
|
|
|
if (yonghu != null) {
|
|
|
|
|
// 将用户信息的部分属性复制到 ChatView 中,并排除指定字段
|
|
|
|
|
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});
|
|
|
|
|
BeanUtils.copyProperties(yonghu, view, new String[]{"id", "createDate"});
|
|
|
|
|
// 设置 ChatView 中的用户 ID
|
|
|
|
|
view.setYonghuId(yonghu.getId());
|
|
|
|
|
}
|
|
|
|
@ -384,10 +389,10 @@ public class ChatController {
|
|
|
|
|
dictionaryService.dictionaryConvert(view, request);
|
|
|
|
|
// 返回成功响应,并将处理后的 ChatView 数据封装在 data 属性中
|
|
|
|
|
return R.ok().put("data", view);
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
// 如果未查询到记录,返回错误响应
|
|
|
|
|
return R.error(511,"查不到数据");
|
|
|
|
|
return R.error(511, "查不到数据");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|