Browse Source

增加一个监听用户状态变更的方法

hgw 3 years ago
parent
commit
0e8d876219
1 changed files with 14 additions and 4 deletions
  1. 14 4
      mec-im/src/main/java/com/ym/controller/UserController.java

+ 14 - 4
mec-im/src/main/java/com/ym/controller/UserController.java

@@ -1,12 +1,11 @@
 package com.ym.controller;
 package com.ym.controller;
 
 
+import com.alibaba.fastjson.JSON;
+import com.ym.pojo.ImUserState;
 import com.ym.service.UserService;
 import com.ym.service.UserService;
 import io.rong.models.user.UserModel;
 import io.rong.models.user.UserModel;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 
 @RestController
 @RestController
 @RequestMapping("/user")
 @RequestMapping("/user")
@@ -19,8 +18,19 @@ public class UserController {
     public Object register(@RequestBody UserModel userModel) throws Exception {
     public Object register(@RequestBody UserModel userModel) throws Exception {
         return userService.register(userModel);
         return userService.register(userModel);
     }
     }
+
     @RequestMapping(value = "/update", method = RequestMethod.POST)
     @RequestMapping(value = "/update", method = RequestMethod.POST)
     public Object update(@RequestBody UserModel userModel) throws Exception {
     public Object update(@RequestBody UserModel userModel) throws Exception {
         return userService.update(userModel);
         return userService.update(userModel);
     }
     }
+
+    /**
+     * 监听融云用户状态变更
+     *
+     * @param userState
+     */
+    @PostMapping(value = "/statusImUser")
+    public void statusImMsg(@RequestBody ImUserState userState) {
+        JSON.toJSONString(userState);
+    }
 }
 }