From 52a528f118547dda939a4acd89b8616cba8aa360 Mon Sep 17 00:00:00 2001 From: chenshaohua <635616957@qq.com> Date: Sat, 11 Jul 2026 20:17:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=92=A8=E8=AF=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/HrAgencyConsultMsgController.java | 129 ++++++++++++++++++ .../cms/domain/msg/HrAgencyConsultMsg.java | 76 +++++++++++ .../mapper/msg/HrAgencyConsultMsgMapper.java | 47 +++++++ .../msg/IHrAgencyConsultMsgService.java | 77 +++++++++++ .../impl/HrAgencyConsultMsgServiceImpl.java | 83 +++++++++++ .../mapper/msg/HrAgencyConsultMsgMapper.xml | 83 +++++++++++ 6 files changed, 495 insertions(+) create mode 100644 ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/HrAgencyConsultMsgController.java create mode 100644 ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/msg/HrAgencyConsultMsg.java create mode 100644 ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/msg/HrAgencyConsultMsgMapper.java create mode 100644 ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/msg/IHrAgencyConsultMsgService.java create mode 100644 ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/msg/impl/HrAgencyConsultMsgServiceImpl.java create mode 100644 ruoyi-bussiness/src/main/resources/mapper/msg/HrAgencyConsultMsgMapper.xml diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/HrAgencyConsultMsgController.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/HrAgencyConsultMsgController.java new file mode 100644 index 0000000..b4dea6b --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/app/HrAgencyConsultMsgController.java @@ -0,0 +1,129 @@ +package com.ruoyi.cms.controller.app; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.cms.domain.msg.HrAgencyConsultMsg; +import com.ruoyi.cms.service.msg.IHrAgencyConsultMsgService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +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.RestController; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.utils.poi.ExcelUtil; + +/** + * 人力中介咨询消息Controller + * + * @author ruoyi + * @date 2026-07-10 + */ +@RestController +@RequestMapping("/app/hrAgencyConsultMsg") +public class HrAgencyConsultMsgController extends BaseController +{ + @Autowired + private IHrAgencyConsultMsgService hrAgencyConsultMsgService; + + /** + * 查询消息列表 + */ + @GetMapping("/list") + public TableDataInfo list(HrAgencyConsultMsg hrAgencyConsultMsg) + { + startPage(); + List list = hrAgencyConsultMsgService.selectHrAgencyConsultMsgList(hrAgencyConsultMsg); + return getDataTable(list); + } + + /** + * 导出Excel + */ + @PostMapping("/export") + public void export(HttpServletResponse response, HrAgencyConsultMsg hrAgencyConsultMsg) + { + List list = hrAgencyConsultMsgService.selectHrAgencyConsultMsgList(hrAgencyConsultMsg); + ExcelUtil util = new ExcelUtil<>(HrAgencyConsultMsg.class); + util.exportExcel(response, list, "中介咨询消息数据"); + } + + /** + * 获取单条详情 + */ + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable Long id) + { + return AjaxResult.success(hrAgencyConsultMsgService.selectHrAgencyConsultMsgById(id)); + } + + /** + * 新增消息 + */ + @PostMapping + public AjaxResult add(@RequestBody HrAgencyConsultMsg hrAgencyConsultMsg) + { + return toAjax(hrAgencyConsultMsgService.insertHrAgencyConsultMsg(hrAgencyConsultMsg)); + } + + /** + * 修改消息 + */ + @PutMapping + public AjaxResult edit(@RequestBody HrAgencyConsultMsg hrAgencyConsultMsg) + { + return toAjax(hrAgencyConsultMsgService.updateHrAgencyConsultMsg(hrAgencyConsultMsg)); + } + + /** + * 删除消息 + */ + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(hrAgencyConsultMsgService.deleteHrAgencyConsultMsgByIds(ids)); + } + + /** + * 根据会话ID查询聊天记录 + */ + @GetMapping("/session/{sessionId}") + public AjaxResult getSessionMsg(@PathVariable String sessionId) { + List list = hrAgencyConsultMsgService.listMsgBySessionId(sessionId); + return AjaxResult.success(list); + } + + /** + * 机构标记已读 + */ + @PutMapping("/read/agency") + public AjaxResult markAgencyRead(@RequestBody HrAgencyConsultMsg hrAgencyConsultMsg) { + return toAjax(hrAgencyConsultMsgService.markAgencyRead(hrAgencyConsultMsg)); + } + + /** + * 求职者标记已读 + */ + @PutMapping("/read/seeker") + public AjaxResult markSeekerRead(@RequestBody HrAgencyConsultMsg hrAgencyConsultMsg) { + + return toAjax(hrAgencyConsultMsgService.markSeekerRead(hrAgencyConsultMsg)); + } + + /** + * 生成会话ID + */ + @GetMapping("/genSessionId") + public AjaxResult genSessionId(Long agencyId, Long seekerId) { + String sessionId = hrAgencyConsultMsgService.generateSessionId(agencyId, seekerId); + AjaxResult ajax = AjaxResult.success(); + ajax.put("sessionId", sessionId); + return ajax; + } +} \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/msg/HrAgencyConsultMsg.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/msg/HrAgencyConsultMsg.java new file mode 100644 index 0000000..9317937 --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/domain/msg/HrAgencyConsultMsg.java @@ -0,0 +1,76 @@ +package com.ruoyi.cms.domain.msg; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 人力中介机构与求职者咨询对话消息对象 hr_agency_consult_msg + * + * @author ruoyi + * @date 2026-07-10 + */ +@Data +@ApiModel("人力中介咨询消息实体") +public class HrAgencyConsultMsg extends BaseEntity +{ + @TableField(exist = false) + private static final long serialVersionUID = 1L; + + /** 主键自增ID */ + @TableId(type = IdType.AUTO) + @ApiModelProperty("主键ID") + private Long id; + + /** 会话唯一ID,中介机构和求职者对话分组标识 */ + @ApiModelProperty("会话唯一ID") + private String sessionId; + + /** 发送方类型:1-求职者 2-人力中介机构 */ + @ApiModelProperty("发送方类型:1求职者,2人力中介机构") + private Integer sendUserType; + + /** 发送方ID,求职者ID/人力机构ID */ + @ApiModelProperty("发送方ID") + private Long sendUserId; + + /** 发送方名称(求职者姓名/人力机构名称) */ + @ApiModelProperty("发送方名称") + private String sendUserName; + + /** 接收方类型:1-求职者 2-人力中介机构 */ + @ApiModelProperty("接收方类型:1求职者,2人力中介机构") + private Integer receiveUserType; + + /** 接收方ID */ + @ApiModelProperty("接收方ID") + private Long receiveUserId; + + /** 接收方名称 */ + @ApiModelProperty("接收方名称") + private String receiveUserName; + + /** 消息类型:1-文本 2-图片 3-文件附件 4-语音 */ + @ApiModelProperty("消息类型:1文本 2图片 3文件 4语音") + private Integer msgType; + + /** 文本消息内容 */ + @ApiModelProperty("文本消息内容") + private String msgContent; + + /** 图片/附件资源地址,多图逗号分隔 */ + @ApiModelProperty("附件资源地址,多个逗号分隔") + private String msgAttachUrl; + + /** 求职者是否已读:0未读 1已读 */ + @ApiModelProperty("求职者是否已读:0未读 1已读") + private Integer seekerRead; + + /** 人力中介机构是否已读:0未读 1已读 */ + @ApiModelProperty("人力机构是否已读:0未读 1已读") + private Integer agencyRead; +} \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/msg/HrAgencyConsultMsgMapper.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/msg/HrAgencyConsultMsgMapper.java new file mode 100644 index 0000000..9bb2655 --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/mapper/msg/HrAgencyConsultMsgMapper.java @@ -0,0 +1,47 @@ +package com.ruoyi.cms.mapper.msg; + +import java.util.List; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.cms.domain.msg.HrAgencyConsultMsg; +import org.apache.ibatis.annotations.Param; + +/** + * 人力中介咨询消息Mapper接口 + * + * @author ruoyi + * @date 2026-07-10 + */ +public interface HrAgencyConsultMsgMapper extends BaseMapper +{ + /** + * 查询单条消息详情 + * + * @param id 主键ID + * @return 消息实体 + */ + public HrAgencyConsultMsg selectHrAgencyConsultMsgById(Long id); + + /** + * 查询消息列表 + * + * @param hrAgencyConsultMsg 查询条件 + * @return 消息集合 + */ + public List selectHrAgencyConsultMsgList(HrAgencyConsultMsg hrAgencyConsultMsg); + + /** + * 根据会话ID查询会话全部消息 + */ + List selectMsgBySessionId(@Param("sessionId") String sessionId); + + /** + * 标记机构全部消息已读 + */ + int updateAgencyReadBySessionId(HrAgencyConsultMsg hrAgencyConsultMsg); + + /** + * 标记求职者全部消息已读 + */ + int updateSeekerReadBySessionId(HrAgencyConsultMsg hrAgencyConsultMsg); +} \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/msg/IHrAgencyConsultMsgService.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/msg/IHrAgencyConsultMsgService.java new file mode 100644 index 0000000..3e01ebf --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/msg/IHrAgencyConsultMsgService.java @@ -0,0 +1,77 @@ +package com.ruoyi.cms.service.msg; + +import com.ruoyi.cms.domain.msg.HrAgencyConsultMsg; + +import java.util.List; + +/** + * 人力中介咨询消息Service接口 + * + * @author ruoyi + * @date 2026-07-10 + */ +public interface IHrAgencyConsultMsgService +{ + /** + * 查询单条消息 + * + * @param id 主键ID + * @return 消息实体 + */ + public HrAgencyConsultMsg selectHrAgencyConsultMsgById(Long id); + + /** + * 查询消息列表 + * + * @param hrAgencyConsultMsg 查询条件 + * @return 消息集合 + */ + public List selectHrAgencyConsultMsgList(HrAgencyConsultMsg hrAgencyConsultMsg); + + /** + * 新增消息(自动生成sessionId逻辑内置) + * + * @param hrAgencyConsultMsg 消息实体 + * @return 结果 + */ + public int insertHrAgencyConsultMsg(HrAgencyConsultMsg hrAgencyConsultMsg); + + /** + * 修改消息 + * + * @param hrAgencyConsultMsg 消息实体 + * @return 结果 + */ + public int updateHrAgencyConsultMsg(HrAgencyConsultMsg hrAgencyConsultMsg); + + /** + * 批量删除消息 + * + * @param ids 需要删除的主键数组 + * @return 结果 + */ + public int deleteHrAgencyConsultMsgByIds(Long[] ids); + + /** + * 根据会话ID查询全部聊天记录 + */ + List listMsgBySessionId(String sessionId); + + /** + * 标记机构当前会话全部消息已读 + */ + int markAgencyRead(HrAgencyConsultMsg hrAgencyConsultMsg); + + /** + * 标记求职者当前会话全部消息已读 + */ + int markSeekerRead(HrAgencyConsultMsg hrAgencyConsultMsg); + + /** + * 生成会话唯一sessionId:SESS_机构ID_求职者ID + * @param agencyId 人力机构ID + * @param seekerId 求职者ID + * @return sessionId + */ + String generateSessionId(Long agencyId, Long seekerId); +} \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/msg/impl/HrAgencyConsultMsgServiceImpl.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/msg/impl/HrAgencyConsultMsgServiceImpl.java new file mode 100644 index 0000000..d05125e --- /dev/null +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/msg/impl/HrAgencyConsultMsgServiceImpl.java @@ -0,0 +1,83 @@ +package com.ruoyi.cms.service.msg.impl; + +import java.util.Arrays; +import java.util.List; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.cms.domain.msg.HrAgencyConsultMsg; +import com.ruoyi.cms.mapper.msg.HrAgencyConsultMsgMapper; +import com.ruoyi.cms.service.msg.IHrAgencyConsultMsgService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 人力中介咨询消息Service实现 + * + * @author ruoyi + * @date 2026-07-10 + */ +@Service +public class HrAgencyConsultMsgServiceImpl extends ServiceImpl implements IHrAgencyConsultMsgService { + @Autowired + private HrAgencyConsultMsgMapper hrAgencyConsultMsgMapper; + + @Override + public HrAgencyConsultMsg selectHrAgencyConsultMsgById(Long id) + { + return hrAgencyConsultMsgMapper.selectHrAgencyConsultMsgById(id); + } + + @Override + public List selectHrAgencyConsultMsgList(HrAgencyConsultMsg hrAgencyConsultMsg) + { + return hrAgencyConsultMsgMapper.selectHrAgencyConsultMsgList(hrAgencyConsultMsg); + } + + @Override + public int insertHrAgencyConsultMsg(HrAgencyConsultMsg hrAgencyConsultMsg) + { + // 默认未读 + if (hrAgencyConsultMsg.getSeekerRead() == null) { + hrAgencyConsultMsg.setSeekerRead(0); + } + if (hrAgencyConsultMsg.getAgencyRead() == null) { + hrAgencyConsultMsg.setAgencyRead(0); + } + if (hrAgencyConsultMsg.getMsgType() == null) { + hrAgencyConsultMsg.setMsgType(1); + } + return hrAgencyConsultMsgMapper.insert(hrAgencyConsultMsg); + } + + @Override + public int updateHrAgencyConsultMsg(HrAgencyConsultMsg hrAgencyConsultMsg) + { + return hrAgencyConsultMsgMapper.updateById(hrAgencyConsultMsg); + } + + @Override + public int deleteHrAgencyConsultMsgByIds(Long[] ids) + { + return hrAgencyConsultMsgMapper.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public List listMsgBySessionId(String sessionId) { + return hrAgencyConsultMsgMapper.selectMsgBySessionId(sessionId); + } + + @Override + public int markAgencyRead(HrAgencyConsultMsg hrAgencyConsultMsg) { + return hrAgencyConsultMsgMapper.updateAgencyReadBySessionId(hrAgencyConsultMsg); + } + + @Override + public int markSeekerRead(HrAgencyConsultMsg hrAgencyConsultMsg) { + return hrAgencyConsultMsgMapper.updateSeekerReadBySessionId(hrAgencyConsultMsg); + } + + @Override + public String generateSessionId(Long agencyId, Long seekerId) { + return "SESS_" + agencyId + "_" + seekerId; + } +} \ No newline at end of file diff --git a/ruoyi-bussiness/src/main/resources/mapper/msg/HrAgencyConsultMsgMapper.xml b/ruoyi-bussiness/src/main/resources/mapper/msg/HrAgencyConsultMsgMapper.xml new file mode 100644 index 0000000..3c28d52 --- /dev/null +++ b/ruoyi-bussiness/src/main/resources/mapper/msg/HrAgencyConsultMsgMapper.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT id, session_id, send_user_type, send_user_id, send_user_name, receive_user_type, receive_user_id, receive_user_name, + msg_type, msg_content, msg_attach_url, seeker_read, agency_read, job_id, del_flag, create_by, create_time, update_by, update_time + FROM hr_agency_consult_msg + + + + + + + + + + UPDATE hr_agency_consult_msg + SET agency_read = 1, update_by = #{updateBy}, update_time = NOW() + WHERE session_id = #{sessionId} AND del_flag = '0' AND agency_read = '0' + + + + UPDATE hr_agency_consult_msg + SET seeker_read = 1, update_by = #{updateBy}, update_time = NOW() + WHERE session_id = #{sessionId} AND del_flag = '0' AND seeker_read = '0' + + + \ No newline at end of file