package work.soho.chat.biz.controller.client;
import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageSerializable;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.util.MimeType;
import org.springframework.util.MimeTypeUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import work.soho.admin.common.security.userdetails.SohoUserDetails;
import work.soho.api.admin.request.BetweenCreatedTimeRequest;
import work.soho.chat.api.ChatMessage;
import work.soho.chat.api.payload.RealTimeCmd;
import work.soho.chat.api.payload.SystemMessage;
import work.soho.chat.biz.domain.*;
import work.soho.chat.biz.enums.ChatGroupUserEnums;
import work.soho.chat.biz.enums.ChatSessionEnums;
import work.soho.chat.biz.enums.ChatSessionUserEnums;
import work.soho.chat.biz.req.*;
import work.soho.chat.biz.service.*;
import work.soho.chat.biz.vo.ChatGroupVO;
import work.soho.chat.biz.vo.GroupQuestionsVo;
import work.soho.chat.biz.vo.GroupVO;
import work.soho.chat.biz.vo.MyGroupVO;
import work.soho.common.core.result.R;
import work.soho.common.core.util.BeanUtils;
import work.soho.common.core.util.StringUtils;
import work.soho.common.data.upload.utils.UploadUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* 群组客户端控制器
*/
@Api(tags = "客户端群组客户端控制器")
@Log4j2
@RestController
@RequiredArgsConstructor
@RequestMapping("/chat/chat/chat-group")
public class ClientChatGroupController {
private final ChatUserService chatUserService;
private final ChatGroupService chatGroupService;
private final ChatGroupUserService chatGroupUserService;
private final ChatGroupApplyService chatGroupApplyService;
private final ChatUserNoticeService chatUserNoticeService;
private final ChatSessionService chatSessionService;
private final ChatSessionUserService chatSessionUserService;
private final ChatService chatService;
private final ChatGroupQuestionsService chatGroupQuestionsService;
/**
* 群组列表/群组搜索用接口
*
* @param chatGroup
* @param keyword
* @param betweenCreatedTimeRequest
* @param sohoUserDetails
* @return
*/
@GetMapping("/list")
public R<PageSerializable<GroupVO>> list(ChatGroup chatGroup,String keyword, BetweenCreatedTimeRequest betweenCreatedTimeRequest,@AuthenticationPrincipal SohoUserDetails sohoUserDetails)
{
LambdaQueryWrapper<ChatGroup> lqw = new LambdaQueryWrapper<ChatGroup>();
//关键字搜索
if(StringUtils.isNotBlank(keyword)) {
lqw.like(ChatGroup::getTitle, keyword + "%");
lqw.or().like(ChatGroup::getId, keyword);
}
lqw.eq(chatGroup.getId() != null, ChatGroup::getId ,chatGroup.getId());
lqw.like(StringUtils.isNotBlank(chatGroup.getTitle()),ChatGroup::getTitle ,chatGroup.getTitle());
lqw.eq(chatGroup.getType() != null, ChatGroup::getType ,chatGroup.getType());
lqw.eq(chatGroup.getMasterChatUid() != null, ChatGroup::getMasterChatUid ,chatGroup.getMasterChatUid());
lqw.like(StringUtils.isNotBlank(chatGroup.getAvatar()),ChatGroup::getAvatar ,chatGroup.getAvatar());
lqw.like(StringUtils.isNotBlank(chatGroup.getIntroduction()),ChatGroup::getIntroduction ,chatGroup.getIntroduction());
lqw.like(StringUtils.isNotBlank(chatGroup.getProclamation()),ChatGroup::getProclamation ,chatGroup.getProclamation());
lqw.eq(chatGroup.getUpdatedTime() != null, ChatGroup::getUpdatedTime ,chatGroup.getUpdatedTime());
lqw.ge(betweenCreatedTimeRequest!=null && betweenCreatedTimeRequest.getStartTime() != null, ChatGroup::getCreatedTime, betweenCreatedTimeRequest.getStartTime());
lqw.lt(betweenCreatedTimeRequest!=null && betweenCreatedTimeRequest.getEndTime() != null, ChatGroup::getCreatedTime, betweenCreatedTimeRequest.getEndTime());
List<ChatGroup> list = chatGroupService.list(lqw);
//计算已经加入的群
List<Long> resultGroupIds = list.stream().map(ChatGroup::getId).collect(Collectors.toList());
resultGroupIds.add(0l);
LambdaQueryWrapper<ChatGroupUser> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
lambdaQueryWrapper1.in(ChatGroupUser::getGroupId, resultGroupIds)
.eq(ChatGroupUser::getChatUid, sohoUserDetails.getId());
List<ChatGroupUser> groupUsers = chatGroupUserService.list(lambdaQueryWrapper1);
List<GroupVO> result = new ArrayList<>();
list.forEach(item->{
GroupVO chatGroupVO = BeanUtils.copy(item, GroupVO.class);
Optional<ChatGroupUser> optional = groupUsers.stream().filter(u->{return u.getGroupId().equals(item.getId());}).findFirst();
chatGroupVO.setInGroup(optional.isPresent());
result.add(chatGroupVO);
});
return R.success(new PageSerializable<>(result));
}
/**
* 我的群列表
*
* @param chatGroup
* @param betweenCreatedTimeRequest
* @return
*/
@GetMapping("/my-list")
public R<PageSerializable<MyGroupVO>> myList(ChatGroup chatGroup, BetweenCreatedTimeRequest betweenCreatedTimeRequest,@AuthenticationPrincipal SohoUserDetails sohoUserDetails)
{
LambdaQueryWrapper<ChatGroupUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ChatGroupUser::getChatUid, sohoUserDetails.getId());
List<ChatGroupUser> groupUsers = chatGroupUserService.list(lambdaQueryWrapper);
List<Long> groupIds = groupUsers.stream().map(ChatGroupUser::getGroupId).collect(Collectors.toList());
groupIds.add(0l);
LambdaQueryWrapper<ChatGroup> lqw = new LambdaQueryWrapper<ChatGroup>();
lqw.in(ChatGroup::getId, groupIds);
List<ChatGroup> list = chatGroupService.list(lqw);
//计算已经加入的群
List<MyGroupVO> result = new ArrayList<>();
list.forEach(item->{
MyGroupVO chatGroupVO = BeanUtils.copy(item, MyGroupVO.class);
Optional<ChatGroupUser> optional = groupUsers.stream().filter(u->{return u.getGroupId().equals(item.getId());}).findFirst();
if(optional.isPresent()) {
chatGroupVO.setNotesName(optional.get().getNotesName());
chatGroupVO.setIsAdmin(optional.get().getIsAdmin());
if(chatGroupVO.getIsAdmin() == 0 && item.getMasterChatUid().equals(sohoUserDetails.getId())) {
chatGroupVO.setIsAdmin(1);
}
}
result.add(chatGroupVO);
});
return R.success(new PageSerializable<>(result));
}
/**
* 创建群组
*
* @param createGroupReq
* @return
*/
@PostMapping("")
public R<ChatSession> create(@RequestBody CreateGroupReq createGroupReq, @AuthenticationPrincipal SohoUserDetails sohoUserDetails) {
ChatGroup chatGroup = new ChatGroup();
chatGroup.setTitle(createGroupReq.getTitle());
chatGroup.setMasterChatUid(sohoUserDetails.getId());
chatGroup.setUpdatedTime(LocalDateTime.now());
chatGroup.setCreatedTime(LocalDateTime.now());
List<Long> chatUserIds = createGroupReq.getChatUserIds();
chatGroupService.createGroup(chatGroup, chatUserIds);
//同步群组数据到会话
LambdaQueryWrapper<ChatGroupUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ChatGroupUser::getGroupId, chatGroup.getId());
List<ChatGroupUser> chatGroupUsers = chatGroupUserService.list(lambdaQueryWrapper);
//创建会话信息
ChatSession chat
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目是一款基于Spring Boot框架开发的简易管理后台,采用Java和Shell脚本语言编写,源码文件共计970个。其中,Java源文件739个,XML配置文件111个,Markdown文档31个,SQL脚本16个,IntelliJ IDEA项目文件16个,Git忽略文件13个,YAML配置文件8个,Shell脚本6个,PNG图片6个,属性文件5个。系统主要功能涵盖菜单管理、用户管理、权限管理、角色管理、鉴权机制,并集成了基础组件库,旨在提供便捷的运维管理体验。
资源推荐
资源详情
资源评论
收起资源包目录
基于Spring Boot的Java+Shell开发soho管理后台设计源码 (965个子文件)
Dockerfile 4KB
Dockerfile 543B
Dockerfile 401B
Dockerfile 158B
spring.factories 118B
spring.factories 118B
spring.factories 114B
.gitignore 400B
.gitignore 395B
.gitignore 395B
.gitignore 395B
.gitignore 395B
.gitignore 241B
.gitignore 58B
.gitignore 53B
.gitignore 38B
.gitignore 18B
.gitignore 18B
.gitignore 17B
.gitignore 5B
.gitignore 0B
soho-common-test.iml 205B
soho-common-bom.iml 205B
soho-chat-biz.iml 205B
soho-user-api.iml 205B
soho-user.iml 205B
soho-content.iml 205B
soho-content-biz.iml 205B
soho-groovy-api.iml 205B
soho-groovy.iml 205B
soho-groovy-biz.iml 205B
soho-long-link-biz.iml 205B
soho-long-link.iml 205B
soho-long-link-api.iml 205B
soho-code-api.iml 205B
soho-code-biz.iml 205B
soho-code.iml 205B
ClientChatGroupController.java 29KB
ClientChatSessionController.java 26KB
CodeTableController.java 16KB
ApprovalProcessOrderServiceImpl.java 15KB
ChatSessionServiceImpl.java 15KB
TemporalTableColServiceImpl.java 13KB
ClientChatUserController.java 12KB
ApprovalProcessOrderController.java 11KB
UploadFileServiceImpl.java 10KB
AdminUserController.java 10KB
ExampleCategoryController.java 9KB
ClientChatUserFriendController.java 9KB
CodeTableVo.java 9KB
ClientChatGroupApplyController.java 9KB
AdminResourceController.java 9KB
ExampleController.java 9KB
AdminNotificationController.java 9KB
DbServiceImpl.java 8KB
CodeTableTemplateGroupController.java 8KB
ClientChatUserNoticeController.java 7KB
ClientChatUserFriendApplyController.java 7KB
LotModelController.java 7KB
ChatGroupServiceImpl.java 7KB
CodeTableTemplateController.java 7KB
DefaultExcelView.java 7KB
AdminContentCategoryController.java 7KB
ClientUserController.java 7KB
OpenAi.java 7KB
OpenAi.java 7KB
LotProductController.java 7KB
OpenExampleController.java 6KB
UserExampleController.java 6KB
AdminUserServiceImpl.java 6KB
ClientContentController.java 6KB
AdminRoleController.java 6KB
TemporalCategoryController.java 6KB
ChatServiceImpl.java 6KB
GroovyServiceTest.java 5KB
AdminResourceServiceImpl.java 5KB
TemporalTableColController.java 5KB
ChatUserController.java 5KB
ChatSessionController.java 5KB
UserInfoController.java 5KB
PayOrderServiceImpl.java 5KB
ClientChatFriendQuestionsController.java 5KB
NumberCardEventListener.java 5KB
GroovyInfoController.java 5KB
CodeTableServiceImpl.java 5KB
AdminJobController.java 5KB
IpUtils.java 5KB
TokenServiceImpl.java 5KB
SecurityConfig.java 5KB
PayInfoController.java 5KB
ExampleCategory.java 5KB
AliyunAi.java 5KB
AdminReleaseController.java 5KB
CodeTableColumnController.java 5KB
LongArrayPropertyEditor.java 5KB
SohoAuthenticationProvider.java 4KB
InvokeUtil.java 4KB
GroovyGroupController.java 4KB
AdminConfigController.java 4KB
NinePatchAvatarGeneratorUtils.java 4KB
共 965 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
lly202406
- 粉丝: 3054
- 资源: 5529
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于形状匹配的剃须刀刀片检测与缺陷分析的完整Halcon例程代码和示例图像文件
- 西门子博途1500双驱同步,伺服同步运行程序,3轴码垛博途程序,scl项目,同步轴走PN工艺对象,其他两轴走Epos控制,PN通讯,程序90%采用scl编程,大量成熟功能块重复调用,结构化编程,结构框
- 酷我音乐-电脑版.zip
- C/C++大作业:实现《球球大作战》小游戏,附完整代码
- SXU-计算机网络实验报告及拓扑图
- C语言基础理论习题及简单的数据结构习题
- 基于SpringBoot和Vue的就业招聘管理系统
- 私域流量池从0到1搭建指南
- SSL证书格式转换工具
- 彩虹聚合DNS管理系统源码V2.0.1,SSL证书自动申请与部署
- 预计2030年全球车载双目立体相机市场规模将达到4.1亿美元
- 在win32汇编环境中,在richedit控件中显示文本或添加文本
- 预计2030年全球触媒陶瓷滤管市场规模将达到39.8亿美元
- 基于springboot的家乡特色推荐系统源码(java毕业设计完整源码+LW).zip
- 预计2030年全球家用无线路由器市场规模将达到45.8亿美元
- 遛狗无牵绳检测数据集VOC+YOLO格式
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功