|
@@ -2,25 +2,26 @@ package com.yonge.cooleshow.student.controller;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.ImUserFriend;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.ImUserStateSync;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.MK;
|
|
|
import com.yonge.cooleshow.biz.dal.service.ImGroupService;
|
|
|
import com.yonge.cooleshow.biz.dal.service.ImUserFriendService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.LiveRoomService;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.im.ImUserFriendVO;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.im.ImUserWrapper;
|
|
|
import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
import io.swagger.annotations.*;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.text.MessageFormat;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
@@ -33,70 +34,25 @@ import java.util.Objects;
|
|
|
*/
|
|
|
@Api(tags = "用户通讯录表")
|
|
|
@RestController
|
|
|
-@RequestMapping("/imUserFriend")
|
|
|
-public class ImUserFriendController extends BaseController {
|
|
|
- /**
|
|
|
- * 服务对象
|
|
|
- */
|
|
|
- @Resource
|
|
|
- private ImUserFriendService imUserFriendService;
|
|
|
- @Resource
|
|
|
- private SysUserFeignService sysUserFeignService;
|
|
|
+@Slf4j
|
|
|
+@RequestMapping("/user")
|
|
|
+public class UserController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
- private ImGroupService imGroupService;
|
|
|
-
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "search", dataType = "String", value = "根据用户编号、昵称模糊查询")
|
|
|
- })
|
|
|
- @ApiOperation("获取通讯录成员列表")
|
|
|
- @PostMapping(value = "/queryAll")
|
|
|
- public HttpResponseResult<List<ImUserWrapper.ImUserFriend>> queryAll(@RequestBody Map<String,Object> params) throws Exception {
|
|
|
+ private LiveRoomService liveRoomService;
|
|
|
|
|
|
- // 用户ID
|
|
|
- SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
- if (Objects.isNull(sysUser)) {
|
|
|
- return failed("请登录");
|
|
|
- }
|
|
|
|
|
|
- // 学生好友列表
|
|
|
- List<ImUserWrapper.ImUserFriend> userFriends = imUserFriendService.findUserAllImFriendInfo(ClientEnum.STUDENT, sysUser.getId(), params);
|
|
|
|
|
|
- /*Object search = params.get("search");
|
|
|
- List<ImUserFriend> userFriends = imUserFriendService.getBaseMapper().selectList(Wrappers.<ImUserFriend>query().lambda()
|
|
|
- .and(Objects.nonNull(search) && StringUtils.isNotEmpty(search.toString()),
|
|
|
- e->e.eq(ImUserFriend::getFriendId, search).or()
|
|
|
- .like(ImUserFriend::getFriendNickname, search))
|
|
|
- .eq(ImUserFriend::getUserId,sysUser.getId()).orderByDesc(ImUserFriend::getId));
|
|
|
-
|
|
|
- for (ImUserFriend item : userFriends) {
|
|
|
- // 学生目前添加好友都为老师
|
|
|
- item.clientType(ClientEnum.TEACHER)
|
|
|
- .setImFriendId(MessageFormat.format("{0}", String.valueOf(item.getFriendId())));
|
|
|
- }*/
|
|
|
-
|
|
|
- return succeed(userFriends);
|
|
|
+ /**
|
|
|
+ * 同步融云用户状态变更
|
|
|
+ *
|
|
|
+ * @param userState
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/statusImUser")
|
|
|
+ public void statusImUser(@RequestBody List<ImUserStateSync> userState) {
|
|
|
+ log.info("opsRoom >>>>> : {}", JSONObject.toJSONString(userState));
|
|
|
+ liveRoomService.opsRoom(userState);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation("获取好友详情")
|
|
|
- @PostMapping(value = "/getDetail/{userId}")
|
|
|
- public HttpResponseResult<ImUserFriendVO.ImUserFriend> getDetail(@ApiParam(value = "用户编号", required = true) @PathVariable("userId") String userId) {
|
|
|
-
|
|
|
- String ret = imGroupService.analysisImUserId(userId);
|
|
|
- if (!ret.matches(MK.EXP_INT)) {
|
|
|
- return failed("无效的用户ID");
|
|
|
- }
|
|
|
-
|
|
|
- ImUserFriend userFriend = imUserFriendService.getDetail(userId, ClientEnum.STUDENT);
|
|
|
- if (Objects.isNull(userFriend)) {
|
|
|
- return failed("当前好友不存在");
|
|
|
- }
|
|
|
-
|
|
|
- if (Objects.isNull(userFriend.getFriendType())) {
|
|
|
- userFriend.setFriendType(ClientEnum.TEACHER);
|
|
|
- }
|
|
|
-
|
|
|
- return succeed(ImUserFriendVO.ImUserFriend.from(JSON.toJSONString(userFriend)));
|
|
|
- }
|
|
|
}
|
|
|
|