|
@@ -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 {
|