瀏覽代碼

add:租户

yonge 5 年之前
父節點
當前提交
8ffd6a39f0

+ 20 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/core/handler/BaseAuthenticationSuccessEventHandler.java

@@ -12,6 +12,8 @@ import javax.servlet.http.HttpServletResponse;
 import com.ym.mec.common.entity.ImResult;
 import com.ym.mec.common.entity.ImUserModel;
 import com.ym.mec.im.ImFeignService;
+import com.ym.mec.im.UserFeignService;
+
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -58,6 +60,9 @@ public class BaseAuthenticationSuccessEventHandler extends SavedRequestAwareAuth
 	private ImFeignService imFeignService;
 	
 	@Autowired
+	private UserFeignService userFeignService;
+	
+	@Autowired
 	private ClientDetailsService clientDetailsService;
 
 	@Autowired
@@ -128,6 +133,21 @@ public class BaseAuthenticationSuccessEventHandler extends SavedRequestAwareAuth
 			Map<String,Object> map = new HashMap<>(3);
 			map.put("password", StringUtils.isEmpty(sysUser.getPassword())?false:true);
 			map.put("authentication",oAuth2AccessToken);
+			
+			String tenantId = "1";
+			if (StringUtils.equalsIgnoreCase(clientId, "TEACHER")) {
+				// 查询老师所在分部
+				Integer organId = userFeignService.queryTeacherOrganId(sysUser.getId());
+				if (organId == 43) {
+					tenantId = "2";
+				}
+			} else if (StringUtils.equalsIgnoreCase(clientId, "STUDENT")) {
+				if (sysUser.getOrganId() == 43) {
+					tenantId = "2";
+				}
+			}
+			map.put("tenantId", tenantId);
+			
 			response.setContentType("application/json; charset=utf-8");
 			HttpResponseResult result = new HttpResponseResult(true, HttpStatus.OK.value(), map, "");
 			response.getWriter().write(objectMapper.writeValueAsString(result));

+ 3 - 0
mec-client-api/src/main/java/com/ym/mec/im/UserFeignService.java

@@ -12,4 +12,7 @@ public interface UserFeignService {
 
 	@RequestMapping(value = "api/createCashAccount")
 	Boolean createCashAccount(@RequestParam("userId") Integer userId);
+	
+	@RequestMapping(value = "api/queryTeacherOrganId")
+	public Integer queryTeacherOrganId(@RequestParam("userId") Integer userId);
 }

+ 7 - 1
mec-client-api/src/main/java/com/ym/mec/im/fallback/UserFeignServiceFallback.java

@@ -10,4 +10,10 @@ public class UserFeignServiceFallback implements UserFeignService {
 	@Override
 	public Boolean createCashAccount(Integer userId) {
 		return false;
-	}}
+	}
+
+	@Override
+	public Integer queryTeacherOrganId(Integer userId) {
+		return null;
+	}
+}

+ 20 - 4
mec-web/src/main/java/com/ym/mec/web/controller/APIController.java

@@ -1,15 +1,19 @@
 package com.ym.mec.web.controller;
 
-import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
-import com.ym.mec.biz.dal.entity.SysUserCashAccount;
-import com.ym.mec.biz.service.PracticeLessonApplyService;
-import com.ym.mec.common.controller.BaseController;
 import io.swagger.annotations.Api;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
+import com.ym.mec.biz.dal.dao.TeacherDao;
+import com.ym.mec.biz.dal.entity.SysUserCashAccount;
+import com.ym.mec.biz.dal.entity.Teacher;
+import com.ym.mec.biz.service.PracticeLessonApplyService;
+import com.ym.mec.common.controller.BaseController;
+
 @RequestMapping("api")
 @Api(tags = "对外接口")
 @RestController
@@ -17,6 +21,9 @@ public class APIController extends BaseController {
 
 	@Autowired
 	private SysUserCashAccountDao sysUserCashAccountDao;
+	
+	@Autowired
+	private TeacherDao teacherDao;
 
 	@Autowired
 	private PracticeLessonApplyService practiceLessonApplyService;
@@ -29,6 +36,15 @@ public class APIController extends BaseController {
 		return true;
 	}
 
+	@GetMapping("/queryTeacherOrganId")
+	public Integer queryTeacherOrganId(Integer userId) {
+		Teacher teacher = teacherDao.get(userId);
+		if (teacher != null) {
+			return teacher.getOrganId();
+		}
+		return null;
+	}
+
 	@GetMapping("/practiceSum")
 	public Object practiceSum() {
 		return succeed(practiceLessonApplyService.practiceSum());