添加咨询接口
This commit is contained in:
@@ -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<HrAgencyConsultMsg> list = hrAgencyConsultMsgService.selectHrAgencyConsultMsgList(hrAgencyConsultMsg);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出Excel
|
||||
*/
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, HrAgencyConsultMsg hrAgencyConsultMsg)
|
||||
{
|
||||
List<HrAgencyConsultMsg> list = hrAgencyConsultMsgService.selectHrAgencyConsultMsgList(hrAgencyConsultMsg);
|
||||
ExcelUtil<HrAgencyConsultMsg> 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<HrAgencyConsultMsg> 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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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<HrAgencyConsultMsg>
|
||||
{
|
||||
/**
|
||||
* 查询单条消息详情
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return 消息实体
|
||||
*/
|
||||
public HrAgencyConsultMsg selectHrAgencyConsultMsgById(Long id);
|
||||
|
||||
/**
|
||||
* 查询消息列表
|
||||
*
|
||||
* @param hrAgencyConsultMsg 查询条件
|
||||
* @return 消息集合
|
||||
*/
|
||||
public List<HrAgencyConsultMsg> selectHrAgencyConsultMsgList(HrAgencyConsultMsg hrAgencyConsultMsg);
|
||||
|
||||
/**
|
||||
* 根据会话ID查询会话全部消息
|
||||
*/
|
||||
List<HrAgencyConsultMsg> selectMsgBySessionId(@Param("sessionId") String sessionId);
|
||||
|
||||
/**
|
||||
* 标记机构全部消息已读
|
||||
*/
|
||||
int updateAgencyReadBySessionId(HrAgencyConsultMsg hrAgencyConsultMsg);
|
||||
|
||||
/**
|
||||
* 标记求职者全部消息已读
|
||||
*/
|
||||
int updateSeekerReadBySessionId(HrAgencyConsultMsg hrAgencyConsultMsg);
|
||||
}
|
||||
@@ -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<HrAgencyConsultMsg> 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<HrAgencyConsultMsg> 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);
|
||||
}
|
||||
@@ -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<HrAgencyConsultMsgMapper, HrAgencyConsultMsg> implements IHrAgencyConsultMsgService {
|
||||
@Autowired
|
||||
private HrAgencyConsultMsgMapper hrAgencyConsultMsgMapper;
|
||||
|
||||
@Override
|
||||
public HrAgencyConsultMsg selectHrAgencyConsultMsgById(Long id)
|
||||
{
|
||||
return hrAgencyConsultMsgMapper.selectHrAgencyConsultMsgById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HrAgencyConsultMsg> 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<HrAgencyConsultMsg> 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.ruoyi.cms.mapper.msg.HrAgencyConsultMsgMapper">
|
||||
|
||||
<resultMap type="HrAgencyConsultMsg" id="HrAgencyConsultMsgResult">
|
||||
<id column="id" property="id"/>
|
||||
<result column="session_id" property="sessionId"/>
|
||||
<result column="send_user_type" property="sendUserType"/>
|
||||
<result column="send_user_id" property="sendUserId"/>
|
||||
<result column="send_user_name" property="sendUserName"/>
|
||||
<result column="receive_user_type" property="receiveUserType"/>
|
||||
<result column="receive_user_id" property="receiveUserId"/>
|
||||
<result column="receive_user_name" property="receiveUserName"/>
|
||||
<result column="msg_type" property="msgType"/>
|
||||
<result column="msg_content" property="msgContent"/>
|
||||
<result column="msg_attach_url" property="msgAttachUrl"/>
|
||||
<result column="seeker_read" property="seekerRead"/>
|
||||
<result column="agency_read" property="agencyRead"/>
|
||||
<result column="job_id" property="jobId"/>
|
||||
<result column="del_flag" property="delFlag"/>
|
||||
<result column="create_by" property="createBy"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_by" property="updateBy"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectHrAgencyConsultMsgVo">
|
||||
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
|
||||
</sql>
|
||||
|
||||
<select id="selectHrAgencyConsultMsgById" resultMap="HrAgencyConsultMsgResult">
|
||||
<include refid="selectHrAgencyConsultMsgVo"/>
|
||||
WHERE id = #{id} AND del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectHrAgencyConsultMsgList" resultMap="HrAgencyConsultMsgResult">
|
||||
<include refid="selectHrAgencyConsultMsgVo"/>
|
||||
<where>
|
||||
del_flag = 0
|
||||
<if test="sessionId != null and sessionId != ''">
|
||||
AND session_id = #{sessionId}
|
||||
</if>
|
||||
<if test="sendUserType != null">
|
||||
AND send_user_type = #{sendUserType}
|
||||
</if>
|
||||
<if test="sendUserId != null">
|
||||
AND send_user_id = #{sendUserId}
|
||||
</if>
|
||||
<if test="receiveUserType != null">
|
||||
AND receive_user_type = #{receiveUserType}
|
||||
</if>
|
||||
<if test="receiveUserId != null">
|
||||
AND receive_user_id = #{receiveUserId}
|
||||
</if>
|
||||
<if test="jobId != null">
|
||||
AND job_id = #{jobId}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectMsgBySessionId" resultMap="HrAgencyConsultMsgResult">
|
||||
<include refid="selectHrAgencyConsultMsgVo"/>
|
||||
WHERE session_id = #{sessionId} AND del_flag = '0'
|
||||
ORDER BY create_time ASC
|
||||
</select>
|
||||
|
||||
<update id="updateAgencyReadBySessionId" parameterType="HrAgencyConsultMsg">
|
||||
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>
|
||||
|
||||
<update id="updateSeekerReadBySessionId" parameterType="HrAgencyConsultMsg">
|
||||
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'
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user