zouxuan 5 years ago
parent
commit
1cfaadd1fc

+ 3 - 4
mec-auth/mec-auth-api/src/main/java/com/ym/mec/auth/api/entity/SysUser.java

@@ -1,11 +1,10 @@
 package com.ym.mec.auth.api.entity;
 
-import java.util.Date;
-
-import org.apache.commons.lang3.builder.ToStringBuilder;
-
 import com.ym.mec.auth.api.enums.SysUserType;
 import com.ym.mec.common.enums.UserGenderEnum;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import java.util.Date;
 
 /**
  * 对应数据库表(sys_user):

+ 1 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/core/filter/UsernameAuthenticationFilter.java

@@ -11,6 +11,7 @@ import org.springframework.security.authentication.AuthenticationServiceExceptio
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
 import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
 import org.springframework.util.Assert;

+ 1 - 5
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/core/handler/AuthenticationFailureListener.java

@@ -36,11 +36,7 @@ public class AuthenticationFailureListener implements ApplicationListener<Authen
         Date date = new Date();
         SysUser sysUser = null;
         if(username.split(":").length > 1){
-            if(username.startsWith(SecurityConstants.USERNAME_PRINCIPAL_PREFIX)){
-                sysUser = sysUserService.queryByUsername(username.split(":")[1]);
-            }else {
-                sysUser = sysUserService.queryByPhone(username.split(":")[1]);
-            }
+            sysUser = sysUserService.queryByPhone(username.split(":")[1]);
         }
         if(sysUser != null){
             SysUserLogin userLogin = sysUserLoginService.findLoginByUserId(sysUser.getId());

+ 1 - 6
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/core/handler/BaseAuthenticationSuccessEventHandler.java

@@ -63,12 +63,7 @@ public class BaseAuthenticationSuccessEventHandler extends SavedRequestAwareAuth
 		logger.info("用户:{} 登录成功", authentication.getPrincipal());
 		HashMap<String,String> hashMap = objectMapper.convertValue(authentication.getPrincipal(), HashMap.class);
 		String username = hashMap.get("username");
-		SysUser sysUser;
-		if(username.startsWith(SecurityConstants.USERNAME_PRINCIPAL_PREFIX)){
-			sysUser = sysUserService.queryByUsername(username.split(":")[1]);
-		}else {
-			sysUser = sysUserService.queryByPhone(username.split(":")[1]);
-		}
+		SysUser sysUser  = sysUserService.queryByPhone(username.split(":")[1]);
 		Date date = new Date();
 		//修改添加登录信息
 		SysUserLogin userLogin = sysUserLoginService.findLoginByUserId(sysUser.getId());

+ 9 - 3
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/core/provider/PhoneAuthenticationProvider.java

@@ -1,6 +1,12 @@
 package com.ym.mec.auth.core.provider;
 
+import com.alibaba.fastjson.JSON;
+import com.ym.mec.auth.config.constant.SecurityConstants;
+import com.ym.mec.auth.config.token.PhoneAuthenticationToken;
+import com.ym.mec.common.validcode.SmsCodeService;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.security.authentication.BadCredentialsException;
 import org.springframework.security.authentication.InternalAuthenticationServiceException;
 import org.springframework.security.core.Authentication;
@@ -8,9 +14,6 @@ import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.security.core.userdetails.UsernameNotFoundException;
-import com.ym.mec.auth.config.constant.SecurityConstants;
-import com.ym.mec.auth.config.token.PhoneAuthenticationToken;
-import com.ym.mec.common.validcode.SmsCodeService;
 
 public class PhoneAuthenticationProvider extends AbstractAuthenticationProvider {
 
@@ -18,6 +21,8 @@ public class PhoneAuthenticationProvider extends AbstractAuthenticationProvider
 
 	private SmsCodeService smsCodeService;
 
+	@Autowired
+	private RedisTemplate<String,String> redisTemplate;
 	@Override
 	protected void additionalAuthenticationChecks(UserDetails userDetails, Authentication authentication) throws AuthenticationException {
 		if (authentication.getCredentials() == null) {
@@ -54,6 +59,7 @@ public class PhoneAuthenticationProvider extends AbstractAuthenticationProvider
 	protected Authentication createSuccessAuthentication(Object principal, Authentication authentication, UserDetails user) {
 		PhoneAuthenticationToken result = new PhoneAuthenticationToken(principal, authentication.getCredentials(), user.getAuthorities());
 		result.setDetails(authentication.getDetails());
+		redisTemplate.opsForValue().set(user.getUsername(),JSON.toJSONString(user));
 		return result;
 	}
 

+ 1 - 1
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/service/impl/SysUserServiceImpl.java

@@ -45,7 +45,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<Integer, SysUser> implem
 
 	@Override
 	public SysUserInfo queryUserInfoByUsername(String username) {
-		SysUser sysUser = queryByUsername(username);
+		SysUser sysUser = queryByPhone(username);
 		return getSysUserInfo(sysUser);
 	}
 

+ 14 - 9
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/web/controller/UserController.java

@@ -14,6 +14,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.Date;
+import java.util.HashMap;
 
 @RestController()
 @RequestMapping("user")
@@ -39,7 +40,7 @@ public class UserController extends BaseController {
 			@ApiImplicitParam(name = "createStartDate", value = "开始注册时间", required = true, dataType = "String"),
 			@ApiImplicitParam(name = "createEndDate", value = "结束注册时间", required = true, dataType = "String") })
 	@GetMapping("/queryPage")
-	public Object queryPage(SysUserQueryInfo queryInfo) {
+	public Object queryPage(@RequestBody SysUserQueryInfo queryInfo) {
 		return succeed(sysUserService.queryPage(queryInfo));
 	}
 
@@ -51,7 +52,7 @@ public class UserController extends BaseController {
 
 	@ApiOperation(value = "新增用户")
 	@PostMapping("/add")
-	public Object add(SysUser sysUser) {
+	public Object add(@RequestBody SysUser sysUser) {
 		Date date = new Date();
 		sysUser.setCreateTime(date);
 		sysUser.setUpdateTime(date);
@@ -68,7 +69,7 @@ public class UserController extends BaseController {
 
 	@ApiOperation(value = "修改用户")
 	@PutMapping("/update")
-	public Object update(SysUser sysUser) {
+	public Object update(@RequestBody SysUser sysUser) {
 		Date date = new Date();
 		sysUser.setUpdateTime(date);
 		sysUser.setPassword(new BCryptPasswordEncoder().encode(sysUser.getPassword()));
@@ -86,11 +87,13 @@ public class UserController extends BaseController {
 	@ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户编号", required = true, dataType = "Integer"),
 			@ApiImplicitParam(name = "roleIds", value = "角色id,逗号分隔", required = true, dataType = "String") })
 	@PostMapping("/addRole")
-	public Object getRole(Integer userId,String roleIds) {
-		if(userId == null || StringUtils.isEmpty(roleIds)){
+	public Object getRole(@RequestBody HashMap<String,String> param) {
+		String userId = param.get("userId");
+		String roleIds = param.get("roleIds");
+		if(StringUtils.isEmpty(param.get("userId")) || StringUtils.isEmpty(param.get("roleIds"))){
 			return failed(SecurityConstants.PARAM_VERIFY_EXCEPTION);
 		}
-		sysUserRoleService.batchInsert(userId,roleIds);
+		sysUserRoleService.batchInsert(Integer.parseInt(userId),roleIds);
 		return succeed();
 	}
 
@@ -98,11 +101,13 @@ public class UserController extends BaseController {
 	@ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户编号", required = true, dataType = "Integer"),
 			@ApiImplicitParam(name = "roleIds", value = "角色id,逗号分隔", required = true, dataType = "String") })
 	@DeleteMapping("/delRole")
-	public Object delRole(Integer userId,String roleIds) {
-		if(userId == null || StringUtils.isEmpty(roleIds)){
+	public Object delRole(@RequestBody HashMap<String,String> param) {
+		String userId = param.get("userId");
+		String roleIds = param.get("roleIds");
+		if(StringUtils.isEmpty(param.get("userId")) || StringUtils.isEmpty(param.get("roleIds"))){
 			return failed(SecurityConstants.PARAM_VERIFY_EXCEPTION);
 		}
-		sysUserRoleService.batchDel(userId,roleIds);
+		sysUserRoleService.batchDel(Integer.parseInt(userId),roleIds);
 		return succeed();
 	}
 }

+ 11 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/security/SecurityUtils.java

@@ -25,6 +25,17 @@ public class SecurityUtils {
 	/**
 	 * 获取用户
 	 */
