zhangheng 3 سال پیش
والد
کامیت
a929418f1b
1فایلهای تغییر یافته به همراه14 افزوده شده و 0 حذف شده
  1. 14 0
      server/src/main/java/edp/davinci/core/inteceptor/AuthenticationInterceptor.java

+ 14 - 0
server/src/main/java/edp/davinci/core/inteceptor/AuthenticationInterceptor.java

@@ -20,8 +20,10 @@
 package edp.davinci.core.inteceptor;
 
 import edp.davinci.dao.RelRoleUserMapper;
+import edp.davinci.dao.RelUserOrganizationMapper;
 import edp.davinci.dto.userDto.UserRegist;
 import edp.davinci.model.RelRoleUser;
+import edp.davinci.model.RelUserOrganization;
 import edp.davinci.service.RoleService;
 import org.apache.commons.lang.StringUtils;
 import com.alibaba.fastjson.JSON;
@@ -65,6 +67,9 @@ public class AuthenticationInterceptor implements HandlerInterceptor
     private RelRoleUserMapper relRoleUserMapper;
 
     @Autowired
+    private RelUserOrganizationMapper relUserOrganizationMapper;
+
+    @Autowired
     private RestTemplate restTemplate;
 
     @Autowired
@@ -150,10 +155,19 @@ public class AuthenticationInterceptor implements HandlerInterceptor
                 userRegist.setEmail(userinfoObject.getString("email"));
                 userRegist.setPassword(userinfoObject.getString("password"));
                 User registUser = userService.regist(userRegist);
+
+                // Role
                 RelRoleUser relRoleUser = new RelRoleUser();
                 relRoleUser.setRoleId(1L);
                 relRoleUser.setUserId(registUser.getId());
                 relRoleUserMapper.insert(relRoleUser);
+
+                // Organization
+                RelUserOrganization relUserOrganization = new RelUserOrganization();
+                relUserOrganization.setUserId(registUser.getId());
+                relUserOrganization.setOrgId(1L);
+                relUserOrganization.setRole(Short.parseShort("1"));
+                relUserOrganizationMapper.insert(relUserOrganization);
             }
             request.setAttribute(Constants.CURRENT_USER, user);
         }