UserController.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package com.ym.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.ym.common.BaseResponse;
  4. import com.ym.mec.biz.service.ImLiveBroadcastRoomService;
  5. import com.ym.mec.common.entity.ImUserState;
  6. import com.ym.service.UserService;
  7. import io.rong.models.user.UserModel;
  8. import org.slf4j.Logger;
  9. import org.slf4j.LoggerFactory;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.*;
  12. import java.util.List;
  13. @RestController
  14. @RequestMapping("/user")
  15. public class UserController {
  16. private static final Logger log = LoggerFactory.getLogger(UserController.class);
  17. @Autowired
  18. private UserService userService;
  19. @Autowired
  20. private ImLiveBroadcastRoomService imLiveBroadcastRoomService;
  21. @RequestMapping(value = "/register", method = RequestMethod.POST)
  22. public Object register(@RequestBody UserModel userModel) throws Exception {
  23. return userService.register(userModel);
  24. }
  25. @RequestMapping(value = "/update", method = RequestMethod.POST)
  26. public Object update(@RequestBody UserModel userModel) throws Exception {
  27. return userService.update(userModel);
  28. }
  29. /**
  30. * 监听融云用户状态变更
  31. *
  32. * @param userState
  33. */
  34. @PostMapping(value = "/statusImUser")
  35. public BaseResponse statusImUser(@RequestBody List<ImUserState> userState) {
  36. log.info("statusImUser >>>>> : {}", JSONObject.toJSONString(userState));
  37. imLiveBroadcastRoomService.opsRoom(userState);
  38. return new BaseResponse<>();
  39. }
  40. }