Ver código fonte

登录时候 查询角色集合

zhangc 8 meses atrás
pai
commit
6fe76b10d9

+ 7 - 4
src/main/java/com/sunxung/factoring/service/sys/impl/AuthorityServiceImpl.java

@@ -6,7 +6,9 @@ import java.util.List;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.google.common.collect.Lists;
 import com.sunxung.factoring.component.enums.ClientTypeEnum;
+import com.sunxung.factoring.entity.sys.*;
 import com.sunxung.factoring.service.sys.dto.LoginResultDto;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -20,10 +22,6 @@ import com.sunxung.factoring.component.util.StringUtil;
 import com.sunxung.factoring.component.util.SystemVariable;
 import com.sunxung.factoring.component.util.ThreadLocalUtil;
 import com.sunxung.factoring.dict.impl.LogTypeDict;
-import com.sunxung.factoring.entity.sys.LoginLog;
-import com.sunxung.factoring.entity.sys.Session;
-import com.sunxung.factoring.entity.sys.User;
-import com.sunxung.factoring.entity.sys.UserRoleRel;
 import com.sunxung.factoring.mapper.sys.AuthorityMapper;
 import com.sunxung.factoring.service.sys.AuthorityService;
 import com.sunxung.factoring.service.sys.DictionaryService;
@@ -81,12 +79,17 @@ public class AuthorityServiceImpl implements AuthorityService {
             if (null == roleIdList || roleIdList.size() == 0) {
                 throw new ValidatorException(CodeUtil.FAIL, "您暂时还无法登录系统,请联系管理分配一个角色");
             }
+            List<Role> roles = Lists.newArrayList();
             for (UserRoleRel role : roleIdList) {
                 if (role.isAdmin()) {
                     entiy.setAdmin(true);
                     break;
+                }else{
+                    Role roleDO = roleService.get(role.getRoleId());
+                    roles.add(roleDO);
                 }
             }
+            entiy.setRoles(roles);
         }
         if (entiy == null || !PasswordUtil.validatePassword(password, entiy.getPassword())) {
             throw new ValidatorException(CodeUtil.FAIL, "账号或密码错误");