From efdb99f8cecc4afb592afad79c761081d5d5cf22 Mon Sep 17 00:00:00 2001
From: lee <4766465@qq.com>
Date: Wed, 18 Dec 2024 13:27:00 +0800
Subject: [PATCH] init

---
 yami-shop-api/src/main/java/com/yami/shop/api/controller/im/LuckImGroupController.java |  210 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 210 insertions(+), 0 deletions(-)

diff --git a/yami-shop-api/src/main/java/com/yami/shop/api/controller/im/LuckImGroupController.java b/yami-shop-api/src/main/java/com/yami/shop/api/controller/im/LuckImGroupController.java
new file mode 100644
index 0000000..cd43e85
--- /dev/null
+++ b/yami-shop-api/src/main/java/com/yami/shop/api/controller/im/LuckImGroupController.java
@@ -0,0 +1,210 @@
+package com.yami.shop.api.controller.im;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.yami.shop.bean.model.*;
+import com.yami.shop.bean.param.im.*;
+import com.yami.shop.common.bean.AliOss;
+import com.yami.shop.common.bean.HuaWeiOss;
+import com.yami.shop.common.config.Constant;
+import com.yami.shop.common.response.ServerResponseEntity;
+import com.yami.shop.security.api.util.SecurityUtils;
+import com.yami.shop.service.*;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 用户聊天群组管理
+ *
+ */
+@RestController
+@RequestMapping("/p/imGroup")
+@Tag(name = "聊天群组管理")
+public class LuckImGroupController {
+
+    @Autowired
+    private ILuckImGroupService luckImGroupService;
+
+    @Autowired
+    private ILuckImGroupTypeService luckImGroupTypeService;
+
+    @Autowired
+    private ILuckImGroupMemberService luckImGroupMemberService;
+
+
+    @Autowired
+    private QRCodeService qrCodeService;
+
+    @Autowired
+    private SysConfigService sysConfigService;
+
+
+    @Operation(summary = "获取所有群组类型")
+    @GetMapping(value = "/getGroupTypes")
+    public ServerResponseEntity<List<LuckImGroupType>> getGroupTypes() {
+    	List<LuckImGroupType> list = luckImGroupTypeService.list(new QueryWrapper<LuckImGroupType>().eq("status",1).orderByAsc("sort"));
+        return ServerResponseEntity.success(list);
+    }
+
+    @Operation(summary = "获取群组列表")
+    @GetMapping(value = "/getGroupList")
+    public ServerResponseEntity<Page<LuckImGroup>> getGroupList(GetGroupListParam params) {
+    	params.setSelfUserId(SecurityUtils.getUser().getUserId());
+        Page<LuckImGroup> groupList = luckImGroupService.getGroupList(params);
+        return ServerResponseEntity.success(groupList);
+    }
+
+    @Operation(summary = "获取群组详情")
+    @GetMapping(value = "/getGroupById")
+    public ServerResponseEntity<LuckImGroup> getGroupById(@RequestParam String groupId) {
+        LuckImGroup groupInfo = luckImGroupService.getGroupById(groupId);
+        return ServerResponseEntity.success(groupInfo);
+    }
+
+    @Operation(summary = "查看群成员")
+    @GetMapping(value = "/getGroupMembers")
+    public ServerResponseEntity<List<LuckImGroupMember>> getGroupMembers(GetGroupMembersParam params) {
+    	params.setSelfUserId(SecurityUtils.getUser().getUserId());
+    	List<LuckImGroupMember> members = luckImGroupService.getGroupMembers(params);
+        return ServerResponseEntity.success(members);
+    }
+
+    @Operation(summary = "查看群成员信息")
+    @GetMapping(value = "/getGroupMemberInfo")
+    public ServerResponseEntity<LuckImGroupMember> getGroupMemberInfo(@RequestParam String groupId,@RequestParam String userId) {
+        if (StringUtils.isBlank(userId)) {
+            userId = SecurityUtils.getUser().getUserId();
+        }
+        LuckImGroupMember member = luckImGroupMemberService.getOne(Wrappers.lambdaQuery(LuckImGroupMember.class)
+                .eq(LuckImGroupMember::getGroupId, groupId)
+                .eq(LuckImGroupMember::getUserId,userId));
+        return ServerResponseEntity.success(member);
+    }
+
+    @Operation(summary = "创建群组")
+    @PostMapping(value = "/createGroup")
+    public ServerResponseEntity<Object> createGroup(@RequestBody CreateGroupParam params) {
+    	params.setSelfUserId(SecurityUtils.getUser().getUserId());
+    	luckImGroupService.createGroup(params);
+        return ServerResponseEntity.success();
+    }
+
+    @Operation(summary = "解散群组")
+    @PostMapping(value = "/dissolveGroup")
+    public ServerResponseEntity<Object> dissolveGroup(@RequestBody DissolveGroupParam params) {
+    	params.setSelfUserId(SecurityUtils.getUser().getUserId());
+    	luckImGroupService.dissolveGroup(params);
+        return ServerResponseEntity.success();
+    }
+
+    @Operation(summary = "修改群组信息")
+    @PostMapping(value = "/updateGroup")
+    public ServerResponseEntity<Object> updateGroup(@RequestBody UpdateGroupParam params) {
+    	params.setSelfUserId(SecurityUtils.getUser().getUserId());
+    	luckImGroupService.updateGroup(params);
+        return ServerResponseEntity.success();
+    }
+
+    @Operation(summary = "设置群组管理")
+    @PostMapping(value = "/setGroupAdmin")
+    public ServerResponseEntity<Object> setGroupAdmin(@RequestBody SetGroupAdminParam params) {
+    	params.setSelfUserId(SecurityUtils.getUser().getUserId());
+    	luckImGroupService.setGroupAdmin(params);
+        return ServerResponseEntity.success();
+    }
+
+    @Operation(summary = "转让群组")
+    @PostMapping(value = "/transferGroup")
+    public ServerResponseEntity<Object> transferGroup(@RequestBody TransferGroupParam params) {
+    	params.setSelfUserId(SecurityUtils.getUser().getUserId());
+    	luckImGroupService.transferGroup(params);
+        return ServerResponseEntity.success();
+    }
+
+    @Operation(summary = "申请加入群组")
+    @PostMapping(value = "/joinGroup")
+    public ServerResponseEntity<Object> joinGroup(@RequestBody JoinGroupParam params) {
+    	params.setSelfUserId(SecurityUtils.getUser().getUserId());
+    	luckImGroupService.joinGroup(params);
+        return ServerResponseEntity.success();
+    }
+
+    @Operation(summary = "邀请加入群组")
+    @PostMapping(value = "/inviteJoinGroup")
+    public ServerResponseEntity<Object> inviteJoinGroup(@RequestBody InviteJoinGroupParam params) {
+    	params.setSelfUserId(SecurityUtils.getUser().getUserId());
+    	luckImGroupService.inviteJoinGroup(params);
+        return ServerResponseEntity.success();
+    }
+
+    @Operation(summary = "群管理审核成员")
+    @PostMapping(value = "/auditMember")
+    public ServerResponseEntity<Object> auditMember(@RequestBody AuditMemberParam params) {
+    	params.setSelfUserId(SecurityUtils.getUser().getUserId());
+    	luckImGroupService.auditMember(params);
+        return ServerResponseEntity.success();
+    }
+
+    @Operation(summary = "退出群组")
+    @PostMapping(value = "/exitGroup")
+    public ServerResponseEntity<Object> exitGroup(@RequestBody ExitGroupParam params) {
+    	params.setSelfUserId(SecurityUtils.getUser().getUserId());
+    	luckImGroupService.exitGroup(params);
+        return ServerResponseEntity.success();
+    }
+
+    @Operation(summary = "提人出群组")
+    @PostMapping(value = "/kickMember")
+    public ServerResponseEntity<Object> kickMember(@RequestBody KickMemberParam params) {
+    	params.setSelfUserId(SecurityUtils.getUser().getUserId());
+    	luckImGroupService.kickMember(params);
+        return ServerResponseEntity.success();
+    }
+
+
+    @Operation(summary = "生成群聊二维码")
+    @GetMapping(value = "/createGroupQrCode")
+    public ServerResponseEntity<String> createGroupQrCode(@RequestParam String groupId) {
+        HuaWeiOss aliOss = sysConfigService.getSysConfigObject(Constant.HUAWEI_OBS_CONFIG, HuaWeiOss.class);
+        LuckImGroup luckImGroup = luckImGroupService.getOne(new QueryWrapper<LuckImGroup>().eq("id", groupId));
+        if (StringUtils.isNotBlank(luckImGroup.getQrCode())){
+            return ServerResponseEntity.success(luckImGroup.getQrCode());
+        }
+        String content = "/pages/im/chatInfo/chatInfo?groupId=" + groupId;
+    	String qrCodeUrl = qrCodeService.generateQRCodeUrl(content, aliOss);
+        luckImGroupService.update(Wrappers.lambdaUpdate(LuckImGroup.class).set(LuckImGroup::getQrCode, qrCodeUrl).eq(LuckImGroup::getId, groupId));
+        return ServerResponseEntity.success(qrCodeUrl);
+    }
+
+    @Operation(summary = "设置群用户发言状态")
+    @PostMapping(value = "/setBannedToPost")
+    public ServerResponseEntity<Object> setBannedToPost(@RequestBody BannedToPostParam bannedToPostParam) {
+        if (bannedToPostParam.getBannedType() == 0) {
+            luckImGroupMemberService.update(Wrappers.lambdaUpdate(LuckImGroupMember.class)
+                    .set(LuckImGroupMember::getBannedToPost, bannedToPostParam.getBannedToPost())
+                    .set(LuckImGroupMember::getUpdateTime, new Date())
+                    .set(LuckImGroupMember::getAuditUserId, SecurityUtils.getUser().getUserId())
+                    .eq(LuckImGroupMember::getGroupId, bannedToPostParam.getGroupId())
+                    .eq(LuckImGroupMember::getUserId, bannedToPostParam.getUserId()));
+        }else{
+            luckImGroupMemberService.update(Wrappers.lambdaUpdate(LuckImGroupMember.class)
+                    .set(LuckImGroupMember::getBannedToPost, bannedToPostParam.getBannedToPost())
+                    .set(LuckImGroupMember::getUpdateTime, new Date())
+                    .set(LuckImGroupMember::getAuditUserId, SecurityUtils.getUser().getUserId())
+                    .eq(LuckImGroupMember::getGroupId, bannedToPostParam.getGroupId())
+                    .eq(LuckImGroupMember::getRole,1));
+            luckImGroupService.update(Wrappers.lambdaUpdate(LuckImGroup.class)
+                    .set(LuckImGroup::getBannedToPost,bannedToPostParam.getBannedToPost())
+                    .set(LuckImGroup::getUpdateTime, new Date())
+                    .eq(LuckImGroup::getId, bannedToPostParam.getGroupId()));
+        }
+        return ServerResponseEntity.success();
+    }
+}

--
Gitblit v1.9.3