|
@@ -33,6 +33,7 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -92,6 +93,10 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
@Resource
|
|
|
FileStoreUtil fileStoreUtil;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private BasicSchoolService basicSchoolService;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取用户菜单
|
|
|
*
|
|
@@ -304,6 +309,53 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
return Objects.nonNull(sysPrivilegeList) && sysPrivilegeList.size() > 0 ? sysPrivilegeList.stream().map(s -> s.getUrl()).collect(Collectors.toList()) : null;
|
|
|
}
|
|
|
|
|
|
+ @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());
|
|
|
+ QueryWrapper<SysPrivilege> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(SysPrivilege::getSchoolId, SystemConstant.DEFAULT_PRIVILEGE_SCHOOL);
|
|
|
+ List<SysPrivilege> sysPrivileges = sysPrivilegeService.list(queryWrapper);
|
|
|
+ if (sysPrivileges.size() == 0){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("默认学校权限不存在");
|
|
|
+ }
|
|
|
+ Map<Long, Long> map = new HashMap<>();
|
|
|
+ List<SysPrivilege> newList = new ArrayList<>();
|
|
|
+ for (Long newSchoolId : targetSchoolIdSet) {
|
|
|
+ BasicSchool basicSchool = basicSchoolService.getById(newSchoolId);
|
|
|
+ if (Objects.isNull(basicSchool)){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到学校信息");
|
|
|
+ }
|
|
|
+ for (SysPrivilege sysPrivilege : sysPrivileges) {
|
|
|
+ Long id = SystemConstant.getDbUuid();
|
|
|
+ map.put(sysPrivilege.getId(), id);
|
|
|
+ sysPrivilege.setId(id);
|
|
|
+ sysPrivilege.setSchoolId(newSchoolId);
|
|
|
+ sysPrivilege.setEnable(basicSchool.getEnable());
|
|
|
+ newList.add(sysPrivilege);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 删除用户信息
|
|
|
*
|