Commit 99938109 by lixiaozhong

1、创建会话需要传给服务端chatType

2、查询会话列表,返回chatType和memberCount
3、在线文档路径添加新路径扫描
parent 61f36d6a
......@@ -155,7 +155,7 @@ public class Swagger2Config {
@Bean
public Docket restAppApi() {
// 获取需要扫描的包
String[] basePackages = {"com.wecloud.im.controller"};
String[] basePackages = {"com.wecloud.im.controller", "com.wecloud.im.thousandchat.controller"};
ApiSelectorBuilder apiSelectorBuilder = new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("app")
......
......@@ -42,8 +42,8 @@ public class ImConversation extends BaseEntity {
@ApiModelProperty("群成员数量")
private Integer memberCount;
@ApiModelProperty("是否万人群")
private Boolean isThousand;
@ApiModelProperty("会话属性,1:单聊,2:普通群,3:万人群")
private Integer chatType;
@NotNull(message = "应用appid不能为空")
@ApiModelProperty("应用appid")
......
package com.wecloud.im.enums;
import io.geekidea.springbootplus.framework.common.enums.BaseEnum;
/**
* @Description 会话类型
* @Author lixiaozhong
* @Date 2022/1/11 4:58 下午
*/
public enum ChatTypeEnum implements BaseEnum {
SINGLE(1, "单聊"),
NORMAL_GROUP(2, "普通群"),
THOUSAND_GROUP(3, "万人群");
private final Integer code;
private final String desc;
ChatTypeEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
@Override
public Integer getCode() {
return this.code;
}
@Override
public String getDesc() {
return this.desc;
}
}
......@@ -52,6 +52,6 @@ public class ImConversationQueryVo implements Serializable {
@ApiModelProperty("群成员数量")
private Integer memberCount;
@ApiModelProperty("是否万人群")
private Boolean isThousand;
@ApiModelProperty("会话属性,1:单聊,2:普通群,3:万人群")
private Integer chatType;
}
......@@ -7,6 +7,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.List;
......@@ -32,4 +33,8 @@ public class ImConversationCreate extends BaseEntity {
@ApiModelProperty("可选 邀请加入会话的客户端,如创建单聊,则填入对方的clientId")
private List<String> clientIds;
@ApiModelProperty("会话属性,1:单聊,2:普通群,3:万人群")
@NotNull(message = "会话类型不能为空")
private Integer chatType;
}
......@@ -11,6 +11,7 @@ import com.wecloud.im.entity.ImConversation;
import com.wecloud.im.entity.ImConversationMembers;
import com.wecloud.im.entity.ImMessage;
import com.wecloud.im.entity.ImMessageOnlineSend;
import com.wecloud.im.enums.ChatTypeEnum;
import com.wecloud.im.mapper.ImConversationMapper;
import com.wecloud.im.param.ImConversationPageParam;
import com.wecloud.im.param.ImConversationQueryVo;
......@@ -35,6 +36,7 @@ import com.wecloud.im.ws.sender.ChannelSender;
import com.wecloud.utils.JsonUtils;
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.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
......@@ -100,6 +102,11 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
return ApiResult.result(ApiCode.CLIENT_NOT_FOUNT, null);
}
if (BaseEnum.valueOf(ChatTypeEnum.class, imConversationCreate.getChatType()) == null) {
log.info("会话类型不存在");
return ApiResult.result(ApiCode.PARAMETER_EXCEPTION, null);
}
// 成员不存在,不能创建会话
for (String id : imConversationCreate.getClientIds()) {
ImClient imClient = imClientService.getOne(new QueryWrapper<ImClient>().lambda()
......@@ -180,7 +187,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
imConversation.setFkAppid(createClient.getFkAppid());
imConversation.setCreator(creator);
imConversation.setMemberCount(imConversationCreate.getClientIds().size() + 1);
imConversation.setIsThousand(false);
imConversation.setChatType(imConversationCreate.getChatType());
imConversation.setName(imConversationCreate.getName());
imConversation.setSystemFlag(false);
// 拓展数据
......
......@@ -11,6 +11,7 @@ import com.wecloud.im.entity.ImConversation;
import com.wecloud.im.entity.ImConversationMembers;
import com.wecloud.im.entity.ImMessage;
import com.wecloud.im.entity.ImMessageOnlineSend;
import com.wecloud.im.enums.ChatTypeEnum;
import com.wecloud.im.mapper.ImMessageMapper;
import com.wecloud.im.param.ImHistoryMessagePageParam;
import com.wecloud.im.param.add.ImMsgRecall;
......@@ -344,7 +345,7 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
for (ImConversation imConversation : myImConversationList) {
//万人群 暂时跳过,后面统一处理
if(BooleanUtils.isTrue(imConversation.getIsThousand())) {
if(ChatTypeEnum.THOUSAND_GROUP.getCode().equals(imConversation.getChatType())) {
thousandConversations.add(imConversation);
continue;
}
......
......@@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/imState")
@Api(value = "消息收件箱表API", tags = {"消息收件箱表"})
@Api(value = "万人群消息处理API", tags = {"万人群消息处理"})
public class ThousandChatController extends BaseController {
@Autowired
......@@ -30,7 +30,7 @@ public class ThousandChatController extends BaseController {
* 消息修改为已接收状态
*/
@PostMapping("/msgReceivedUpdate")
@ApiOperation(value = "消息修改为已接收状态")
@ApiOperation(value = "万人群消息修改为已接收状态")
public ApiResult<Boolean> updateImMsgReceived(@RequestBody @Validated LastestReceivedMsg lastestReceivedMsg) {
return thousandChatService.updateImMsgReceived(lastestReceivedMsg);
}
......@@ -39,7 +39,7 @@ public class ThousandChatController extends BaseController {
* 消息修改为已读状态
*/
@PostMapping("/msgReadUpdate")
@ApiOperation(value = "消息修改为已读状态")
@ApiOperation(value = "万人群消息修改为已读状态")
public ApiResult<Boolean> updateInMsgReadUpdate(Long lastestMsgId) {
return thousandChatService.updateImMsgRead(lastestMsgId);
}
......
......@@ -44,7 +44,7 @@ public class MyConversationListVo implements Serializable {
private HashMap attributes;
@ApiModelProperty("可选 对话类型标志,是否是系统对话,后面会说明。")
private Boolean system;
private Boolean systemFlag;
@ApiModelProperty("未读消息条数")
private Long msgNotReadCount;
......@@ -52,7 +52,13 @@ public class MyConversationListVo implements Serializable {
@ApiModelProperty("成员")
private String members;
@ApiModelProperty("会话属性,1:单聊,2:普通群,3:万人群")
private Integer chatType;
@ApiModelProperty("群成员数")
private Integer memberCount;
@ApiModelProperty("会话最后一条消息")
private OfflineMsgDto lastMsg;
}
\ No newline at end of file
}
......@@ -3,6 +3,7 @@ package com.wecloud.im.ws.strategy;
import com.wecloud.im.entity.ImApplication;
import com.wecloud.im.entity.ImClient;
import com.wecloud.im.enums.ChatTypeEnum;
import com.wecloud.im.param.ImConversationQueryVo;
import com.wecloud.im.service.ImApplicationService;
import com.wecloud.im.service.ImClientService;
......@@ -71,7 +72,7 @@ public abstract class AbstractImCmdStrategy {
return;
}
if(BooleanUtils.isTrue(conversation.getIsThousand()) && WsRequestCmdEnum.NORMAL_CHAT == wsRequestPathEnum) {
if(ChatTypeEnum.THOUSAND_GROUP.getCode().equals(conversation.getChatType()) && WsRequestCmdEnum.NORMAL_CHAT == wsRequestPathEnum) {
// 普通群升级为万人群
wsRequestPathEnum = WsRequestCmdEnum.THROUSAND_CHAT;
}
......
......@@ -5,7 +5,7 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id
, create_time, update_time, last_message, member_count, is_thousand, fk_appid, creator, name, attributes, system_flag
, create_time, update_time, last_message, member_count, chat_type, fk_appid, creator, name, attributes, system_flag
</sql>
<select id="getImConversationById" resultType="com.wecloud.im.param.ImConversationQueryVo">
......@@ -24,6 +24,8 @@
SELECT imConversation.id,
imConversation.create_time,
imConversation.`name`,
imConversation.chat_type,
imConversation.member_count,
imConversation.attributes as attribute,
imConversation.system_flag,
im_client.client_id AS creator,
......@@ -112,7 +114,7 @@
</update>
<update id="updateMemberCount">
update im_conversation set is_thousand = 1 where fk_appid = #{appId} and id = #{conversationId}
update im_conversation set chat_type = 3 where fk_appid = #{appId} and id = #{conversationId}
</update>
</mapper>
......@@ -46,7 +46,7 @@
<select id="findThousandGroupsByClientId" resultType="java.lang.Long">
select a.id from im_conversation a
inner join im_conversation_members b on a.id = b.fk_conversation_id
where b.fk_client_id = #{clientId} and a.is_thousand = 1
where b.fk_client_id = #{clientId} and a.chat_type = 3
</select>
</mapper>
......@@ -220,7 +220,7 @@ ALTER TABLE `im_message` CHANGE COLUMN `system` `system_flag` tinyint(1) NULL DE
-- 在feature-cluster 2022年1月4日之后,需要执行的sql增量脚本
ALTER TABLE im_conversation`
ADD COLUMN `member_count` int NULL COMMENT '群成员数' AFTER `last_message`,
ADD COLUMN `is_thousand` tinyint NULL COMMENT '是否万人群' AFTER `member_count`;
ADD COLUMN `chat_type` tinyint NULL COMMENT '是否万人群' AFTER `member_count`;
ALTER TABLE `im_conversation_members` ADD INDEX `fk_client_id`(`fk_client_id`);
-- 在feature-cluster 2022年1月10日之后,需要执行的sql增量脚本
......
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