|
@@ -2,16 +2,12 @@ package com.qmth.teachcloud.common.service.impl;
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.ZipUtil;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
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;
|
|
@@ -30,7 +26,6 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -279,12 +274,13 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
SysOrg org = Objects.nonNull(user.getOrgId()) ? commonCacheService.orgCache(user.getOrgId()) : null;
|
|
|
sysPrivilegeQueryWrapper.lambda().in(SysPrivilege::getId, privilegeIds)
|
|
|
.eq(SysPrivilege::getType, PrivilegeEnum.URL)
|
|
|
- .eq(SysPrivilege::getProperty, PrivilegePropertyEnum.AUTH);
|
|
|
- if (Objects.isNull(tbSchool)) {
|
|
|
- sysPrivilegeQueryWrapper.lambda().isNull(SysPrivilege::getSchoolId);
|
|
|
- } else {
|
|
|
- sysPrivilegeQueryWrapper.lambda().eq(SysPrivilege::getSchoolId, user.getSchoolId());
|
|
|
- }
|
|
|
+ .eq(SysPrivilege::getProperty, PrivilegePropertyEnum.AUTH)
|
|
|
+ .eq(SysPrivilege::getDefaultAuth, true);
|
|
|
+// if (Objects.isNull(tbSchool)) {
|
|
|
+// sysPrivilegeQueryWrapper.lambda().isNull(SysPrivilege::getSchoolId);
|
|
|
+// } else {
|
|
|
+// sysPrivilegeQueryWrapper.lambda().eq(SysPrivilege::getSchoolId, user.getSchoolId());
|
|
|
+// }
|
|
|
List<SysPrivilege> sysPrivilegeList = sysPrivilegeService.list(sysPrivilegeQueryWrapper);
|
|
|
authBean = new AuthBean(sysRoleList, sysPrivilegeList.stream().map(s -> s.getUrl()).collect(Collectors.toSet()), tbSchool, org);
|
|
|
}
|
|
@@ -325,7 +321,8 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
sysPrivilegeQueryWrapper.lambda().eq(SysPrivilege::getType, PrivilegeEnum.URL)
|
|
|
.eq(SysPrivilege::getProperty, privilegePropertyEnum)
|
|
|
.eq(SysPrivilege::getEnable, true)
|
|
|
- .eq(SysPrivilege::getSchoolId, schoolId);
|
|
|
+ .eq(SysPrivilege::getDefaultAuth, true);
|
|
|
+// .eq(SysPrivilege::getSchoolId, schoolId);
|
|
|
List<SysPrivilege> sysPrivilegeList = sysPrivilegeService.list(sysPrivilegeQueryWrapper);
|
|
|
return Objects.nonNull(sysPrivilegeList) && sysPrivilegeList.size() > 0 ? sysPrivilegeList.stream().map(s -> s.getUrl()).collect(Collectors.toSet()) : null;
|
|
|
}
|
|
@@ -333,51 +330,53 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public void addSchoolPrivilege(Set<Long> schoolIdSet) {
|
|
|
- Set<Long> pidSet = sysPrivilegeService.list().stream().map(SysPrivilege::getSchoolId).collect(Collectors.toSet());
|
|
|
- // 权限表里没有该学校主键的
|
|
|
- Set<Long> targetSchoolIdSet = schoolIdSet.stream().filter(e -> !pidSet.contains(e)).collect(Collectors.toSet());
|
|
|
+// Set<Long> pidSet = sysPrivilegeService.list().stream().map(SysPrivilege::getSchoolId).collect(Collectors.toSet());
|
|
|
+// // 权限表里没有该学校主键的
|
|
|
+// Set<Long> targetSchoolIdSet = schoolIdSet.stream().filter(e -> !pidSet.contains(e)).collect(Collectors.toSet());
|
|
|
QueryWrapper<SysPrivilege> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda().eq(SysPrivilege::getSchoolId, SystemConstant.DEFAULT_PRIVILEGE_SCHOOL);
|
|
|
+// queryWrapper.lambda().eq(SysPrivilege::getSchoolId, SystemConstant.DEFAULT_PRIVILEGE_SCHOOL);
|
|
|
+ queryWrapper.lambda().eq(SysPrivilege::getDefaultAuth, true)
|
|
|
+ .eq(SysPrivilege::getEnable, true);
|
|
|
List<SysPrivilege> sysPrivileges = sysPrivilegeService.list(queryWrapper);
|
|
|
if (sysPrivileges.size() == 0) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("默认学校权限不存在");
|
|
|
}
|
|
|
- for (Long newSchoolId : targetSchoolIdSet) {
|
|
|
- // 一个学校一个学校的权限加 如果放在外面的话必须在map的key中关联进学校主键
|
|
|
- Map<Long, Long> map = new HashMap<>();
|
|
|
- List<SysPrivilege> newList = new ArrayList<>();
|
|
|
- BasicSchool basicSchool = basicSchoolService.getById(newSchoolId);
|
|
|
- if (Objects.isNull(basicSchool)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("未找到学校信息");
|
|
|
- }
|
|
|
- for (SysPrivilege sysPrivilege : sysPrivileges) {
|
|
|
- SysPrivilege cell = new SysPrivilege();
|
|
|
- BeanUtils.copyProperties(sysPrivilege,cell);
|
|
|
- Long id = SystemConstant.getDbUuid();
|
|
|
- map.put(cell.getId(), id);
|
|
|
- cell.setId(id);
|
|
|
- cell.setSchoolId(newSchoolId);
|
|
|
- cell.setEnable(basicSchool.getEnable());
|
|
|
- newList.add(cell);
|
|
|
- }
|
|
|
- for (SysPrivilege sysPrivilege : newList) {
|
|
|
- if (Objects.nonNull(sysPrivilege.getParentId())) {
|
|
|
- sysPrivilege.setParentId(map.get(sysPrivilege.getParentId()));
|
|
|
- }
|
|
|
- String relateId = sysPrivilege.getRelated();
|
|
|
- if (StringUtils.isNotBlank(relateId)) {
|
|
|
- String[] relateIds = relateId.split(",");
|
|
|
- List<String> newRelateIds = new ArrayList<>();
|
|
|
- for (String id : relateIds) {
|
|
|
- Long lid = Long.valueOf(id.trim());
|
|
|
- newRelateIds.add(String.valueOf(map.get(lid)));
|
|
|
- }
|
|
|
- String newRelateId = String.join(",", newRelateIds);
|
|
|
- sysPrivilege.setRelated(newRelateId);
|
|
|
- }
|
|
|
- }
|
|
|
- sysPrivilegeService.saveBatch(newList);
|
|
|
- }
|
|
|
+// for (Long newSchoolId : targetSchoolIdSet) {
|
|
|
+// // 一个学校一个学校的权限加 如果放在外面的话必须在map的key中关联进学校主键
|
|
|
+// Map<Long, Long> map = new HashMap<>();
|
|
|
+// List<SysPrivilege> newList = new ArrayList<>();
|
|
|
+// BasicSchool basicSchool = basicSchoolService.getById(newSchoolId);
|
|
|
+// if (Objects.isNull(basicSchool)) {
|
|
|
+// throw ExceptionResultEnum.ERROR.exception("未找到学校信息");
|
|
|
+// }
|
|
|
+// for (SysPrivilege sysPrivilege : sysPrivileges) {
|
|
|
+// SysPrivilege cell = new SysPrivilege();
|
|
|
+// BeanUtils.copyProperties(sysPrivilege, cell);
|
|
|
+// Long id = SystemConstant.getDbUuid();
|
|
|
+// map.put(cell.getId(), id);
|
|
|
+// cell.setId(id);
|
|
|
+// cell.setSchoolId(newSchoolId);
|
|
|
+// cell.setEnable(basicSchool.getEnable());
|
|
|
+// newList.add(cell);
|
|
|
+// }
|
|
|
+// for (SysPrivilege sysPrivilege : newList) {
|
|
|
+// if (Objects.nonNull(sysPrivilege.getParentId())) {
|
|
|
+// sysPrivilege.setParentId(map.get(sysPrivilege.getParentId()));
|
|
|
+// }
|
|
|
+// String relateId = sysPrivilege.getRelated();
|
|
|
+// if (StringUtils.isNotBlank(relateId)) {
|
|
|
+// String[] relateIds = relateId.split(",");
|
|
|
+// List<String> newRelateIds = new ArrayList<>();
|
|
|
+// for (String id : relateIds) {
|
|
|
+// Long lid = Long.valueOf(id.trim());
|
|
|
+// newRelateIds.add(String.valueOf(map.get(lid)));
|
|
|
+// }
|
|
|
+// String newRelateId = String.join(",", newRelateIds);
|
|
|
+// sysPrivilege.setRelated(newRelateId);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// sysPrivilegeService.saveBatch(newList);
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -878,11 +877,11 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
loginResult.setTime(System.currentTimeMillis());
|
|
|
String mobileNumber = sysUser.getMobileNumber();
|
|
|
int pwdCount = sysUser.getPwdCount();
|
|
|
- if (roleTypes.contains(RoleTypeEnum.ADMIN.name())){
|
|
|
+ if (roleTypes.contains(RoleTypeEnum.ADMIN.name())) {
|
|
|
mobileNumber = sysUser.getLoginName() + "(特殊权限)";
|
|
|
pwdCount = 1;
|
|
|
}
|
|
|
- loginResult.setUserLoginCheckResult(new UserLoginCheckResult(sysUser.getId(),mobileNumber,pwdCount));
|
|
|
+ loginResult.setUserLoginCheckResult(new UserLoginCheckResult(sysUser.getId(), mobileNumber, pwdCount));
|
|
|
return loginResult;
|
|
|
}
|
|
|
|