Commit bdf13426 by 罗长华

1、调整群设置入参

2、群设置入参修改
parent 953bf923
...@@ -80,10 +80,6 @@ public class ImConversation extends BaseEntity { ...@@ -80,10 +80,6 @@ public class ImConversation extends BaseEntity {
@ApiModelProperty("禁止互加好友") @ApiModelProperty("禁止互加好友")
private Boolean forbidAddFriend; private Boolean forbidAddFriend;
@TableField("is_forbid_send_red_packets")
@ApiModelProperty("禁止发红包")
private Boolean forbidSendRedPackets;
@TableField("is_forbid_send_pic") @TableField("is_forbid_send_pic")
@ApiModelProperty("禁止发图片") @ApiModelProperty("禁止发图片")
private Boolean forbidSendPic; private Boolean forbidSendPic;
......
...@@ -22,7 +22,7 @@ public class GroupChatSettingParam { ...@@ -22,7 +22,7 @@ public class GroupChatSettingParam {
@NotNull @NotNull
@ApiModelProperty("会话id") @ApiModelProperty("会话id")
private Long conversationId; private Long groupId;
@ApiModelProperty("开启 true是 false否") @ApiModelProperty("开启 true是 false否")
private Boolean on; private Boolean on;
......
...@@ -18,17 +18,29 @@ public enum GroupChatSettingTypeEnum implements BaseEnum { ...@@ -18,17 +18,29 @@ public enum GroupChatSettingTypeEnum implements BaseEnum {
*/ */
FORBID_ADD_FRIEND(1, "禁止群成员互加好友"), FORBID_ADD_FRIEND(1, "禁止群成员互加好友"),
/** /**
* 2-禁止群成员发红包
*/
FORBID_SEND_RED_PACKETS(2, "禁止群成员发红包"),
/**
* 3-禁止群成员发图片 * 3-禁止群成员发图片
*/ */
FORBID_SEND_PIC(3, "禁止群成员发图片"), FORBID_SEND_PIC(2, "禁止群成员发图片"),
/** /**
* 4-禁止群成员发链接 * 4-禁止群成员发链接
*/ */
FORBID_SEND_LINK(4, "禁止群成员发链接"); FORBID_SEND_LINK(3, "禁止群成员发链接"),
/**
* 4-禁言
*/
MUTED(4, "禁言"),
/**
* 5-修改群名
*/
NAME(5, "修改群名"),
/**
* 修改群头像
*/
HEAD_PORTRAIT(6, "修改群头像"),
;
GroupChatSettingTypeEnum(int code, String desc) { GroupChatSettingTypeEnum(int code, String desc) {
......
...@@ -225,7 +225,7 @@ public interface ImConversationService extends BaseService<ImConversation> { ...@@ -225,7 +225,7 @@ public interface ImConversationService extends BaseService<ImConversation> {
Long getRepetitionConversationAttributes(Long clientId1, Long clientId2, String attributes); Long getRepetitionConversationAttributes(Long clientId1, Long clientId2, String attributes);
/** /**
* 群禁言 * 群设置
* @param param * @param param
* @return * @return
*/ */
......
package com.wecloud.im.service.impl; package com.wecloud.im.service.impl;
import io.geekidea.springbootplus.framework.common.api.ApiCode;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.enums.BaseEnum;
import io.geekidea.springbootplus.framework.common.exception.BusinessException;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
...@@ -62,29 +88,6 @@ import com.wecloud.im.ws.sender.ChannelSender; ...@@ -62,29 +88,6 @@ import com.wecloud.im.ws.sender.ChannelSender;
import com.wecloud.im.ws.utils.RedisUtils; import com.wecloud.im.ws.utils.RedisUtils;
import com.wecloud.utils.JsonUtils; import com.wecloud.utils.JsonUtils;
import com.wecloud.utils.SnowflakeUtil; import com.wecloud.utils.SnowflakeUtil;
import io.geekidea.springbootplus.framework.common.api.ApiCode;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.enums.BaseEnum;
import io.geekidea.springbootplus.framework.common.exception.BusinessException;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static cn.hutool.core.date.DatePattern.CHINESE_DATE_PATTERN; import static cn.hutool.core.date.DatePattern.CHINESE_DATE_PATTERN;
import static com.wecloud.im.ws.enums.MsgTypeEnum.CONVERSATION_FORBID_ADD_FRIEND; import static com.wecloud.im.ws.enums.MsgTypeEnum.CONVERSATION_FORBID_ADD_FRIEND;
...@@ -93,8 +96,6 @@ import static com.wecloud.im.ws.enums.MsgTypeEnum.CONVERSATION_FORBID_SEND_LINK; ...@@ -93,8 +96,6 @@ import static com.wecloud.im.ws.enums.MsgTypeEnum.CONVERSATION_FORBID_SEND_LINK;
import static com.wecloud.im.ws.enums.MsgTypeEnum.CONVERSATION_FORBID_SEND_LINK_CANCEL; import static com.wecloud.im.ws.enums.MsgTypeEnum.CONVERSATION_FORBID_SEND_LINK_CANCEL;
import static com.wecloud.im.ws.enums.MsgTypeEnum.CONVERSATION_FORBID_SEND_PIC; import static com.wecloud.im.ws.enums.MsgTypeEnum.CONVERSATION_FORBID_SEND_PIC;
import static com.wecloud.im.ws.enums.MsgTypeEnum.CONVERSATION_FORBID_SEND_PIC_CANCEL; import static com.wecloud.im.ws.enums.MsgTypeEnum.CONVERSATION_FORBID_SEND_PIC_CANCEL;
import static com.wecloud.im.ws.enums.MsgTypeEnum.CONVERSATION_FORBID_SEND_RED_PACKETS;
import static com.wecloud.im.ws.enums.MsgTypeEnum.CONVERSATION_FORBID_SEND_RED_PACKETS_CANCEL;
/** /**
* 会话表 服务实现类 * 会话表 服务实现类
...@@ -1246,7 +1247,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -1246,7 +1247,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
public Boolean groupChatSetting(GroupChatSettingParam param) { public Boolean groupChatSetting(GroupChatSettingParam param) {
// 获取当前client // 获取当前client
ImClient currentClient = contextService.getImClientIfNotNullOrThrow(); ImClient currentClient = contextService.getImClientIfNotNullOrThrow();
if (!imConversationService.isBelongToRole(currentClient.getClientId(), param.getConversationId(), if (!imConversationService.isBelongToRole(currentClient.getClientId(), param.getGroupId(),
Lists.newArrayList(GroupRoleEnum.OWNER.getCode(), GroupRoleEnum.ADMIN.getCode()))) { Lists.newArrayList(GroupRoleEnum.OWNER.getCode(), GroupRoleEnum.ADMIN.getCode()))) {
// 当前操作人不属于群主或管理人员 // 当前操作人不属于群主或管理人员
throw new BusinessException("操作人既不是群主也不是群管理员,无权限操作"); throw new BusinessException("操作人既不是群主也不是群管理员,无权限操作");
...@@ -1255,15 +1256,12 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -1255,15 +1256,12 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
// 根据类型处理 // 根据类型处理
GroupChatSettingTypeEnum typeEnum = param.getType(); GroupChatSettingTypeEnum typeEnum = param.getType();
ImConversation muteGroupParam = new ImConversation(); ImConversation muteGroupParam = new ImConversation();
muteGroupParam.setId(param.getConversationId()); muteGroupParam.setId(param.getGroupId());
muteGroupParam.setUpdateTime(new Date()); muteGroupParam.setUpdateTime(new Date());
switch (typeEnum) { switch (typeEnum) {
case FORBID_ADD_FRIEND: case FORBID_ADD_FRIEND:
muteGroupParam.setForbidAddFriend(param.getOn()); muteGroupParam.setForbidAddFriend(param.getOn());
break; break;
case FORBID_SEND_RED_PACKETS:
muteGroupParam.setForbidSendRedPackets(param.getOn());
break;
case FORBID_SEND_PIC: case FORBID_SEND_PIC:
muteGroupParam.setForbidSendPic(param.getOn()); muteGroupParam.setForbidSendPic(param.getOn());
break; break;
...@@ -1275,10 +1273,10 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -1275,10 +1273,10 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
} }
// 更新会话 // 更新会话
imConversationMapper.updateById(muteGroupParam); imConversationMapper.updateById(muteGroupParam);
deleteCacheImConversationById(param.getConversationId()); deleteCacheImConversationById(param.getGroupId());
// 发送群聊配置变化消息 // 发送群聊配置变化消息
Integer msgType = getMsgType(typeEnum, param.getOn()); Integer msgType = getMsgType(typeEnum, param.getOn());
sendConversationSettingChangeMsg(currentClient, param.getConversationId(), msgType); sendConversationSettingChangeMsg(currentClient, param.getGroupId(), msgType);
return true; return true;
} }
...@@ -1480,13 +1478,6 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -1480,13 +1478,6 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
msgType = CONVERSATION_FORBID_ADD_FRIEND_CANCEL.getUriCode(); msgType = CONVERSATION_FORBID_ADD_FRIEND_CANCEL.getUriCode();
} }
break; break;
case FORBID_SEND_RED_PACKETS:
if (on) {
msgType = CONVERSATION_FORBID_SEND_RED_PACKETS.getUriCode();
} else {
msgType = CONVERSATION_FORBID_SEND_RED_PACKETS_CANCEL.getUriCode();
}
break;
case FORBID_SEND_PIC: case FORBID_SEND_PIC:
if (on) { if (on) {
msgType = CONVERSATION_FORBID_SEND_PIC.getUriCode(); msgType = CONVERSATION_FORBID_SEND_PIC.getUriCode();
......
...@@ -72,12 +72,6 @@ public enum MsgTypeEnum { ...@@ -72,12 +72,6 @@ public enum MsgTypeEnum {
// 取消禁止群成员互加好友 // 取消禁止群成员互加好友
CONVERSATION_FORBID_ADD_FRIEND_CANCEL(-1023), CONVERSATION_FORBID_ADD_FRIEND_CANCEL(-1023),
// 禁止群成员发红包
CONVERSATION_FORBID_SEND_RED_PACKETS(-1024),
// 取消禁止群成员发红包
CONVERSATION_FORBID_SEND_RED_PACKETS_CANCEL(-1025),
// 禁止群成员发图片 // 禁止群成员发图片
CONVERSATION_FORBID_SEND_PIC_CANCEL(-1026), CONVERSATION_FORBID_SEND_PIC_CANCEL(-1026),
......
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