|
@@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.google.common.reflect.TypeToken;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.qmth.boot.core.enums.Platform;
|
|
|
+import com.qmth.boot.tools.signature.SignatureType;
|
|
|
+import com.qmth.teachcloud.common.SignatureEntityTest;
|
|
|
import com.qmth.teachcloud.common.bean.auth.AuthBean;
|
|
|
import com.qmth.teachcloud.common.bean.auth.ExpireTimeBean;
|
|
|
import com.qmth.teachcloud.common.bean.dto.MenuDto;
|
|
@@ -111,7 +113,7 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
LinkedMultiValueMap<Long, MenuDto> linkedMultiValueMap = new LinkedMultiValueMap<>();
|
|
|
List<MenuPrivilegeDto> menuPrivilegeDtoList = new ArrayList<>();
|
|
|
for (MenuDto m : menuDtoList) {
|
|
|
- if (Objects.isNull(m.getParentId()) || m.getType() == PrivilegeEnum.MENU || m.getType() == PrivilegeEnum.TAB) {
|
|
|
+ if (Objects.isNull(m.getParentId()) || m.getType() == PrivilegeEnum.MENU) {
|
|
|
menuPrivilegeDtoList.add(gson.fromJson(gson.toJson(m), MenuPrivilegeDto.class));
|
|
|
} else {
|
|
|
if (!linkedMultiValueMap.containsKey(m.getParentId())) {
|
|
@@ -125,14 +127,9 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
}
|
|
|
for (MenuPrivilegeDto m : menuPrivilegeDtoList) {
|
|
|
List<MenuDto> menuDtos = linkedMultiValueMap.get(m.getId());
|
|
|
- List<MenuDto> urls = null, tabs = null, buttons = null, links = null, lists = null, conditions = null;
|
|
|
+ List<MenuDto> urls = null, buttons = null, links = null, lists = null, conditions = null;
|
|
|
if (Objects.nonNull(menuDtos)) {
|
|
|
for (MenuDto menuDto : menuDtos) {
|
|
|
-// if (menuDto.getType() == PrivilegeEnum.TAB) {
|
|
|
-// tabs = Objects.isNull(buttons) ? new ArrayList<>() : tabs;
|
|
|
-// tabs.add(gson.fromJson(gson.toJson(menuDto), MenuPrivilegeDto.class));
|
|
|
-// m.setTabs(buttons);
|
|
|
-// } else
|
|
|
if (menuDto.getType() == PrivilegeEnum.BUTTON) {
|
|
|
buttons = Objects.isNull(buttons) ? new ArrayList<>() : buttons;
|
|
|
buttons.add(gson.fromJson(gson.toJson(menuDto), MenuPrivilegeDto.class));
|
|
@@ -740,10 +737,16 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
String token = SystemConstant.getUuid();
|
|
|
cacheService.userCache(sysUser.getId());
|
|
|
//添加用户会话缓存
|
|
|
- Set<String> roleNames = authBean.getRoleList().stream().map(s -> s.getName()).collect(Collectors.toSet());
|
|
|
+ Set<String> roleNames = new HashSet<>(), roleTypes = new HashSet<>();
|
|
|
+ for (SysRole s : authBean.getRoleList()) {
|
|
|
+ roleNames.add(s.getName());
|
|
|
+ if (Objects.nonNull(s.getType())) {
|
|
|
+ roleTypes.add(s.getType().name());
|
|
|
+ }
|
|
|
+ }
|
|
|
String sessionId = SessionUtil.digest(sysUser.getId(), Math.abs(roleNames.toString().hashCode()), platform.name());
|
|
|
//TODO 测试用
|
|
|
-// String test = SignatureEntityTest.build(SignatureType.TOKEN, sessionId, token);
|
|
|
+ String test = SignatureEntityTest.build(SignatureType.TOKEN, sessionId, token);
|
|
|
ExpireTimeBean expireTime = AuthUtil.getExpireTime(platform);
|
|
|
TBSession tbSession = new TBSession(sysUser.getSchoolId(), sessionId, String.valueOf(sysUser.getId()), roleNames.toString(),
|
|
|
platform.name(), platform.name(), deviceId, ServletUtil.getRequest().getLocalAddr(), token,
|
|
@@ -751,8 +754,8 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
tbSessionService.saveOrUpdate(tbSession);
|
|
|
redisUtil.setUserSession(sessionId, tbSession, expireTime.getExpireSeconds());
|
|
|
|
|
|
-// LoginResult loginResult = new LoginResult(sysUser, sessionId, test, roleNames, appSource);
|
|
|
- LoginResult loginResult = new LoginResult(sysUser, sessionId, token, roleNames, appSource);
|
|
|
+ LoginResult loginResult = new LoginResult(sysUser, sessionId, test, Objects.nonNull(roleTypes) && roleTypes.size() > 0 ? roleTypes : roleNames, appSource);
|
|
|
+// LoginResult loginResult = new LoginResult(sysUser, sessionId, token, roleTypes, appSource);
|
|
|
loginResult.setSchoolInfo(Objects.nonNull(authBean.getSchool()) ? loginResult.new SchoolNativeBean(authBean.getSchool()) : null);
|
|
|
loginResult.setOrgInfo(Objects.nonNull(authBean.getOrg()) ? loginResult.new OrgNativeBean(authBean.getOrg()) : null);
|
|
|
loginResult.setTime(System.currentTimeMillis());
|