+	public static Object getPrincipal() {
+		Authentication authentication = getAuthentication();
+		if (authentication == null) {
+			return null;
+		}
+		return authentication.getPrincipal();
+	}
+
+	/**
+	 * 获取用户
+	 */
 	public static AuthUser getUser() {
 		Authentication authentication = getAuthentication();
 		if (authentication == null) {

+ 2 - 8
mec-im/pom.xml

@@ -58,15 +58,9 @@
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-aop</artifactId>
     </dependency>
-    <!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt -->
-    <!--<dependency>
-      <groupId>io.jsonwebtoken</groupId>
-      <artifactId>jjwt</artifactId>
-      <version>0.7.0</version>
-    </dependency>-->
     <dependency>
-      <groupId>org.springframework.cloud</groupId>
-      <artifactId>spring-cloud-starter-oauth2</artifactId>
+      <groupId>com.ym</groupId>
+      <artifactId>common-core</artifactId>
     </dependency>
     <dependency>
       <groupId>com.alibaba</groupId>

+ 0 - 15
mec-im/src/main/java/com/ym/SealClassConfiguration.java

@@ -41,21 +41,6 @@ public class SealClassConfiguration {
         return new GlobalExceptionHandlerAdvice();
     }
 
-    /*@Bean
-    public JwtTokenHelper jwtTokenHelper() {
-        return jwtProperties.getTtlInMilliSec() == null
-                ? new JwtTokenHelper(jwtProperties.getSecret())
-                : new JwtTokenHelper(jwtProperties.getSecret(), jwtProperties.getTtlInMilliSec());
-    }*/
-
-    /*@Bean
-    public FilterRegistrationBean jwtTokenFilter() {
-        final FilterRegistrationBean registrationBean = new FilterRegistrationBean();
-        registrationBean.setFilter(new JwtFilter());
-        registrationBean.addUrlPatterns("/*");
-        return registrationBean;
-    }*/
-
     @Bean
     public WebMvcConfigurer getWebMvcConfigurerAdapter() {
         return new WebMvcConfigurer() {

+ 0 - 14
mec-im/src/main/java/com/ym/common/JwtUser.java

@@ -1,14 +0,0 @@
-package com.ym.common;
-
-import lombok.Data;
-
-/**
- * Created by weiqinxiao on 2019/2/27.
- */
-@Data
-public class JwtUser {
-    private String userId;
-    private String roomId;
-    private String userName;
-    private int deviceType;
-}

+ 46 - 69
mec-im/src/main/java/com/ym/controller/RoomController.java

@@ -3,7 +3,6 @@ package com.ym.controller;
 import com.ym.common.ApiException;
 import com.ym.common.BaseResponse;
 import com.ym.common.ErrorEnum;
-import com.ym.common.JwtUser;
 import com.ym.pojo.*;
 import com.ym.service.RoomService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,98 +20,87 @@ public class RoomController {
     RoomService roomService;
 
     @RequestMapping(value = "/join", method = RequestMethod.POST)
-    public BaseResponse<RoomResult> joinRoom(@RequestBody ReqUserData data,
-                                             @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<RoomResult> joinRoom(@RequestBody ReqUserData data)
             throws ApiException, Exception {
-        RoomResult roomResult = roomService.joinRoom(data.getUserName(), data.getRoomId(), data.isAudience(), data.isDisableCamera(), jwtUser);
+        RoomResult roomResult = roomService.joinRoom(data.getUserName(), data.getRoomId(), data.isAudience(), data.isDisableCamera());
         return new BaseResponse<>(roomResult);
     }
 
     @RequestMapping(value = "/leave", method = RequestMethod.POST)
-    public BaseResponse<Boolean> leaveRoom(@RequestBody ReqUserData data,
-                                           @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> leaveRoom(@RequestBody ReqUserData data)
             throws ApiException, Exception {
-        boolean result = roomService.leaveRoom(jwtUser, data.getRoomId());
+        boolean result = roomService.leaveRoom(data.getRoomId());
         return new BaseResponse<>(result);
     }
 
     @RequestMapping(value = "/downgrade", method = RequestMethod.POST)
-    public BaseResponse<Boolean> downRole(@RequestBody ReqChangeUserRoleData data,
-                                          @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> downRole(@RequestBody ReqChangeUserRoleData data)
             throws ApiException, Exception {
-        boolean result = roomService.downgrade(data.getRoomId(), jwtUser, data.getUsers());
+        boolean result = roomService.downgrade(data.getRoomId(), data.getUsers());
         return new BaseResponse<>(result);
     }
 
     @RequestMapping(value = "/kick", method = RequestMethod.POST)
-    public BaseResponse<Boolean> kickMember(@RequestBody ReqUserData data,
-                                            @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> kickMember(@RequestBody ReqUserData data)
             throws ApiException, Exception {
-        boolean result = roomService.kickMember(data.getRoomId(), data.getUserId(), jwtUser);
+        boolean result = roomService.kickMember(data.getRoomId(), data.getUserId());
         return new BaseResponse<>(result);
     }
 
     //only teacher
     @RequestMapping(value = "/display", method = RequestMethod.POST)
-    public BaseResponse<Boolean> display(@RequestBody ReqDisplayData data,
-                                         @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> display(@RequestBody ReqDisplayData data)
             throws ApiException, Exception {
-        boolean result = roomService.display(data.getRoomId(), data.getType(), data.getUserId(), data.getUri(), jwtUser);
+        boolean result = roomService.display(data.getRoomId(), data.getType(), data.getUserId(), data.getUri());
         return new BaseResponse<>(result);
     }
 
     @RequestMapping(value = "/whiteboard/create", method = RequestMethod.POST)
-    public BaseResponse<String> createWhiteBoard(@RequestBody ReqWhiteboardData data,
-                                                 @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<String> createWhiteBoard(@RequestBody ReqWhiteboardData data)
             throws ApiException, Exception {
-        String result = roomService.createWhiteBoard(data.getRoomId(), jwtUser);
+        String result = roomService.createWhiteBoard(data.getRoomId());
         return new BaseResponse<>(result);
     }
 
 
     @RequestMapping(value = "/whiteboard/delete", method = RequestMethod.POST)
-    public BaseResponse<Boolean> destroyWhiteBoard(@RequestBody ReqWhiteboardData data,
-                                                   @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> destroyWhiteBoard(@RequestBody ReqWhiteboardData data)
             throws ApiException, Exception {
-        boolean result = roomService.deleteWhiteboard(data.getRoomId(), jwtUser, data.getWhiteboardId());
+        boolean result = roomService.deleteWhiteboard(data.getRoomId(), data.getWhiteboardId());
         return new BaseResponse<>(result);
     }
 
     @RequestMapping(value = "/whiteboard/list", method = RequestMethod.GET)
-    public BaseResponse<List<RoomResult.WhiteboardResult>> getWhiteBoard(@RequestParam String roomId,
-                                                                         @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<List<RoomResult.WhiteboardResult>> getWhiteBoard(@RequestParam String roomId)
             throws ApiException, Exception {
-        List<RoomResult.WhiteboardResult> whiteboards = roomService.getWhiteboard(roomId, jwtUser);
+        List<RoomResult.WhiteboardResult> whiteboards = roomService.getWhiteboard(roomId);
         return new BaseResponse<>(whiteboards);
     }
 
     @RequestMapping(value = "/device/approve", method = RequestMethod.POST)
-    public BaseResponse<Boolean> approveControlDevice(@RequestBody ReqDeviceControlData data,
-                                                      @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> approveControlDevice(@RequestBody ReqDeviceControlData data)
             throws ApiException, Exception {
         boolean result;
-        result = roomService.approveControlDevice(data.getRoomId(), data.getTicket(), jwtUser);
+        result = roomService.approveControlDevice(data.getRoomId(), data.getTicket());
         return new BaseResponse<>(result);
     }
 
     @RequestMapping(value = "/device/reject", method = RequestMethod.POST)
-    public BaseResponse<Boolean> rejectControlDevice(@RequestBody ReqDeviceControlData data,
-                                                      @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> rejectControlDevice(@RequestBody ReqDeviceControlData data)
             throws ApiException, Exception {
         boolean result;
-        result = roomService.rejectControlDevice(data.getRoomId(), data.getTicket(), jwtUser);
+        result = roomService.rejectControlDevice(data.getRoomId(), data.getTicket());
         return new BaseResponse<>(result);
     }
 
     @RequestMapping(value = "/device/control", method = RequestMethod.POST)
-    public BaseResponse<Boolean> controlDevice(@RequestBody ReqDeviceControlData data,
-                                               @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> controlDevice(@RequestBody ReqDeviceControlData data)
             throws ApiException, Exception {
         boolean result;
         if (data.getCameraOn() != null) {
-            result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.Camera, data.getCameraOn(), jwtUser);
+            result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.Camera, data.getCameraOn());
         } else if (data.getMicrophoneOn() != null) {
-            result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.Microphone, data.getMicrophoneOn(), jwtUser);
+            result = roomService.controlDevice(data.getRoomId(), data.getUserId(), DeviceTypeEnum.Microphone, data.getMicrophoneOn());
         } else {
             throw new ApiException(ErrorEnum.ERR_REQUEST_PARA_ERR);
         }
@@ -120,14 +108,13 @@ public class RoomController {
     }
 
     @RequestMapping(value = "/device/sync", method = RequestMethod.POST)
-    public BaseResponse<Boolean> syncDeviceState(@RequestBody ReqDeviceControlData data,
-                                                 @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> syncDeviceState(@RequestBody ReqDeviceControlData data)
             throws ApiException, Exception {
         boolean result;
         if (data.getCameraOn() != null) {
-            result = roomService.syncDeviceState(data.getRoomId(), DeviceTypeEnum.Camera, data.getCameraOn(), jwtUser);
+            result = roomService.syncDeviceState(data.getRoomId(), DeviceTypeEnum.Camera, data.getCameraOn());
         } else if (data.getMicrophoneOn() != null) {
-            result = roomService.syncDeviceState(data.getRoomId(), DeviceTypeEnum.Microphone, data.getMicrophoneOn(), jwtUser);
+            result = roomService.syncDeviceState(data.getRoomId(), DeviceTypeEnum.Microphone, data.getMicrophoneOn());
         } else {
             throw new ApiException(ErrorEnum.ERR_REQUEST_PARA_ERR);
         }
@@ -135,82 +122,72 @@ public class RoomController {
     }
 
     @RequestMapping(value = "/whiteboard/turn-page", method = RequestMethod.POST)
-    public BaseResponse<Boolean> turnPage(@RequestBody ReqWhiteboardData data,
-                                          @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> turnPage(@RequestBody ReqWhiteboardData data)
             throws ApiException, Exception {
-        boolean result = roomService.turnWhiteBoardPage(data.getRoomId(), data.getWhiteboardId(), data.getPage(), jwtUser);
+        boolean result = roomService.turnWhiteBoardPage(data.getRoomId(), data.getWhiteboardId(), data.getPage());
         return new BaseResponse<>(result);
     }
 
     @RequestMapping(value = "/members", method = RequestMethod.GET)
-    public BaseResponse<List<RoomResult.MemberResult>> getMembers(@RequestParam String roomId,
-                                                                  @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<List<RoomResult.MemberResult>> getMembers(@RequestParam String roomId)
             throws ApiException, Exception {
-        List<RoomResult.MemberResult> whiteboards = roomService.getMembers(roomId, jwtUser);
+        List<RoomResult.MemberResult> whiteboards = roomService.getMembers(roomId);
         return new BaseResponse<>(whiteboards);
     }
 
     @RequestMapping(value = "/speech/apply", method = RequestMethod.POST)
-    public BaseResponse<Boolean> apply(@RequestBody ReqSpeechData data,
-                                       @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> apply(@RequestBody ReqSpeechData data)
             throws ApiException, Exception {
-        Boolean result = roomService.applySpeech(data.getRoomId(), jwtUser);
+        Boolean result = roomService.applySpeech(data.getRoomId());
         return new BaseResponse<>(result);
     }
 
     @RequestMapping(value = "/speech/approve", method = RequestMethod.POST)
-    public BaseResponse<Boolean> approval(@RequestBody ReqSpeechData data,
-                                          @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> approval(@RequestBody ReqSpeechData data)
             throws ApiException, Exception {
-        Boolean result = roomService.approveSpeech(data.getRoomId(), data.getTicket(), jwtUser);
+        Boolean result = roomService.approveSpeech(data.getRoomId(), data.getTicket());
         return new BaseResponse<>(result);
     }
 
     @RequestMapping(value = "/speech/reject", method = RequestMethod.POST)
-    public BaseResponse<Boolean> reject(@RequestBody ReqSpeechData data,
-                                        @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> reject(@RequestBody ReqSpeechData data)
             throws ApiException, Exception {
-        Boolean result = roomService.rejectSpeech(data.getRoomId(), data.getTicket(), jwtUser);
+        Boolean result = roomService.rejectSpeech(data.getRoomId(), data.getTicket());
         return new BaseResponse<>(result);
     }
 
     @RequestMapping(value = "/transfer", method = RequestMethod.POST)
-    public BaseResponse<Boolean> transfer(@RequestBody ReqUpgradeRoleData data,
-                                          @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> transfer(@RequestBody ReqUpgradeRoleData data)
             throws ApiException, Exception {
-        Boolean result = roomService.transfer(data.getRoomId(), data.getUserId(), jwtUser);
+        Boolean result = roomService.transfer(data.getRoomId(), data.getUserId());
         return new BaseResponse<>(result);
     }
 
     @RequestMapping(value = "/upgrade/invite", method = RequestMethod.POST)
-    public BaseResponse<Boolean> inviteUpgradeRole(@RequestBody ReqUpgradeRoleData data,
-                                                   @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> inviteUpgradeRole(@RequestBody ReqUpgradeRoleData data)
             throws ApiException, Exception {
-        Boolean result = roomService.inviteUpgradeRole(data.getRoomId(), data.getUserId(), data.getRole(), jwtUser);
+        Boolean result = roomService.inviteUpgradeRole(data.getRoomId(), data.getUserId(), data.getRole());
         return new BaseResponse<>(result);
     }
 
     @RequestMapping(value = "/upgrade/approve", method = RequestMethod.POST)
-    public BaseResponse<Boolean> approveUpgradeRole(@RequestBody ReqUpgradeRoleData data,
-                                                    @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> approveUpgradeRole(@RequestBody ReqUpgradeRoleData data)
             throws ApiException, Exception {
-        Boolean result = roomService.approveUpgradeRole(data.getRoomId(), data.getTicket(), jwtUser);
+        Boolean result = roomService.approveUpgradeRole(data.getRoomId(), data.getTicket());
         return new BaseResponse<>(result);
     }
 
     @RequestMapping(value = "/upgrade/reject", method = RequestMethod.POST)
-    public BaseResponse<Boolean> rejectUpgradeRole(@RequestBody ReqUpgradeRoleData data,
-                                                   @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> rejectUpgradeRole(@RequestBody ReqUpgradeRoleData data)
             throws ApiException, Exception {
-        Boolean result = roomService.rejectUpgradeRole(data.getRoomId(), data.getTicket(), jwtUser);
+        Boolean result = roomService.rejectUpgradeRole(data.getRoomId(), data.getTicket());
         return new BaseResponse<>(result);
     }
 
     @RequestMapping(value = "/change-role", method = RequestMethod.POST)
-    public BaseResponse<Boolean> changeRole(@RequestBody ReqChangeRole data,
-                                            @RequestAttribute JwtUser jwtUser)
+    public BaseResponse<Boolean> changeRole(@RequestBody ReqChangeRole data)
             throws ApiException, Exception {
-        Boolean result = roomService.changeRole(data.getRoomId(), data.getUserId(), data.getRole(), jwtUser);
+        Boolean result = roomService.changeRole(data.getRoomId(), data.getUserId(), data.getRole());
         return new BaseResponse<>(result);
     }
 

+ 0 - 1
mec-im/src/main/java/com/ym/controller/UserController.java

@@ -2,7 +2,6 @@ package com.ym.controller;
 
 import com.ym.common.ApiException;
 import com.ym.common.BaseResponse;
-import com.ym.common.JwtUser;
 import com.ym.pojo.ReqUserData;
 import com.ym.service.UserService;
 import io.rong.models.user.UserModel;

+ 198 - 184
mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java

@@ -1,9 +1,9 @@
 package com.ym.service.Impl;
 
+import com.alibaba.fastjson.JSON;
 import com.ym.common.ApiException;
 import com.ym.common.DisplayEnum;
 import com.ym.common.ErrorEnum;
-import com.ym.common.JwtUser;
 import com.ym.config.IMProperties;
 import com.ym.config.RoomProperties;
 import com.ym.dao.RoomDao;
@@ -13,6 +13,8 @@ import com.ym.dao.WhiteboardDao;
 import com.ym.im.IMHelper;
 import com.ym.im.message.*;
 import com.ym.job.ScheduleManager;
+import com.ym.mec.common.security.AuthUser;
+import com.ym.mec.common.security.SecurityUtils;
 import com.ym.pojo.*;
 import com.ym.service.RoomService;
 import com.ym.utils.CheckUtils;
@@ -21,7 +23,9 @@ import com.ym.utils.DateTimeUtils;
 import com.ym.utils.IdentifierUtils;
 import com.ym.whiteboard.WhiteBoardHelper;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.MapUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -47,9 +51,6 @@ public class RoomServiceImpl implements RoomService {
     @Autowired
     private RoomMemberDao roomMemberDao;
 
-//    @Autowired
-//    private JwtTokenHelper tokenHelper;
-
     @Autowired
     private WhiteBoardHelper whiteBoardHelper;
 
@@ -65,25 +66,23 @@ public class RoomServiceImpl implements RoomService {
     @Autowired
     private IMProperties imProperties;
 
+    @Autowired
+    private RedisTemplate<String,String> redisTemplate;
+
+    private AuthUser getUser(){
+        String principal = SecurityUtils.getPrincipal().toString();
+        String json = redisTemplate.opsForValue().get(principal);
+        return JSON.parseObject(json,AuthUser.class);
+    }
+
     @Transactional
     @Override
-    public RoomResult joinRoom(String userName, String roomId, boolean isAudience, boolean isDisableCamera, JwtUser jwtUser) throws ApiException, Exception {
+    public RoomResult joinRoom(String userName, String roomId, boolean isAudience, boolean isDisableCamera) throws ApiException, Exception {
         CheckUtils.checkArgument(userName != null, "userName must't be null");
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
 
-        log.info("joinRoom: jwtUser={}, roomId={}, userName={}, isAudience={}, isDisableCamera={}", jwtUser, roomId, userName, isAudience, isDisableCamera);
-        String userId;
-        if (jwtUser != null) {
-            userId = jwtUser.getUserId();
-            if (!jwtUser.getUserName().equals(userName) || !jwtUser.getRoomId().equals(roomId)) {
-                userId = IdentifierUtils.uuid();
-                log.info("generate new user: roomId={} , userId={}, userName={}", roomId, userId, userName);
-            } else {
-                log.info("join the old room: roomId={} , userId={}, userName={}", roomId, userId, userName);
-            }
-        } else {
-            userId = IdentifierUtils.uuid();
-        }
+        log.info("joinRoom: roomId={}, userName={}, isAudience={}, isDisableCamera={}", roomId, userName, isAudience, isDisableCamera);
+        String userId = getUser().getUserId().toString();
 
         String display = "";
         Date curTime = DateTimeUtils.currentUTC();
@@ -177,12 +176,6 @@ public class RoomServiceImpl implements RoomService {
         userResult.setRole(roleEnum.getValue());
         roomResult.setUserInfo(userResult);
         roomResult.setDisplay(display);
-
-        //generate authorization
-        jwtUser = new JwtUser();
-        jwtUser.setUserId(userId);
-        jwtUser.setUserName(userName);
-        jwtUser.setRoomId(roomId);
 //        JwtToken jwtToken = tokenHelper.createJwtToken(jwtUser);
         IMTokenInfo tokenInfo = imHelper.getToken(userId, userId, "");
         if (tokenInfo.isSuccess()) {
@@ -224,30 +217,31 @@ public class RoomServiceImpl implements RoomService {
 
     @Transactional
     @Override
-    public Boolean leaveRoom(JwtUser jwtUser, String roomId) throws Exception {
-        CheckUtils.checkArgument(jwtUser.getUserId() != null, "userId must't be null");
+    public Boolean leaveRoom(String roomId) throws Exception {
+        AuthUser user = getUser();
+        
+        CheckUtils.checkArgument(user != null, "user must't be null");
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
-        CheckUtils.checkArgument(roomId.equals(jwtUser.getRoomId()), "roomId not exist");
-
+        String userId = user.getUserId().toString();
         List<Room> roomList = roomDao.findByRid(roomId);
         if (roomList.size() == 0) {
             log.error("room : {} not exist ", roomId);
             throw new ApiException(ErrorEnum.ERR_ROOM_NOT_EXIST);
         }
 
-        List<RoomMember> roomMemberList = roomMemberDao.findByRidAndUid(roomId, jwtUser.getUserId());
+        List<RoomMember> roomMemberList = roomMemberDao.findByRidAndUid(roomId, userId);
         if (roomMemberList.size() == 0) {
-            log.error("{} not exist in room: {}", jwtUser.getUserId(), roomId);
+            log.error("{} not exist in room: {}", userId, roomId);
             throw new ApiException(ErrorEnum.ERR_USER_NOT_EXIST_IN_ROOM);
         }
 
         int userRole = roomMemberList.get(0).getRole();
-        log.info("leaveRoom: roomId={}, {}, role={}", roomId, jwtUser, RoleEnum.getEnumByValue(userRole));
+        log.info("leaveRoom: roomId={}, role={}", roomId, RoleEnum.getEnumByValue(userRole));
 
         if (userRole == RoleEnum.RoleTeacher.getValue() || userRole == RoleEnum.RoleAssistant.getValue()) {
-            if (isUserDisplay(roomList.get(0), jwtUser.getUserId())) {
-                updateDisplay(roomId, jwtUser.getUserId(), "", 0);
-                log.info("clear display cause speaker leave: roomId={}, {}", roomId, jwtUser);
+            if (isUserDisplay(roomList.get(0), userId)) {
+                updateDisplay(roomId, userId, "", 0);
+                log.info("clear display cause speaker leave: roomId={}", roomId);
             } else {
                 log.info("don't update current display: room={}, role={}", roomList.get(0), RoleEnum.getEnumByValue(userRole));
             }
@@ -258,40 +252,40 @@ public class RoomServiceImpl implements RoomService {
         if (roomMemberDao.countByRid(roomId) == 1) {
             IMApiResultInfo apiResultInfo = null;
             try {
-                apiResultInfo = imHelper.dismiss(jwtUser.getUserId(), roomId);
+                apiResultInfo = imHelper.dismiss(userId, roomId);
                 if (apiResultInfo.getCode() == 200) {
-                    roomMemberDao.deleteUserByRidAndUid(roomId, jwtUser.getUserId());
+                    roomMemberDao.deleteUserByRidAndUid(roomId, userId);
                     roomDao.deleteByRid(roomId);
-                    deleteWhiteboardByUser(roomId, jwtUser.getUserId());
+                    deleteWhiteboardByUser(roomId, userId);
                     log.info("dismiss the room: {}", roomId);
                 } else {
-                    log.error("{} exit {} room error: {}", jwtUser.getUserId(), roomId, apiResultInfo.getErrorMessage());
+                    log.error("{} exit {} room error: {}", userId, roomId, apiResultInfo.getErrorMessage());
                     throw new ApiException(ErrorEnum.ERR_EXIT_ROOM_ERROR, apiResultInfo.getErrorMessage());
                 }
             } catch (Exception e) {
-                log.error("{} exit {} room error: {}", jwtUser.getUserId(), roomId, e.getMessage());
+                log.error("{} exit {} room error: {}", userId, roomId, e.getMessage());
                 throw new ApiException(ErrorEnum.ERR_EXIT_ROOM_ERROR, e.getMessage());
             }
         } else {
             IMApiResultInfo apiResultInfo = null;
             try {
-                apiResultInfo = imHelper.quit(new String[]{jwtUser.getUserId()}, roomId);
+                apiResultInfo = imHelper.quit(new String[]{userId}, roomId);
                 if (apiResultInfo.isSuccess()) {
-                    roomMemberDao.deleteUserByRidAndUid(roomId, jwtUser.getUserId());
-                    MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Action_Leave, jwtUser.getUserId(), userRole);
-                    msg.setUserName(jwtUser.getUserName());
-                    imHelper.publishMessage(jwtUser.getUserId(), roomId, msg);
-                    imHelper.quit(new String[]{jwtUser.getUserId()}, roomId);
-                    log.info("quit group: roomId={}, {}", roomId, jwtUser);
+                    roomMemberDao.deleteUserByRidAndUid(roomId, userId);
+                    MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Action_Leave, userId, userRole);
+                    msg.setUserName(user.getUsername());
+                    imHelper.publishMessage(userId, roomId, msg);
+                    imHelper.quit(new String[]{userId}, roomId);
+                    log.info("quit group: roomId={}", roomId);
                 } else {
                     throw new ApiException(ErrorEnum.ERR_EXIT_ROOM_ERROR, apiResultInfo.getErrorMessage());
                 }
             } catch (Exception e) {
-                log.error("leave room error: roomId={}, {}, {}", roomId, jwtUser, e.getMessage());
+                log.error("leave room error: roomId={}, {}", roomId, e.getMessage());
                 throw new ApiException(ErrorEnum.ERR_EXIT_ROOM_ERROR);
             }
         }
-        userDao.deleteByUid(jwtUser.getUserId());
+        userDao.deleteByUid(userId);
 
         return true;
     }
@@ -327,10 +321,11 @@ public class RoomServiceImpl implements RoomService {
 
     @Transactional
     @Override
-    public Boolean downgrade(String roomId, JwtUser jwtUser, List<ReqChangeUserRoleData.ChangedUser> users) throws ApiException, Exception {
+    public Boolean downgrade(String roomId, List<ReqChangeUserRoleData.ChangedUser> users) throws ApiException, Exception {
+        AuthUser authUser = getUser();
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         CheckUtils.checkArgument(users.size() > 0, "the changed user list must't be null");
-
+        String userId = authUser.getUserId().toString();
         List<Room> roomList = roomDao.findByRid(roomId);
         if (roomList.isEmpty()) {
             throw new ApiException(ErrorEnum.ERR_ROOM_NOT_EXIST);
@@ -341,8 +336,8 @@ public class RoomServiceImpl implements RoomService {
         for (ReqChangeUserRoleData.ChangedUser user : users) {
             String changedUserId = user.getUserId();
             RoleEnum changedRole = RoleEnum.getEnumByValue(user.getRole());
-            if (changedUserId.equals(jwtUser.getUserId())) {
-                log.error("can not change self role: {}, {}, {}", roomId, jwtUser.getUserId(), changedRole);
+            if (changedUserId.equals(userId)) {
+                log.error("can not change self role: {}, {}, {}", roomId, userId, changedRole);
                 throw new ApiException(ErrorEnum.ERR_CHANGE_SELF_ROLE);
             } else {
                 List<RoomMember> oldUsers = roomMemberDao.findByRidAndUid(roomId, changedUserId);
@@ -355,35 +350,35 @@ public class RoomServiceImpl implements RoomService {
                             u.setUserName(userInfoList.get(0).getName());
                         }
                         changedUsers.add(u);
-                        log.info("change the role: {}, {}, {}, result: {}", roomId, jwtUser.getUserId(), changedRole, r);
+                        log.info("change the role: {}, {}, {}, result: {}", roomId, userId, changedRole, r);
                         result = true;
                     }
                     if (oldUsers.get(0).getRole() == RoleEnum.RoleTeacher.getValue() && isUserDisplay(roomList.get(0), oldUsers.get(0).getUid())) {
-                        updateDisplay(roomId, jwtUser.getUserId(), "", 1);
+                        updateDisplay(roomId, userId, "", 1);
                     } else {
                         log.info("don't update display: room={}, userRole={}", roomList.get(0), RoleEnum.getEnumByValue(oldUsers.get(0).getRole()));
                     }
                 } else {
-                    log.info("role changed fail, not exist: {} - {} - {}", roomId, jwtUser.getUserId(), changedRole);
+                    log.info("role changed fail, not exist: {} - {} - {}", roomId, userId, changedRole);
                 }
             }
         }
         if (result) {
-            RoleChangedMessage msg = new RoleChangedMessage(jwtUser.getUserId());
+            RoleChangedMessage msg = new RoleChangedMessage(userId);
             msg.setUsers(changedUsers);
-            imHelper.publishMessage(jwtUser.getUserId(), roomId, msg, 1);
+            imHelper.publishMessage(userId, roomId, msg, 1);
         }
         return result;
     }
 
     @Override
-    public Boolean kickMember(String roomId, String userId, JwtUser jwtUser) throws ApiException, Exception {
+    public Boolean kickMember(String roomId, String userId) throws ApiException, Exception {
         CheckUtils.checkArgument(userId != null, "userId must't be null");
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
 
         List<RoomMember> kickedUsers = roomMemberDao.findByRidAndUid(roomId, userId);
         int result = roomMemberDao.deleteUserByRidAndUid(roomId, userId);
-        log.info("kickMember: roomId={}, userId={}, result = {}, {}", roomId, userId, result, jwtUser);
+        log.info("kickMember: roomId={}, userId={}, result = {}", roomId, userId, result);
         if (result == 0) {
             throw new ApiException(ErrorEnum.ERR_USER_NOT_EXIST_IN_ROOM);
         } else {
@@ -392,15 +387,15 @@ public class RoomServiceImpl implements RoomService {
             if (!userInfoList.isEmpty()) {
                 msg.setUserName(userInfoList.get(0).getName());
             }
-            IMApiResultInfo apiResultInfo = imHelper.publishMessage(jwtUser.getUserId(), roomId, msg, 1);
+            IMApiResultInfo apiResultInfo = imHelper.publishMessage(userId, roomId, msg, 1);
             if (!apiResultInfo.isSuccess()) {
                 throw new ApiException(ErrorEnum.ERR_MESSAGE_ERROR);
             }
             Thread.sleep(50);
-            log.info("published msg: {}, msg={}", jwtUser, msg);
+            log.info("published msg: msg={}", msg);
             List<Room> roomList = roomDao.findByRid(roomId);
             if (kickedUsers.get(0).getRole() == RoleEnum.RoleTeacher.getValue() && isUserDisplay(roomList.get(0), userId)) {
-                updateDisplay(roomId, jwtUser.getUserId(), "", 1);
+                updateDisplay(roomId, userId, "", 1);
             } else {
                 log.info("don't update display: room={}, userRole={}", roomId, RoleEnum.getEnumByValue(kickedUsers.get(0).getRole()));
             }
@@ -414,8 +409,8 @@ public class RoomServiceImpl implements RoomService {
     }
 
     @Override
-    public Boolean display(String roomId, int type, String userId, String uri, JwtUser jwtUser) throws ApiException, Exception {
-        log.info("display in room: {}, type = {}, uri = {}, {}", roomId, type, uri, jwtUser);
+    public Boolean display(String roomId, int type, String userId, String uri) throws ApiException, Exception {
+        log.info("display in room: {}, type = {}, uri = {}", roomId, type, uri);
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         CheckUtils.checkArgument(type >= 0 && type < DisplayEnum.values().length, "type not exist");
         DisplayEnum displayEnum = DisplayEnum.values()[type];
@@ -423,7 +418,7 @@ public class RoomServiceImpl implements RoomService {
         if (displayEnum.equals(DisplayEnum.None)) {
             roomDao.updateDisplayByRid(roomId, "");
             DisplayMessage displayMessage = new DisplayMessage("");
-            IMApiResultInfo apiResultInfo = imHelper.publishMessage(jwtUser.getUserId(), roomId, displayMessage);
+            IMApiResultInfo apiResultInfo = imHelper.publishMessage(userId, roomId, displayMessage);
             if (apiResultInfo.isSuccess()) {
                 return true;
             } else {
@@ -440,8 +435,8 @@ public class RoomServiceImpl implements RoomService {
                 display += "?userId=" + teachers.get(0).getUid() + "?uri=";
                 roomDao.updateDisplayByRid(roomId, display);
                 DisplayMessage displayMessage = new DisplayMessage(display);
-                imHelper.publishMessage(jwtUser.getUserId(), roomId, displayMessage);
-                log.info("change display to teacher: roomId={}, {}, display={}", roomId, jwtUser, display);
+                imHelper.publishMessage(userId, roomId, displayMessage);
+                log.info("change display to teacher: roomId={}, display={}", roomId, display);
             }
         } else if (displayEnum.equals(DisplayEnum.Assistant)) {
             List<RoomMember> assistants = roomMemberDao.findByRidAndRole(roomId, RoleEnum.RoleAssistant.getValue());
@@ -451,15 +446,15 @@ public class RoomServiceImpl implements RoomService {
                 display += "?userId=" + assistants.get(0).getUid() + "?uri=";
                 roomDao.updateDisplayByRid(roomId, display);
                 DisplayMessage displayMessage = new DisplayMessage(display);
-                imHelper.publishMessage(jwtUser.getUserId(), roomId, displayMessage);
-                log.info("change display to assistant: roomId={}, {}, display={}", roomId, jwtUser, display);
+                imHelper.publishMessage(userId, roomId, displayMessage);
+                log.info("change display to assistant: roomId={}, display={}", roomId, display);
             }
         } else if (displayEnum.equals(DisplayEnum.Screen)) {
             display += "?userId=" + userId + "?uri=";
             roomDao.updateDisplayByRid(roomId, display);
             DisplayMessage displayMessage = new DisplayMessage(display);
-            imHelper.publishMessage(jwtUser.getUserId(), roomId, displayMessage);
-            log.info("change display to screen: roomId={}, {}, display={}", roomId, jwtUser, display);
+            imHelper.publishMessage(userId, roomId, displayMessage);
+            log.info("change display to screen: roomId={}, display={}", roomId, display);
         } else {
             display += "?userId=" + "?uri=" + uri;
             CheckUtils.checkArgument(uri != null, "uri must't be null");
@@ -467,19 +462,21 @@ public class RoomServiceImpl implements RoomService {
 
             roomDao.updateDisplayByRid(roomId, display);
             DisplayMessage displayMessage = new DisplayMessage(display);
-            imHelper.publishMessage(jwtUser.getUserId(), roomId, displayMessage);
+            imHelper.publishMessage(userId, roomId, displayMessage);
         }
-        log.info("result display in room: {}, type = {}, uri = {}, {}", roomId, type, uri, jwtUser);
+        log.info("result display in room: {}, type = {}, uri = {}", roomId, type, uri);
         return true;
     }
 
     @Override
-    public String createWhiteBoard(String roomId, JwtUser jwtUser) throws ApiException, Exception {
+    public String createWhiteBoard(String roomId) throws ApiException, Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
-        CheckUtils.checkArgument(roomMemberDao.existsByRidAndUid(roomId, jwtUser.getUserId()), "room member not exist");
+        AuthUser authUser = getUser();
+        String userId = authUser.getUserId().toString();
+        CheckUtils.checkArgument(roomMemberDao.existsByRidAndUid(roomId, userId), "room member not exist");
 
-        log.info("createWhiteBoard: roomId = {},  {}", roomId, jwtUser);
+        log.info("createWhiteBoard: roomId = {}", roomId);
 
         String wbRoom = IdentifierUtils.uuid();
         WhiteBoardApiResultInfo resultInfo = whiteBoardHelper.create(wbRoom);
@@ -495,18 +492,18 @@ public class RoomServiceImpl implements RoomService {
             wb.setWbRoom(wbRoom);
             wb.setWbid(wbId);
             wb.setName(name);
-            wb.setCreator(jwtUser.getUserId());
+            wb.setCreator(userId);
             wb.setCreateDt(date);
             wb.setCurPg(0);
             whiteboardDao.save(wb);
             WhiteboardMessage wbmsg = new WhiteboardMessage(WhiteboardMessage.Create);
             wbmsg.setWhiteboardId(wbId);
             wbmsg.setWhiteboardName(name);
-            imHelper.publishMessage(jwtUser.getUserId(), roomId, wbmsg);
-            String display = "display://type=2?userId=" + jwtUser.getUserId() + "?uri=" + wbId;
+            imHelper.publishMessage(userId, roomId, wbmsg);
+            String display = "display://type=2?userId=" + userId + "?uri=" + wbId;
             roomDao.updateDisplayByRid(roomId, display);
             DisplayMessage displayMessage = new DisplayMessage(display);
-            imHelper.publishMessage(jwtUser.getUserId(), roomId, displayMessage, 1);
+            imHelper.publishMessage(userId, roomId, displayMessage, 1);
 
             return wbId;
         } else {
@@ -515,9 +512,11 @@ public class RoomServiceImpl implements RoomService {
     }
 
     @Override
-    public Boolean deleteWhiteboard(String roomId, JwtUser jwtUser, String whiteBoardId) throws ApiException, Exception {
+    public Boolean deleteWhiteboard(String roomId, String whiteBoardId) throws ApiException, Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         CheckUtils.checkArgument(whiteBoardId != null, "whiteBoardId must't be null");
+        AuthUser authUser = getUser();
+        String userId = authUser.getUserId().toString();
 
         List<Whiteboard> whiteboardList = whiteboardDao.findByRidAndWbid(roomId, whiteBoardId);
         CheckUtils.checkArgument(whiteboardList.size() > 0, "whiteboard not exist");
@@ -525,14 +524,14 @@ public class RoomServiceImpl implements RoomService {
         List<Room> roomList = roomDao.findByRid(roomId);
         CheckUtils.checkArgument(!roomList.isEmpty(), "room not exist");
 
-        log.info("deleteWhiteboard: room={}, whiteBoardId={}, {}", roomList.get(0), whiteBoardId, jwtUser);
+        log.info("deleteWhiteboard: room={}, whiteBoardId={}", roomList.get(0), whiteBoardId);
 
         String display = roomList.get(0).getDisplay();
         if (display.contains("uri=" + whiteBoardId)) {
             int result = roomDao.updateDisplayByRid(roomId, "");
             log.info("clear room display, room: {}, result: {}", roomId, result);
             DisplayMessage displayMessage = new DisplayMessage("");
-            imHelper.publishMessage(jwtUser.getUserId(), roomId, displayMessage, 1);
+            imHelper.publishMessage(userId, roomId, displayMessage, 1);
         } else {
             log.info("no display to clean: room={}", roomList.get(0));
         }
@@ -544,7 +543,7 @@ public class RoomServiceImpl implements RoomService {
             log.info("delete whiteboard: roomId = {}, whiteBoardId = {}, result = {}", roomId, whiteBoardId, result);
             WhiteboardMessage wbmsg = new WhiteboardMessage(WhiteboardMessage.Delete);
             wbmsg.setWhiteboardId(whiteBoardId);
-            imHelper.publishMessage(jwtUser.getUserId(), roomId, wbmsg, 1);
+            imHelper.publishMessage(userId, roomId, wbmsg, 1);
             return true;
         } else {
             throw new ApiException(ErrorEnum.ERR_DELETE_WHITE_BOARD, resultInfo.getMsg());
@@ -552,7 +551,7 @@ public class RoomServiceImpl implements RoomService {
     }
 
     @Override
-    public List<RoomResult.WhiteboardResult> getWhiteboard(String roomId, JwtUser jwtUser) throws ApiException, Exception {
+    public List<RoomResult.WhiteboardResult> getWhiteboard(String roomId) throws ApiException, Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
 
@@ -569,28 +568,31 @@ public class RoomServiceImpl implements RoomService {
     }
 
     @Override
-    public Boolean turnWhiteBoardPage(String roomId, String whiteBoardId, int page, JwtUser jwtUser) throws ApiException, Exception {
+    public Boolean turnWhiteBoardPage(String roomId, String whiteBoardId, int page) throws ApiException, Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         CheckUtils.checkArgument(whiteBoardId != null, "whiteBoardId must't be null");
+        AuthUser authUser = getUser();
+        String userId = authUser.getUserId().toString();
         List<Room> roomList = roomDao.findByRid(roomId);
         CheckUtils.checkArgument(!roomList.isEmpty(), "room not exist");
 
         int result = whiteboardDao.updatePageByRidAndWbid(roomId, whiteBoardId, page);
         log.info("turn page to: {}, room: {}, wb : {}; r: {}", page, roomId, whiteBoardId, result);
 
-        TurnPageMessage turnPageMessage = new TurnPageMessage(whiteBoardId, jwtUser.getUserId(), page);
-        imHelper.publishMessage(jwtUser.getUserId(), roomId, turnPageMessage);
+        TurnPageMessage turnPageMessage = new TurnPageMessage(whiteBoardId, userId, page);
+        imHelper.publishMessage(userId, roomId, turnPageMessage);
         return true;
     }
 
     @Override
-    public Boolean controlDevice(String roomId, String userId, DeviceTypeEnum typeEnum, boolean enable, JwtUser jwtUser) throws ApiException, Exception {
+    public Boolean controlDevice(String roomId, String userId, DeviceTypeEnum typeEnum, boolean enable) throws ApiException, Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         CheckUtils.checkArgument(userId != null, "userId must't be null");
         CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
         CheckUtils.checkArgument(roomMemberDao.existsByRidAndUid(roomId, userId), "room member not exist");
+        AuthUser authUser = getUser();
 
-        log.info("controlDevice: {}, userId={}, typeEnum={}, onOff={}", jwtUser, userId, typeEnum, enable);
+        log.info("controlDevice: userId={}, typeEnum={}, onOff={}", userId, typeEnum, enable);
 
         if (enable) {
             String ticket = IdentifierUtils.uuid();
@@ -598,21 +600,21 @@ public class RoomServiceImpl implements RoomService {
             taskInfo.setRoomId(roomId);
             taskInfo.setTypeEnum(typeEnum);
             taskInfo.setOnOff(true);
-            taskInfo.setApplyUserId(jwtUser.getUserId());
+            taskInfo.setApplyUserId(userId);
             taskInfo.setTargetUserId(userId);
             taskInfo.setTicket(ticket);
             scheduleManager.addTask(taskInfo);
             ControlDeviceNotifyMessage msg = new ControlDeviceNotifyMessage(ActionEnum.Invite.ordinal());
             msg.setTicket(ticket);
             msg.setType(taskInfo.getTypeEnum().ordinal());
-            msg.setOpUserId(jwtUser.getUserId());
-            msg.setOpUserName(jwtUser.getUserName());
-            imHelper.publishMessage(jwtUser.getUserId(), userId, roomId, msg);
+            msg.setOpUserId(userId);
+            msg.setOpUserName(authUser.getUsername());
+            imHelper.publishMessage(userId, userId, roomId, msg);
         } else {
             if (typeEnum.equals(DeviceTypeEnum.Camera)) {
-                roomMemberDao.updateCameraByRidAndUid(roomId, jwtUser.getUserId(), false);
+                roomMemberDao.updateCameraByRidAndUid(roomId, userId, false);
             } else {
-                roomMemberDao.updateMicByRidAndUid(roomId, jwtUser.getUserId(), false);
+                roomMemberDao.updateMicByRidAndUid(roomId, userId, false);
             }
             DeviceStateChangedMessage deviceResourceMessage = new DeviceStateChangedMessage(typeEnum.ordinal(), false);
             deviceResourceMessage.setUserId(userId);
@@ -620,70 +622,75 @@ public class RoomServiceImpl implements RoomService {
             if (!userInfoList.isEmpty()) {
                 deviceResourceMessage.setUserName(userInfoList.get(0).getName());
             }
-            imHelper.publishMessage(jwtUser.getUserId(), roomId, deviceResourceMessage, 1);
+            imHelper.publishMessage(userId, roomId, deviceResourceMessage, 1);
         }
         return true;
     }
 
     @Override
-    public Boolean approveControlDevice(String roomId, String ticket, JwtUser jwtUser) throws ApiException, Exception {
+    public Boolean approveControlDevice(String roomId, String ticket) throws ApiException, Exception {
         CheckUtils.checkArgument(ticket != null, "ticket must't be null");
-
-        log.info("approveControlDevice: jwtUser={}, ticket={}", jwtUser, ticket);
+        AuthUser authUser = getUser();
+        String userId = authUser.getUserId().toString();
+        log.info("approveControlDevice: ticket={}", ticket);
         ControlDeviceTaskInfo taskInfo = (ControlDeviceTaskInfo) scheduleManager.executeTask(ticket);
         if (taskInfo.getTypeEnum().equals(DeviceTypeEnum.Camera)) {
-            roomMemberDao.updateCameraByRidAndUid(roomId, jwtUser.getUserId(), taskInfo.isOnOff());
+            roomMemberDao.updateCameraByRidAndUid(roomId, userId, taskInfo.isOnOff());
         } else {
-            roomMemberDao.updateMicByRidAndUid(roomId, jwtUser.getUserId(), taskInfo.isOnOff());
+            roomMemberDao.updateMicByRidAndUid(roomId, userId, taskInfo.isOnOff());
         }
         ControlDeviceNotifyMessage msg = new ControlDeviceNotifyMessage(ActionEnum.Approve.ordinal());
         msg.setType(taskInfo.getTypeEnum().ordinal());
-        msg.setOpUserId(jwtUser.getUserId());
-        msg.setOpUserName(jwtUser.getUserName());
-        imHelper.publishMessage(jwtUser.getUserId(), taskInfo.getApplyUserId(), roomId, msg);
+        msg.setOpUserId(userId);
+        msg.setOpUserName(authUser.getUsername());
+        imHelper.publishMessage(userId, taskInfo.getApplyUserId(), roomId, msg);
 
         DeviceStateChangedMessage deviceResourceMessage = new DeviceStateChangedMessage(taskInfo.getTypeEnum().ordinal(), taskInfo.isOnOff());
-        deviceResourceMessage.setUserId(jwtUser.getUserId());
-        imHelper.publishMessage(jwtUser.getUserId(), roomId, deviceResourceMessage, 1);
+        deviceResourceMessage.setUserId(userId);
+        imHelper.publishMessage(userId, roomId, deviceResourceMessage, 1);
         return true;
     }
 
     @Override
-    public Boolean rejectControlDevice(String roomId, String ticket, JwtUser jwtUser) throws ApiException, Exception {
+    public Boolean rejectControlDevice(String roomId, String ticket) throws ApiException, Exception {
         CheckUtils.checkArgument(ticket != null, "ticket must't be null");
+        AuthUser authUser = getUser();
+        String userId = authUser.getUserId().toString();
 
-        log.info("rejectControlDevice: jwtUser={}, ticket={}", jwtUser, ticket);
+        log.info("rejectControlDevice: ticket={}", ticket);
         ControlDeviceTaskInfo taskInfo = (ControlDeviceTaskInfo) scheduleManager.executeTask(ticket);
         ControlDeviceNotifyMessage msg = new ControlDeviceNotifyMessage(ActionEnum.Reject.ordinal());
         msg.setType(taskInfo.getTypeEnum().ordinal());
-        msg.setOpUserId(jwtUser.getUserId());
-        msg.setOpUserName(jwtUser.getUserName());
-        imHelper.publishMessage(jwtUser.getUserId(), taskInfo.getApplyUserId(), roomId, msg);
+        msg.setOpUserId(userId);
+        msg.setOpUserName(authUser.getUsername());
+        imHelper.publishMessage(userId, taskInfo.getApplyUserId(), roomId, msg);
         return true;
     }
 
     @Override
-    public Boolean syncDeviceState(String roomId, DeviceTypeEnum type, boolean enable, JwtUser jwtUser) throws ApiException, Exception {
+    public Boolean syncDeviceState(String roomId, DeviceTypeEnum type, boolean enable) throws ApiException, Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
+        AuthUser authUser = getUser();
+        String userId = authUser.getUserId().toString();
 
         int result;
         DeviceStateChangedMessage deviceResourceMessage;
         if (type.equals(DeviceTypeEnum.Camera)) {
-            result = roomMemberDao.updateCameraByRidAndUid(roomId, jwtUser.getUserId(), enable);
+            result = roomMemberDao.updateCameraByRidAndUid(roomId, userId, enable);
             deviceResourceMessage = new DeviceStateChangedMessage(type.ordinal(), enable);
         } else {
-            result = roomMemberDao.updateMicByRidAndUid(roomId, jwtUser.getUserId(), enable);
+            result = roomMemberDao.updateMicByRidAndUid(roomId, userId, enable);
             deviceResourceMessage = new DeviceStateChangedMessage(type.ordinal(), enable);
         }
-        deviceResourceMessage.setUserId(jwtUser.getUserId());
-        imHelper.publishMessage(jwtUser.getUserId(), roomId, deviceResourceMessage, 1);
-        log.info("syncDeviceState : {}, {}, result = {}, jwtUser={}", roomId, enable, result, jwtUser);
+        deviceResourceMessage.setUserId(userId);
+        imHelper.publishMessage(userId, roomId, deviceResourceMessage, 1);
+        log.info("syncDeviceState : {}, {}, result = {}", roomId, enable, result);
         return true;
     }
 
     @Override
-    public List<RoomResult.MemberResult> getMembers(String roomId, JwtUser jwtUser) throws ApiException, Exception {
+    public List<RoomResult.MemberResult> getMembers(String roomId) throws ApiException, Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
 
         List<RoomMember> roomMemberList = roomMemberDao.findByRid(roomId);
@@ -693,10 +700,11 @@ public class RoomServiceImpl implements RoomService {
     }
 
     @Override
-    public Boolean applySpeech(String roomId, JwtUser jwtUser) throws ApiException, Exception {
+    public Boolean applySpeech(String roomId) throws ApiException, Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
-
+        AuthUser authUser = getUser();
+        String userId = authUser.getUserId().toString();
         List<RoomMember> assistants = roomMemberDao.findByRidAndRole(roomId, RoleEnum.RoleAssistant.getValue());
         if (assistants.isEmpty()) {
             throw new ApiException(ErrorEnum.ERR_ASSISTANT_NOT_EXIST_IN_ROOM);
@@ -706,18 +714,18 @@ public class RoomServiceImpl implements RoomService {
         ScheduledTaskInfo scheduledTaskInfo = new ScheduledTaskInfo();
         scheduledTaskInfo.setTicket(ticket);
         scheduledTaskInfo.setRoomId(roomId);
-        scheduledTaskInfo.setApplyUserId(jwtUser.getUserId());
+        scheduledTaskInfo.setApplyUserId(userId);
         scheduledTaskInfo.setTargetUserId(assistants.get(0).getUid());
         scheduleManager.addTask(scheduledTaskInfo);
 
-        log.info("applySpeech: task = {}, jwtUser={}", scheduledTaskInfo, jwtUser);
+        log.info("applySpeech: task = {}", scheduledTaskInfo);
 
         ApplyForSpeechMessage msg = new ApplyForSpeechMessage();
         msg.setTicket(ticket);
-        msg.setReqUserId(jwtUser.getUserId());
-        IMApiResultInfo resultInfo = imHelper.publishMessage(jwtUser.getUserId(), assistants.get(0).getUid(), roomId, msg);
+        msg.setReqUserId(userId);
+        IMApiResultInfo resultInfo = imHelper.publishMessage(userId, assistants.get(0).getUid(), roomId, msg);
 
-        log.info("apply for speech: {}, jwtUser = {}, task = {}", roomId, jwtUser, scheduledTaskInfo);
+        log.info("apply for speech: {}, task = {}", roomId, scheduledTaskInfo);
         if (resultInfo.isSuccess()) {
             return true;
         } else {
@@ -726,35 +734,37 @@ public class RoomServiceImpl implements RoomService {
     }
 
     @Override
-    public Boolean approveSpeech(String roomId, String ticket, JwtUser jwtUser) throws ApiException, Exception {
+    public Boolean approveSpeech(String roomId, String ticket) throws ApiException, Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
+        AuthUser authUser = getUser();
+        String userId = authUser.getUserId().toString();
 
         int count = roomMemberDao.countByRidAndExcludeRole(roomId, RoleEnum.RoleAudience.getValue());
         if (count == roomProperties.getMaxCount()) {
-            log.error("approveSpeech error: roomId = {}, jwtUser = {}, ticket={}", roomId, jwtUser, ticket);
+            log.error("approveSpeech error: roomId = {}, ticket={}", roomId, ticket);
             throw new ApiException(ErrorEnum.ERR_OVER_MAX_COUNT);
         }
 
         ScheduledTaskInfo taskInfo = scheduleManager.executeTask(ticket);
-        log.info("approveSpeech: task = {}, jwtUser={}", taskInfo, jwtUser);
+        log.info("approveSpeech: task = {}", taskInfo);
         roomMemberDao.updateRoleByRidAndUid(roomId, taskInfo.getApplyUserId(), RoleEnum.RoleStudent.getValue());
 
         SpeechResultMessage msg = new SpeechResultMessage(SpeechResultMessage.Action_Approve);
         List<UserInfo> userInfoList = userDao.findByUid(taskInfo.getApplyUserId());
-        msg.setOpUserId(jwtUser.getUserId());
-        msg.setOpUserName(jwtUser.getUserName());
+        msg.setOpUserId(userId);
+        msg.setOpUserName(authUser.getUsername());
         msg.setReqUserId(taskInfo.getApplyUserId());
         if (!userInfoList.isEmpty()) {
             msg.setReqUserName(userInfoList.get(0).getName());
         }
         msg.setRole(RoleEnum.RoleStudent.getValue());
-        IMApiResultInfo resultInfo = imHelper.publishMessage(jwtUser.getUserId(), taskInfo.getApplyUserId(), roomId, msg);
+        IMApiResultInfo resultInfo = imHelper.publishMessage(userId, taskInfo.getApplyUserId(), roomId, msg);
         if (!resultInfo.isSuccess()) {
             throw new ApiException(ErrorEnum.ERR_MESSAGE_ERROR, resultInfo.getErrorMessage());
         }
 
-        RoleChangedMessage rcMsg = new RoleChangedMessage(jwtUser.getUserId());
+        RoleChangedMessage rcMsg = new RoleChangedMessage(userId);
         List<RoleChangedMessage.ChangedUser> changedUserList = new ArrayList<>();
         RoleChangedMessage.ChangedUser user = new RoleChangedMessage.ChangedUser(taskInfo.getApplyUserId(), RoleEnum.RoleStudent.getValue());
         if (!userInfoList.isEmpty()) {
@@ -762,24 +772,25 @@ public class RoomServiceImpl implements RoomService {
         }
         changedUserList.add(user);
         rcMsg.setUsers(changedUserList);
-        imHelper.publishMessage(jwtUser.getUserId(), roomId, rcMsg, 1);
+        imHelper.publishMessage(userId, roomId, rcMsg, 1);
 
         return true;
     }
 
     @Override
-    public Boolean rejectSpeech(String roomId, String ticket, JwtUser jwtUser) throws ApiException, Exception {
+    public Boolean rejectSpeech(String roomId, String ticket) throws ApiException, Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
-
+        AuthUser authUser = getUser();
+        String userId = authUser.getUserId().toString();
         ScheduledTaskInfo taskInfo = scheduleManager.executeTask(ticket);
 
-        log.info("rejectSpeech: task = {}, jwtUser={}", taskInfo, jwtUser);
+        log.info("rejectSpeech: task = {}", taskInfo);
         SpeechResultMessage msg = new SpeechResultMessage(SpeechResultMessage.Action_Reject);
-        msg.setOpUserId(jwtUser.getUserId());
-        msg.setOpUserName(jwtUser.getUserName());
+        msg.setOpUserId(userId);
+        msg.setOpUserName(authUser.getUsername());
         msg.setRole(RoleEnum.RoleStudent.getValue());
-        IMApiResultInfo resultInfo = imHelper.publishMessage(jwtUser.getUserId(), taskInfo.getApplyUserId(), roomId, msg);
+        IMApiResultInfo resultInfo = imHelper.publishMessage(userId, taskInfo.getApplyUserId(), roomId, msg);
         if (resultInfo.isSuccess()) {
             return true;
         } else {
@@ -800,37 +811,37 @@ public class RoomServiceImpl implements RoomService {
     }
 
     @Override
-    public Boolean transfer(String roomId, String userId, JwtUser jwtUser) throws ApiException, Exception {
+    public Boolean transfer(String roomId, String userId) throws ApiException, Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         CheckUtils.checkArgument(userId != null, "userId must't be null");
-        CheckUtils.checkArgument(!userId.equals(jwtUser.getUserId()), "can't set self role");
+        CheckUtils.checkArgument(!userId.equals(userId), "can't set self role");
 
-        log.info("transfer: roomId = {}, userId = {}, {}", roomId, userId, jwtUser);
+        log.info("transfer: roomId = {}, userId = {}", roomId, userId);
         List<RoomMember> roomMemberList = roomMemberDao.findByRidAndUid(roomId, userId);
         if (roomMemberList.size() == 0) {
-            log.error("assistant transfer error: {} toUser = {}, opUser={}", roomId, userId, jwtUser.getUserId());
+            log.error("assistant transfer error: {} toUser = {}, opUser={}", roomId, userId, userId);
             throw new ApiException(ErrorEnum.ERR_USER_NOT_EXIST_IN_ROOM);
         }
 
         List<Room> roomList = roomDao.findByRid(roomId);
         if (roomList.size() == 0) {
-            log.error("assistant transfer error: {} toUser = {}, opUser={}", roomId, userId, jwtUser.getUserId());
+            log.error("assistant transfer error: {} toUser = {}, opUser={}", roomId, userId, userId);
             throw new ApiException(ErrorEnum.ERR_ROOM_NOT_EXIST);
         }
 
-        if (isUserDisplay(roomList.get(0), jwtUser.getUserId()) || isUserDisplay(roomList.get(0), userId)) {
-            updateDisplay(roomId, jwtUser.getUserId(), "", 1);
+        if (isUserDisplay(roomList.get(0), userId) || isUserDisplay(roomList.get(0), userId)) {
+            updateDisplay(roomId, userId, "", 1);
         } else {
             log.info("don't update display: room={}", roomList.get(0));
         }
 
-        roomMemberDao.updateRoleByRidAndUid(roomId, jwtUser.getUserId(), RoleEnum.RoleStudent.getValue());
+        roomMemberDao.updateRoleByRidAndUid(roomId, userId, RoleEnum.RoleStudent.getValue());
         roomMemberDao.updateRoleByRidAndUid(roomId, userId, RoleEnum.RoleAssistant.getValue());
 
         AssistantTransferMessage msg = new AssistantTransferMessage();
-        msg.setOpUserId(jwtUser.getUserId());
+        msg.setOpUserId(userId);
         msg.setToUserId(userId);
-        IMApiResultInfo resultInfo = imHelper.publishMessage(jwtUser.getUserId(), roomId, msg, 1);
+        IMApiResultInfo resultInfo = imHelper.publishMessage(userId, roomId, msg, 1);
         if (resultInfo.isSuccess()) {
             return true;
         } else {
@@ -839,13 +850,13 @@ public class RoomServiceImpl implements RoomService {
     }
 
     @Override
-    public Boolean inviteUpgradeRole(String roomId, String targetUserId, int targetRole, JwtUser jwtUser) throws ApiException, Exception {
+    public Boolean inviteUpgradeRole(String roomId, String targetUserId, int targetRole) throws ApiException, Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         CheckUtils.checkArgument(targetUserId != null, "userId must't be null");
-        CheckUtils.checkArgument(!targetUserId.equals(jwtUser.getUserId()), "can't set self role");
         CheckUtils.checkArgument(roomMemberDao.existsByRidAndUid(roomId, targetUserId), "room member not exist");
-
-        log.info("inviteUpgradeRole roomId = {}, targetUserId = {}, targetRole = {}, jwtUser={}", roomId, targetUserId, targetRole, jwtUser);
+        AuthUser authUser = getUser();
+        String userId = authUser.getUserId().toString();
+        log.info("inviteUpgradeRole roomId = {}, targetUserId = {}, targetRole = {}", roomId, targetUserId, targetRole);
 
         List<RoomMember> targetUser = roomMemberDao.findByRidAndUid(roomId, targetUserId);
         if (targetUser.isEmpty()) {
@@ -859,17 +870,17 @@ public class RoomServiceImpl implements RoomService {
         UpgradeRoleTaskInfo taskInfo = new UpgradeRoleTaskInfo();
         taskInfo.setTicket(ticket);
         taskInfo.setRoomId(roomId);
-        taskInfo.setApplyUserId(jwtUser.getUserId());
+        taskInfo.setApplyUserId(userId);
         taskInfo.setTargetUserId(targetUserId);
         taskInfo.setRole(RoleEnum.getEnumByValue(targetRole));
         scheduleManager.addTask(taskInfo);
 
         UpgradeRoleMessage msg = new UpgradeRoleMessage(ActionEnum.Invite.ordinal());
         msg.setTicket(ticket);
-        msg.setOpUserId(jwtUser.getUserId());
-        msg.setOpUserName(jwtUser.getUserName());
+        msg.setOpUserId(userId);
+        msg.setOpUserName(authUser.getUsername());
         msg.setRole(targetRole);
-        IMApiResultInfo resultInfo = imHelper.publishMessage(jwtUser.getUserId(), targetUserId, roomId, msg);
+        IMApiResultInfo resultInfo = imHelper.publishMessage(userId, targetUserId, roomId, msg);
         if (resultInfo.isSuccess()) {
             return true;
         } else {
@@ -878,59 +889,60 @@ public class RoomServiceImpl implements RoomService {
     }
 
     @Override
-    public Boolean approveUpgradeRole(String roomId, String ticket, JwtUser jwtUser) throws ApiException, Exception {
+    public Boolean approveUpgradeRole(String roomId, String ticket) throws ApiException, Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         CheckUtils.checkArgument(ticket != null, "ticket must't be null");
         CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
-        CheckUtils.checkArgument(roomMemberDao.existsByRidAndUid(roomId, jwtUser.getUserId()), "room member not exist");
-
+        AuthUser authUser = getUser();
+        String userId = authUser.getUserId().toString();
         UpgradeRoleTaskInfo taskInfo = (UpgradeRoleTaskInfo) scheduleManager.executeTask(ticket);
-        log.info("approveUpgradeRole roomId = {}, task={}, jwtUser={}", roomId, taskInfo, jwtUser);
+        log.info("approveUpgradeRole roomId = {}, task={}", roomId, taskInfo);
 
-        List<RoomMember> targetUser = roomMemberDao.findByRidAndUid(roomId, jwtUser.getUserId());
+        List<RoomMember> targetUser = roomMemberDao.findByRidAndUid(roomId, userId);
         if (targetUser.isEmpty()) {
             throw new ApiException(ErrorEnum.ERR_USER_NOT_EXIST_IN_ROOM);
         }
-        if (!taskInfo.getTargetUserId().equals(jwtUser.getUserId())) {
+        if (!taskInfo.getTargetUserId().equals(userId)) {
             throw new ApiException(ErrorEnum.ERR_APPLY_TICKET_INVALID);
         }
 
         checkOverMax(roomId, targetUser.get(0), taskInfo.getRole().getValue());
-        roomMemberDao.updateRoleByRidAndUid(roomId, jwtUser.getUserId(), taskInfo.getRole().getValue());
+        roomMemberDao.updateRoleByRidAndUid(roomId, userId, taskInfo.getRole().getValue());
 
         UpgradeRoleMessage msg = new UpgradeRoleMessage(ActionEnum.Approve.ordinal());
-        msg.setOpUserName(jwtUser.getUserName());
-        msg.setOpUserId(jwtUser.getUserId());
+        
+        msg.setOpUserName(authUser.getUsername());
+        msg.setOpUserId(userId);
         msg.setRole(taskInfo.getRole().getValue());
-        IMApiResultInfo resultInfo = imHelper.publishMessage(jwtUser.getUserId(), taskInfo.getApplyUserId(), roomId, msg);
+        IMApiResultInfo resultInfo = imHelper.publishMessage(userId, taskInfo.getApplyUserId(), roomId, msg);
         if (!resultInfo.isSuccess()) {
             throw new ApiException(ErrorEnum.ERR_MESSAGE_ERROR, resultInfo.getErrorMessage());
         }
 
-        RoleChangedMessage rcMsg = new RoleChangedMessage(jwtUser.getUserId());
+        RoleChangedMessage rcMsg = new RoleChangedMessage(userId);
         List<RoleChangedMessage.ChangedUser> changedUserList = new ArrayList<>();
-        RoleChangedMessage.ChangedUser user = new RoleChangedMessage.ChangedUser(jwtUser.getUserId(), taskInfo.getRole().getValue());
-        user.setUserName(jwtUser.getUserName());
+        RoleChangedMessage.ChangedUser user = new RoleChangedMessage.ChangedUser(userId, taskInfo.getRole().getValue());
+        user.setUserName(authUser.getUsername());
         changedUserList.add(user);
         rcMsg.setUsers(changedUserList);
-        imHelper.publishMessage(jwtUser.getUserId(), roomId, rcMsg, 1);
+        imHelper.publishMessage(userId, roomId, rcMsg, 1);
 
         return true;
     }
 
     @Override
-    public Boolean rejectUpgradeRole(String roomId, String ticket, JwtUser jwtUser) throws ApiException, Exception {
+    public Boolean rejectUpgradeRole(String roomId, String ticket) throws ApiException, Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         CheckUtils.checkArgument(ticket != null, "ticket must't be null");
         CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
-        CheckUtils.checkArgument(roomMemberDao.existsByRidAndUid(roomId, jwtUser.getUserId()), "room member not exist");
-
+        AuthUser authUser = getUser();
+        String userId = authUser.getUserId().toString();
         UpgradeRoleTaskInfo taskInfo = (UpgradeRoleTaskInfo) scheduleManager.executeTask(ticket);
         UpgradeRoleMessage msg = new UpgradeRoleMessage(ActionEnum.Reject.ordinal());
-        msg.setOpUserName(jwtUser.getUserName());
-        msg.setOpUserId(jwtUser.getUserId());
+        msg.setOpUserName(authUser.getUsername());
+        msg.setOpUserId(userId);
         msg.setRole(taskInfo.getRole().getValue());
-        IMApiResultInfo resultInfo = imHelper.publishMessage(jwtUser.getUserId(), taskInfo.getApplyUserId(), roomId, msg);
+        IMApiResultInfo resultInfo = imHelper.publishMessage(userId, taskInfo.getApplyUserId(), roomId, msg);
         if (resultInfo.isSuccess()) {
             return true;
         } else {
@@ -939,26 +951,28 @@ public class RoomServiceImpl implements RoomService {
     }
 
     @Override
-    public Boolean changeRole(String roomId, String targetUserId, int targetRole, JwtUser jwtUser) throws ApiException, Exception {
+    public Boolean changeRole(String roomId, String targetUserId, int targetRole) throws ApiException, Exception {
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
         CheckUtils.checkArgument(targetUserId != null, "userId must't be null");
         CheckUtils.checkArgument(roomDao.existsByRid(roomId), "room not exist");
         CheckUtils.checkArgument(RoleEnum.getEnumByValue(targetRole).equals(RoleEnum.RoleTeacher), "only set to teacher");
         CheckUtils.checkArgument(roomMemberDao.existsByRidAndUid(roomId, targetUserId), "room member not exist");
+        AuthUser authUser = getUser();
+        String userId = authUser.getUserId().toString();
 
         List<RoomMember> targetUser = roomMemberDao.findByRidAndUid(roomId, targetUserId);
         if (targetUser.isEmpty()) {
             throw new ApiException(ErrorEnum.ERR_USER_NOT_EXIST_IN_ROOM);
         } else {
             if (!RoleEnum.getEnumByValue(targetUser.get(0).getRole()).equals(RoleEnum.RoleStudent)) {
-                log.error("change role error: {}, targetUserId={}, targetRole = {}", jwtUser, targetUser, RoleEnum.getEnumByValue(targetRole));
+                log.error("change role error: targetUserId={}, targetRole = {}", targetUser, RoleEnum.getEnumByValue(targetRole));
                 throw new ApiException(ErrorEnum.ERR_CHANGE_ROLE);
             }
         }
 
-        log.info("changeRole: roomId={}, {}, targetUserId={}", roomId, jwtUser, targetUserId);
+        log.info("changeRole: roomId={}, targetUserId={}", roomId, targetUserId);
         List<RoleChangedMessage.ChangedUser> changedUserList = new ArrayList<>();
-        RoleChangedMessage msg = new RoleChangedMessage(jwtUser.getUserId());
+        RoleChangedMessage msg = new RoleChangedMessage(userId);
 
         List<RoomMember> teachers = roomMemberDao.findByRidAndRole(roomId, RoleEnum.RoleTeacher.getValue());
         if (!teachers.isEmpty()) {
@@ -981,12 +995,12 @@ public class RoomServiceImpl implements RoomService {
         }
         changedUserList.add(user);
         msg.setUsers(changedUserList);
-        imHelper.publishMessage(jwtUser.getUserId(), roomId, msg, 1);
+        imHelper.publishMessage(userId, roomId, msg, 1);
 
         String display = "display://type=1?userId=" + targetUserId + "?uri=";
         DisplayMessage displayMessage = new DisplayMessage(display);
         roomDao.updateDisplayByRid(roomId, display);
-        imHelper.publishMessage(jwtUser.getUserId(), roomId, displayMessage, 1);
+        imHelper.publishMessage(userId, roomId, displayMessage, 1);
         log.info("changeRole, display changed: roomId={}, {}, targetUserId={}", roomId, display, targetUserId);
 
         return true;

+ 22 - 23
mec-im/src/main/java/com/ym/service/RoomService.java

@@ -1,7 +1,6 @@
 package com.ym.service;
 
 import com.ym.common.ApiException;
-import com.ym.common.JwtUser;
 import com.ym.pojo.DeviceTypeEnum;
 import com.ym.pojo.ReqChangeUserRoleData;
 import com.ym.pojo.ReqMemberOnlineStatus;
@@ -14,52 +13,52 @@ import java.util.List;
  */
 public interface RoomService {
     //everyone
-    public RoomResult joinRoom(String userName, String roomId, boolean isAudience, boolean isDisableCamera, JwtUser jwtUser) throws ApiException, Exception;
+    public RoomResult joinRoom(String userName, String roomId, boolean isAudience, boolean isDisableCamera) throws ApiException, Exception;
 
-    public Boolean leaveRoom(JwtUser jwtUser, String roomId) throws ApiException, Exception;
+    public Boolean leaveRoom(String roomId) throws ApiException, Exception;
 
     //only host
-    public Boolean downgrade(String roomId, JwtUser jwtUser, List<ReqChangeUserRoleData.ChangedUser> users) throws ApiException, Exception;
+    public Boolean downgrade(String roomId, List<ReqChangeUserRoleData.ChangedUser> users) throws ApiException, Exception;
 
-    public Boolean kickMember(String roomId, String userId, JwtUser jwtUser) throws ApiException, Exception;
+    public Boolean kickMember(String roomId, String userId) throws ApiException, Exception;
 
 
     //only teacher
-    public Boolean display(String roomId, int type, String userId, String uri, JwtUser jwtUser) throws ApiException, Exception;
+    public Boolean display(String roomId, int type, String userId, String uri) throws ApiException, Exception;
 
-    public String createWhiteBoard(String roomId, JwtUser jwtUser) throws ApiException, Exception;
+    public String createWhiteBoard(String roomId) throws ApiException, Exception;
 
-    public Boolean deleteWhiteboard(String roomId, JwtUser jwtUser, String whiteBoardId) throws ApiException, Exception;
+    public Boolean deleteWhiteboard(String roomId, String whiteBoardId) throws ApiException, Exception;
 
-    public List<RoomResult.WhiteboardResult> getWhiteboard(String roomId, JwtUser jwtUser) throws ApiException, Exception;
+    public List<RoomResult.WhiteboardResult> getWhiteboard(String roomId) throws ApiException, Exception;
 
-    public Boolean turnWhiteBoardPage(String roomId, String whiteBoardId, int page, JwtUser jwtUser) throws ApiException, Exception;
+    public Boolean turnWhiteBoardPage(String roomId, String whiteBoardId, int page) throws ApiException, Exception;
 
-    public Boolean controlDevice(String roomId, String userId, DeviceTypeEnum type, boolean enable, JwtUser jwtUser) throws ApiException, Exception;
+    public Boolean controlDevice(String roomId, String userId, DeviceTypeEnum type, boolean enable) throws ApiException, Exception;
 
-    public Boolean approveControlDevice(String roomId, String ticket, JwtUser jwtUser) throws ApiException, Exception;
+    public Boolean approveControlDevice(String roomId, String ticket) throws ApiException, Exception;
 
-    public Boolean rejectControlDevice(String roomId, String ticket, JwtUser jwtUser) throws ApiException, Exception;
+    public Boolean rejectControlDevice(String roomId, String ticket) throws ApiException, Exception;
 
 
-    public List<RoomResult.MemberResult> getMembers(String roomId, JwtUser jwtUser) throws  ApiException, Exception;
+    public List<RoomResult.MemberResult> getMembers(String roomId) throws  ApiException, Exception;
 
-    public Boolean applySpeech(String roomId, JwtUser jwtUser) throws  ApiException, Exception;
+    public Boolean applySpeech(String roomId) throws  ApiException, Exception;
 
-    public Boolean approveSpeech(String roomId, String requestId, JwtUser jwtUser) throws  ApiException, Exception;
+    public Boolean approveSpeech(String roomId, String requestId) throws  ApiException, Exception;
 
-    public Boolean rejectSpeech(String roomId, String requestId, JwtUser jwtUser) throws  ApiException, Exception;
+    public Boolean rejectSpeech(String roomId, String requestId) throws  ApiException, Exception;
 
 
-    public Boolean transfer(String roomId, String userId, JwtUser jwtUser) throws ApiException, Exception;
+    public Boolean transfer(String roomId, String userId) throws ApiException, Exception;
 
-    public Boolean inviteUpgradeRole(String roomId, String userId, int role, JwtUser jwtUser) throws  ApiException, Exception;
-    public Boolean approveUpgradeRole(String roomId, String ticket, JwtUser jwtUser) throws ApiException, Exception;
-    public Boolean rejectUpgradeRole(String roomId, String ticket, JwtUser jwtUser) throws ApiException, Exception;
+    public Boolean inviteUpgradeRole(String roomId, String userId, int role) throws  ApiException, Exception;
+    public Boolean approveUpgradeRole(String roomId, String ticket) throws ApiException, Exception;
+    public Boolean rejectUpgradeRole(String roomId, String ticket) throws ApiException, Exception;
 
-    public Boolean syncDeviceState(String roomId, DeviceTypeEnum type, boolean enable, JwtUser jwtUser) throws ApiException, Exception;
+    public Boolean syncDeviceState(String roomId, DeviceTypeEnum type, boolean enable) throws ApiException, Exception;
 
-    public Boolean changeRole(String roomId, String userId, int role, JwtUser jwtUser) throws ApiException, Exception;
+    public Boolean changeRole(String roomId, String userId, int role) throws ApiException, Exception;
 
     public void destroyRoom(String roomId);
     public Boolean memberOnlineStatus(List<ReqMemberOnlineStatus> statusList, String nonce, String timestamp, String signature) throws ApiException, Exception;

+ 0 - 5
mec-web/pom.xml

@@ -23,11 +23,6 @@
 
 		<dependency>
 			<groupId>org.springframework.cloud</groupId>
-			<artifactId>spring-cloud-starter-oauth2</artifactId>
-		</dependency>
-
-		<dependency>
-			<groupId>org.springframework.cloud</groupId>
 			<artifactId>spring-cloud-starter-security</artifactId>
 		</dependency>