Commit 260d58bd by 徐高华

企微通知

parent d12be00e
package com.gic.haoban.manage.service.dao.mapper.chat;
import java.util.List;
import com.gic.haoban.manage.service.entity.chat.TabChatNotice;
/**
*
* @ClassName: TabHaobanChatNoticeMapper
* @Description: TODO
* @Author 徐高华
* @Date 2022年12月01日 17:54:02
* @Modify
* @CopyRight
*/
public interface ChatNoticeMapper {
public int insert(TabChatNotice entity);
public int updateStatus(TabChatNotice entity);
public List<TabChatNotice> listAll();
}
\ No newline at end of file
package com.gic.haoban.manage.service.entity.chat;
import java.io.Serializable;
/**
*
* @ClassName: TabHaobanChatNotice
* @Description: TODO
* @Author 徐高华
* @Date 2022年12月01日 17:54:02
* @Modify
* @CopyRight
*/
public class TabChatNotice implements Serializable {
private static final long serialVersionUID = 2487673259100L;
private Long id;
private String wxEnterpriseId;
private Long chatId;
private String msg;
private Integer type;
/**0待处理1已处理*/
private Integer statusFlag;
private java.util.Date createTime;
private java.util.Date updateTime;
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setChatId(Long chatId) {
this.chatId = chatId;
}
public Long getChatId() {
return chatId;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getMsg() {
return msg;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getType() {
return type;
}
public void setStatusFlag(Integer statusFlag) {
this.statusFlag = statusFlag;
}
public Integer getStatusFlag() {
return statusFlag;
}
public void setCreateTime(java.util.Date createTime) {
this.createTime = createTime;
}
public java.util.Date getCreateTime() {
return createTime;
}
public void setUpdateTime(java.util.Date updateTime) {
this.updateTime = updateTime;
}
public java.util.Date getUpdateTime() {
return updateTime;
}
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ public interface GroupChatService {
public void createChat(String corpid, String wxChatId);
// 更新同步群信息
public void updateChat(String corpid, String wxChatId ,String updateDetail);
public void updateChat(String corpid, String wxChatId ,String updateDetail , String msg);
// 初始化企业群
public void initEnterpriseGroupChat(String wxEnterpriseId);
......
......@@ -20,11 +20,13 @@ import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanExternalClerkRelatedMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.ChatNoticeMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatUserMapper;
import com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.entity.chat.TabChatNotice;
import com.gic.haoban.manage.service.entity.chat.TabGroupChat;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatUser;
import com.gic.haoban.manage.service.service.SecretSettingService;
......@@ -59,6 +61,8 @@ public class GroupChatServiceImpl implements GroupChatService {
private StaffMapper staffMapper;
@Autowired
private SecretSettingService secretSettingService;
@Autowired
private ChatNoticeMapper chatNoticeMapper;
@Override
public void createChat(String corpid, String wxChatId) {
......@@ -85,29 +89,34 @@ public class GroupChatServiceImpl implements GroupChatService {
}
@Override
public void updateChat(String corpid, String wxChatId, String updateDetail) {
public void updateChat(String corpid, String wxChatId, String updateDetail, String msg) {
String wxEnterpriseId = this.getWxEnterpriesId(corpid);
if (null == wxEnterpriseId) {
return;
}
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
if (null == qwDTO) {
logger.info("wxEnterpriseId不存在,id={}", wxEnterpriseId);
TabGroupChat groupChat = this.groupChatMapper.selectByWxChatId(wxEnterpriseId, wxChatId);
if (null == groupChat) {
logger.info("群不存在");
return;
}
TabGroupChat groupChat = this.groupChatMapper.selectByWxChatId(qwDTO.getWxEnterpriseId(), wxChatId);
// change_name=群名变更change_notice=群公告变更
TabChatNotice entity = new TabChatNotice();
entity.setId(UniqueIdUtils.uniqueLong());
entity.setChatId(groupChat.getGroupChatId());
entity.setWxEnterpriseId(wxEnterpriseId);
entity.setMsg(msg);
// change_name=群名变更change_notice=群公告变更 1
if ("change_name".equals(updateDetail) || "change_notice".equals(updateDetail)) {
this.initGroupChatDetail(qwDTO, groupChat, false);
entity.setType(1);
}
// change_owner=群主变更
// change_owner=群主变更 2
if ("change_owner".equals(updateDetail)) {
entity.setType(2);
}
// add_member=成员入群 del_member=成员退群
// add_member=成员入群 del_member=成员退群 3
if ("add_member".equals(updateDetail) || "del_member".equals(updateDetail)) {
entity.setType(3);
}
this.chatNoticeMapper.insert(entity);
}
@Override
......
......@@ -33,7 +33,7 @@ public class GroupChatApiServiceImpl implements GroupChatApiService {
this.groupChatService.createChat(corpid, wxChatId);
} else {
String updateDetail = dto.getUpdateDetail();
this.groupChatService.updateChat(corpid, wxChatId, updateDetail);
this.groupChatService.updateChat(corpid, wxChatId, updateDetail , JSON.toJSONString(dto));
}
return ServiceResponse.success();
}
......
<?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.gic.haoban.manage.service.dao.mapper.chat.ChatNoticeMapper">
<resultMap type="com.gic.haoban.manage.service.entity.chat.TabChatNotice" id="result-map-tabHaobanChatNotice">
<result column="id" property="id" />
<result column="wx_enterprise_id" property="wxEnterpriseId" />
<result column="chat_id" property="chatId" />
<result column="msg" property="msg" />
<result column="type" property="type" />
<result column="status_flag" property="statusFlag" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
id ,
wx_enterprise_id,
chat_id,
msg,
type,
status_flag,
create_time,
update_time
</sql>
<!-- ===================== 新增 ======================== -->
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.chat.TabChatNotice">
<![CDATA[
INSERT INTO tab_haoban_chat_notice(
id ,
wx_enterprise_id,
chat_id,
msg,
type,
status_flag,
create_time,
update_time
)VALUES(
#{id},
#{wxEnterpriseId},
#{chatId},
#{msg},
#{type},
0,
now(),
now()
)
]]>
</insert>
<!-- ==================更新 ========== -->
<update id="updateStatus">
<![CDATA[
UPDATE tab_haoban_chat_notice SET
status_flag=#{statusFlag},
update_time=now()
where id = #{id}
]]>
</update>
<!-- ============ 查询============= -->
<select id="selectById" parameterType="long" resultMap="result-map-tabHaobanChatNotice">
SELECT <include refid="Base_Column_List" /> FROM tab_haoban_chat_notice WHERE id = #{id}
</select>
<select id="listAll" resultMap="result-map-tabHaobanChatNotice">
select <include refid="Base_Column_List" /> from tab_haoban_chat_notice
</select>
</mapper>
\ No newline at end of file
<?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.gic.haoban.manage.service.dao.mapper.chat.GroupChatUserMapper">
<resultMap type="com.gic.haoban.manage.service.entity.chat.TabGroupChatUser" id="result-map-tabHaobanGroupChatUser">
<result column="chat_user_id" property="chatUserId"/>
<result column="wx_enterprise_id" property="wxEnterpriseId"/>
<result column="enterprise_id" property="enterpriseId"/>
<result column="user_type" property="userType"/>
<result column="join_time" property="joinTime"/>
<result column="user_name" property="userName"/>
<result column="nick_name" property="nickName"/>
<result column="user_id" property="userId"/>
<result column="unionid" property="unionid"/>
<result column="member_id" property="memberId"/>
<result column="invitor_user_id" property="invitorUserId"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="delete_flag" property="deleteFlag"/>
<result column="group_chat_id" property="groupChatId"/>
<result column="status_flag" property="statusFlag"/>
<result column="user_quit_time" property="userQuitTime"/>
<result column="quit_scene" property="quitScene"/>
<result column="join_scene" property="joinScene"/>
<result column="join_remark" property="joinRemark"/>
<result column="join_state" property="joinState"/>
</resultMap>
<sql id="Base_Column_List">
chat_user_id,
wx_enterprise_id,
enterprise_id,
user_type,
join_time,
user_name,
nick_name,
user_id,
unionid,
member_id,
invitor_user_id,
create_time,
update_time,
delete_flag,
group_chat_id,
status_flag,
user_quit_time,
quit_scene,
join_scene,
join_remark,
join_state
</sql>
<!-- ===================== 新增 ======================== -->
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.chat.TabGroupChatUser">
<mapper
namespace="com.gic.haoban.manage.service.dao.mapper.chat.GroupChatUserMapper">
<resultMap type="com.gic.haoban.manage.service.entity.chat.TabGroupChatUser"
id="result-map-tabHaobanGroupChatUser">
<result column="chat_user_id" property="chatUserId" />
<result column="wx_enterprise_id" property="wxEnterpriseId" />
<result column="enterprise_id" property="enterpriseId" />
<result column="user_type" property="userType" />
<result column="join_time" property="joinTime" />
<result column="user_name" property="userName" />
<result column="nick_name" property="nickName" />
<result column="user_id" property="userId" />
<result column="unionid" property="unionid" />
<result column="member_id" property="memberId" />
<result column="invitor_user_id" property="invitorUserId" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="delete_flag" property="deleteFlag" />
<result column="group_chat_id" property="groupChatId" />
<result column="status_flag" property="statusFlag" />
<result column="user_quit_time" property="userQuitTime" />
<result column="quit_scene" property="quitScene" />
<result column="join_scene" property="joinScene" />
<result column="join_remark" property="joinRemark" />
<result column="join_state" property="joinState" />
</resultMap>
<sql id="Base_Column_List">
chat_user_id,
wx_enterprise_id,
enterprise_id,
user_type,
join_time,
user_name,
nick_name,
user_id,
unionid,
member_id,
invitor_user_id,
create_time,
update_time,
delete_flag,
group_chat_id,
status_flag,
user_quit_time,
quit_scene,
join_scene,
join_remark,
join_state
</sql>
<!-- ===================== 新增 ======================== -->
<insert id="insert"
parameterType="com.gic.haoban.manage.service.entity.chat.TabGroupChatUser">
<![CDATA[
INSERT INTO tab_haoban_group_chat_user(
chat_user_id,
......@@ -96,16 +99,18 @@
#{joinState,jdbcType=VARCHAR}
)
]]>
</insert>
<!-- =====================删除==================== -->
<update id="deleteByPrimaryKey" parameterType="long">
UPDATE tab_haoban_group_chat_user SET delete_flag = 1 WHERE chat_user_id = #{chatUserId}
</update>
<!-- ==================更新 ========== -->
<update id="update" parameterType="com.gic.haoban.manage.service.entity.chat.TabGroupChatUser">
</insert>
<!-- =====================删除==================== -->
<update id="deleteByPrimaryKey" parameterType="long">
UPDATE tab_haoban_group_chat_user SET delete_flag = 1 WHERE chat_user_id =
#{chatUserId}
</update>
<!-- ==================更新 ========== -->
<update id="update"
parameterType="com.gic.haoban.manage.service.entity.chat.TabGroupChatUser">
<![CDATA[
UPDATE tab_haoban_group_chat_user SET
user_type=#{userType,jdbcType=INTEGER},
......@@ -126,18 +131,26 @@
join_state=#{joinState,jdbcType=VARCHAR}
where chat_user_id = #{chatUserId}
]]>
</update>
<!-- ============ 查询=============-->
<select id="selectById" parameterType="long" resultMap="result-map-tabHaobanGroupChatUser">
SELECT <include refid="Base_Column_List"/> FROM tab_haoban_group_chat_user WHERE chat_user_id = #{chatUserId}
</select>
<select id="selectByUserIdAndChatId" resultMap="result-map-tabHaobanGroupChatUser">
select <include refid="Base_Column_List"/> from tab_haoban_group_chat_user where group_chat_id = #{groupChatId} and user_id =#{userId} and delete_flag = 0
</select>
<select id="listAll" parameterType="com.gic.haoban.manage.service.entity.chat.TabGroupChatUser" resultMap="result-map-tabHaobanGroupChatUser">
select * from tab_haoban_group_chat_user
</select>
</update>
<!-- ============ 查询============= -->
<select id="selectById" parameterType="long"
resultMap="result-map-tabHaobanGroupChatUser">
SELECT
<include refid="Base_Column_List" />
FROM tab_haoban_group_chat_user WHERE chat_user_id = #{chatUserId}
</select>
<select id="selectByUserIdAndChatId" resultMap="result-map-tabHaobanGroupChatUser">
select
<include refid="Base_Column_List" />
from tab_haoban_group_chat_user where group_chat_id = #{groupChatId}
and user_id =#{userId} and delete_flag = 0
</select>
<select id="listAll"
parameterType="com.gic.haoban.manage.service.entity.chat.TabGroupChatUser"
resultMap="result-map-tabHaobanGroupChatUser">
select * from tab_haoban_group_chat_user
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment