liujc 1 gadu atpakaļ
vecāks
revīzija
a4a188bdfc

+ 38 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/teacher/controller/ImGroupController.java

@@ -33,8 +33,10 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Objects;
+import java.util.Set;
 
 /**
  * 即时通讯群组(ImGroup)表控制层
@@ -74,6 +76,42 @@ public class ImGroupController extends BaseController {
         return succeed();
     }
 
+    @ApiOperation("创建群聊")
+    @PostMapping(value = "/create/v2")
+    public HttpResponseResult createV2(@Valid @RequestBody ImGroupWrapper.ImGroup imGroup, BindingResult bindingResult) throws Exception {
+
+        // 将imUserId 转为userId
+        Set<String> imUserIdList = imGroup.getImUserIdList();
+
+        Set<Long> studentIdList = new HashSet<>();
+        for (String imUserId : imUserIdList) {
+            studentIdList.add(Long.parseLong(imGroupService.analysisImUserId(imUserId)));
+        }
+        imGroup.setStudentIdList(studentIdList);
+
+        ValidationKit.ignoreFields(bindingResult,"id");
+        imGroup.setCreateBy(sysUserService.getUserId());
+        imGroupService.create(imGroup);
+        return succeed();
+    }
+
+    @ApiOperation("添加群成员")
+    @PostMapping(value = "/addGroupMember/v2")
+    public HttpResponseResult addGroupMemberV2(@Valid @RequestBody ImGroupWrapper.ImGroup imGroup,
+                                               BindingResult bindingResult) throws Exception {
+        // 将imUserId 转为userId
+        Set<String> imUserIdList = imGroup.getImUserIdList();
+
+        Set<Long> studentIdList = new HashSet<>();
+        for (String imUserId : imUserIdList) {
+            studentIdList.add(Long.parseLong(imGroupService.analysisImUserId(imUserId)));
+        }
+        imGroup.setStudentIdList(studentIdList);
+
+        imGroupService.addGroupMember(imGroup.getGroupId(), imGroup.getStudentIdList());
+        return succeed();
+    }
+
     @ApiOperation("解散群聊")
     @PostMapping(value = "/dismiss/{groupId}")
     public HttpResponseResult dismiss(@ApiParam(value = "群编号", required = true) @PathVariable("groupId") String groupId) throws Exception {

+ 38 - 0
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/ImGroupController.java

@@ -28,8 +28,10 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.validation.Valid;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Objects;
+import java.util.Set;
 
 /**
  * 即时通讯群组(ImGroup)表控制层
@@ -69,6 +71,42 @@ public class ImGroupController extends BaseController {
         return succeed();
     }
 
+    @ApiOperation("创建群聊")
+    @PostMapping(value = "/create/v2")
+    public HttpResponseResult createV2(@Valid @RequestBody ImGroupWrapper.ImGroup imGroup, BindingResult bindingResult) throws Exception {
+
+        // 将imUserId 转为userId
+        Set<String> imUserIdList = imGroup.getImUserIdList();
+
+        Set<Long> studentIdList = new HashSet<>();
+        for (String imUserId : imUserIdList) {
+            studentIdList.add(Long.parseLong(imGroupService.analysisImUserId(imUserId)));
+        }
+        imGroup.setStudentIdList(studentIdList);
+
+        ValidationKit.ignoreFields(bindingResult,"id");
+        imGroup.setCreateBy(sysUserService.getUserId());
+        imGroupService.create(imGroup);
+        return succeed();
+    }
+
+    @ApiOperation("添加群成员")
+    @PostMapping(value = "/addGroupMember/v2")
+    public HttpResponseResult addGroupMemberV2(@Valid @RequestBody ImGroupWrapper.ImGroup imGroup,
+                                               BindingResult bindingResult) throws Exception {
+        // 将imUserId 转为userId
+        Set<String> imUserIdList = imGroup.getImUserIdList();
+
+        Set<Long> studentIdList = new HashSet<>();
+        for (String imUserId : imUserIdList) {
+            studentIdList.add(Long.parseLong(imGroupService.analysisImUserId(imUserId)));
+        }
+        imGroup.setStudentIdList(studentIdList);
+
+        imGroupService.addGroupMember(imGroup.getGroupId(), imGroup.getStudentIdList());
+        return succeed();
+    }
+
     @ApiOperation("解散群聊")
     @PostMapping(value = "/dismiss/{groupId}")
     public HttpResponseResult dismiss(@ApiParam(value = "群编号", required = true) @PathVariable("groupId") String groupId) throws Exception {