|
@@ -1,6 +1,5 @@
|
|
package com.qmth.teachcloud.common.service.impl;
|
|
package com.qmth.teachcloud.common.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -8,7 +7,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
-import com.qmth.teachcloud.common.base.BaseEntity;
|
|
|
|
import com.qmth.teachcloud.common.bean.auth.AuthBean;
|
|
import com.qmth.teachcloud.common.bean.auth.AuthBean;
|
|
import com.qmth.teachcloud.common.bean.dto.BlurryUserDto;
|
|
import com.qmth.teachcloud.common.bean.dto.BlurryUserDto;
|
|
import com.qmth.teachcloud.common.bean.dto.LoginDto;
|
|
import com.qmth.teachcloud.common.bean.dto.LoginDto;
|
|
@@ -17,7 +15,6 @@ import com.qmth.teachcloud.common.bean.dto.VerifyCodeCheckDto;
|
|
import com.qmth.teachcloud.common.bean.dto.excel.DescribeImportDto;
|
|
import com.qmth.teachcloud.common.bean.dto.excel.DescribeImportDto;
|
|
import com.qmth.teachcloud.common.bean.dto.excel.SysUserImportDto;
|
|
import com.qmth.teachcloud.common.bean.dto.excel.SysUserImportDto;
|
|
import com.qmth.teachcloud.common.bean.params.ApproveUserResult;
|
|
import com.qmth.teachcloud.common.bean.params.ApproveUserResult;
|
|
-import com.qmth.teachcloud.common.bean.params.UserPushParam;
|
|
|
|
import com.qmth.teachcloud.common.bean.params.UserSaveParams;
|
|
import com.qmth.teachcloud.common.bean.params.UserSaveParams;
|
|
import com.qmth.teachcloud.common.bean.params.UserSaveReportParams;
|
|
import com.qmth.teachcloud.common.bean.params.UserSaveReportParams;
|
|
import com.qmth.teachcloud.common.bean.result.*;
|
|
import com.qmth.teachcloud.common.bean.result.*;
|
|
@@ -27,7 +24,6 @@ import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.entity.*;
|
|
import com.qmth.teachcloud.common.entity.*;
|
|
import com.qmth.teachcloud.common.enums.*;
|
|
import com.qmth.teachcloud.common.enums.*;
|
|
import com.qmth.teachcloud.common.enums.userPush.SpecialPrivilegeEnum;
|
|
import com.qmth.teachcloud.common.enums.userPush.SpecialPrivilegeEnum;
|
|
-import com.qmth.teachcloud.common.enums.userPush.SyncStatusEnum;
|
|
|
|
import com.qmth.teachcloud.common.mapper.SysUserMapper;
|
|
import com.qmth.teachcloud.common.mapper.SysUserMapper;
|
|
import com.qmth.teachcloud.common.service.*;
|
|
import com.qmth.teachcloud.common.service.*;
|
|
import com.qmth.teachcloud.common.sync.CloudMarkingTaskUtils;
|
|
import com.qmth.teachcloud.common.sync.CloudMarkingTaskUtils;
|
|
@@ -97,24 +93,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
@Resource
|
|
@Resource
|
|
TeachcloudCommonService teachcloudCommonService;
|
|
TeachcloudCommonService teachcloudCommonService;
|
|
|
|
|
|
- @Resource
|
|
|
|
- SysPrivilegeService sysPrivilegeService;
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- PushUserErrorService pushUserErrorService;
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- PushUserTrackService pushUserTrackService;
|
|
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
CloudMarkingTaskUtils stmmsUtils;
|
|
CloudMarkingTaskUtils stmmsUtils;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
SysRoleGroupMemberService sysRoleGroupMemberService;
|
|
SysRoleGroupMemberService sysRoleGroupMemberService;
|
|
|
|
|
|
- @Resource
|
|
|
|
- CloudUserPushService cloudUserPushService;
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public IPage<UserDto> list(String loginName, String roleId, Boolean enable, String realName, Integer pageNumber, Integer pageSize) {
|
|
public IPage<UserDto> list(String loginName, String roleId, Boolean enable, String realName, Integer pageNumber, Integer pageSize) {
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
@@ -144,7 +128,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
/**
|
|
/**
|
|
* 保存用户
|
|
* 保存用户
|
|
*
|
|
*
|
|
- * @return
|
|
|
|
|
|
+ * @return 结果
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public boolean saveUserReport(UserSaveReportParams userSaveReportParams) {
|
|
public boolean saveUserReport(UserSaveReportParams userSaveReportParams) {
|
|
@@ -157,7 +141,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
public boolean enable(SysUser user) throws NoSuchAlgorithmException, IllegalAccessException {
|
|
public boolean enable(SysUser user) throws NoSuchAlgorithmException, IllegalAccessException {
|
|
- SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
UpdateWrapper<SysUser> updateWrapper = new UpdateWrapper<>();
|
|
UpdateWrapper<SysUser> updateWrapper = new UpdateWrapper<>();
|
|
updateWrapper.lambda().set(SysUser::getEnable, user.getEnable()).eq(SysUser::getId, user.getId());
|
|
updateWrapper.lambda().set(SysUser::getEnable, user.getEnable()).eq(SysUser::getId, user.getId());
|
|
commonCacheService.updateUserCache(user.getId());
|
|
commonCacheService.updateUserCache(user.getId());
|
|
@@ -166,9 +149,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
if (!user.getEnable()) {
|
|
if (!user.getEnable()) {
|
|
commonService.removeUserInfo(user.getId(), true);
|
|
commonService.removeUserInfo(user.getId(), true);
|
|
}
|
|
}
|
|
- if (success) {
|
|
|
|
- this.analyzeUserEnableSpecialPrivilege(user.getId(), user.getEnable(), requestUser.getId());
|
|
|
|
- }
|
|
|
|
return success;
|
|
return success;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -265,7 +245,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
}
|
|
}
|
|
|
|
|
|
// 登录
|
|
// 登录
|
|
- BasicSchool basicSchool = null;
|
|
|
|
|
|
+ BasicSchool basicSchool;
|
|
String schoolCode = null;
|
|
String schoolCode = null;
|
|
basicSchool = basicSchoolService.getById(sysUser.getSchoolId());
|
|
basicSchool = basicSchoolService.getById(sysUser.getSchoolId());
|
|
if (Objects.isNull(basicSchool)) {
|
|
if (Objects.isNull(basicSchool)) {
|
|
@@ -828,63 +808,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
return sysUserService.count(sysUserQueryWrapper);
|
|
return sysUserService.count(sysUserQueryWrapper);
|
|
}
|
|
}
|
|
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- @Deprecated
|
|
|
|
- public boolean userPushService(List<UserPushParam> userPushParamList, Long requestUserId) throws IllegalAccessException {
|
|
|
|
- SysUser requestUser = this.getById(requestUserId);
|
|
|
|
- if (Objects.isNull(requestUser)) {
|
|
|
|
- log.error("未找到请求用户信息 requestUserId = " + requestUserId);
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("未找到请求用户信息");
|
|
|
|
- }
|
|
|
|
- boolean result = true;
|
|
|
|
- for (UserPushParam userPushParam : userPushParamList) {
|
|
|
|
- boolean syncResult = stmmsUtils.syncUser(userPushParam).getSuccess();
|
|
|
|
- if (!syncResult) {
|
|
|
|
- log.warn("-----------------------------用户同步推送失败----------------------------");
|
|
|
|
- result = false;
|
|
|
|
- PushUserError pushUserError = new PushUserError();
|
|
|
|
- pushUserError.setId(SystemConstant.getDbUuid());
|
|
|
|
- pushUserError.setSchoolId(userPushParam.getSchoolId());
|
|
|
|
- pushUserError.setUserId(userPushParam.getUserId());
|
|
|
|
- pushUserError.setAccount(userPushParam.getAccount());
|
|
|
|
- pushUserError.setName(userPushParam.getName());
|
|
|
|
- pushUserError.setPassword(userPushParam.getPassword());
|
|
|
|
- pushUserError.setEnable(userPushParam.getEnable());
|
|
|
|
- pushUserError.setSubjectCodes(userPushParam.getSubjectCodes());
|
|
|
|
- pushUserError.setRole(userPushParam.getRole());
|
|
|
|
- pushUserError.setCreateId(requestUser.getId());
|
|
|
|
- log.warn(JSON.toJSONString(pushUserError));
|
|
|
|
- pushUserErrorService.save(pushUserError);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- public void autoPushUserErrorData() throws IllegalAccessException {
|
|
|
|
- List<PushUserError> pushUserErrorList = pushUserErrorService.list();
|
|
|
|
- Set<Long> userIdSet = pushUserErrorList.stream().map(PushUserError::getUserId).collect(Collectors.toSet());
|
|
|
|
- if (userIdSet.size() > 0) {
|
|
|
|
- List<SysUser> sysUserList = this.listByIds(userIdSet);
|
|
|
|
- // 清空push-user-error表
|
|
|
|
- pushUserErrorService.remove(new QueryWrapper<PushUserError>().lambda().in(PushUserError::getUserId, userIdSet));
|
|
|
|
- for (SysUser sysUser : sysUserList) {
|
|
|
|
- if (!SyncStatusEnum.NEED_PUSH_AGAIN.equals(sysUser.getSyncStatus())) {
|
|
|
|
- // 用户同步状态不为需要重新同步的错误数据再同步(防止和需要重新同步类型的数据冲突或因为权限改动导致的反复同步!)
|
|
|
|
- Long userId = sysUser.getId();
|
|
|
|
- Set<Long> roleIdSet = sysUserRoleService.listRoleByUserId(userId).stream().map(BaseEntity::getId).collect(Collectors.toSet());
|
|
|
|
-
|
|
|
|
- Long requestUserId = 1L; // 系统管理员
|
|
|
|
- List<PushUserTrack> pushUserTrackList = pushUserTrackService.createPushTrackUser(null, roleIdSet, userId, sysUser.getEnable(), requestUserId);
|
|
|
|
- List<UserPushParam> userPushParamList = pushUserTrackService.analyzeUserPushSpecialPrivilege(pushUserTrackList);
|
|
|
|
- this.userPushService(userPushParamList, requestUserId);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public SpecialPrivilegeEnum findUserSpecialPrivilegeByRoleIdSet(Set<Long> roleIdSet) {
|
|
public SpecialPrivilegeEnum findUserSpecialPrivilegeByRoleIdSet(Set<Long> roleIdSet) {
|
|
SpecialPrivilegeEnum result = SpecialPrivilegeEnum.UNIDENTIFIED;
|
|
SpecialPrivilegeEnum result = SpecialPrivilegeEnum.UNIDENTIFIED;
|
|
@@ -924,43 +847,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
return this.findUserSpecialPrivilegeByRoleIdSet(roleIdSet);
|
|
return this.findUserSpecialPrivilegeByRoleIdSet(roleIdSet);
|
|
}
|
|
}
|
|
|
|
|
|
- @Transactional
|
|
|
|
- @Override
|
|
|
|
- public SyncCountResult needPushAgainOperate(SysUser requestUser) throws IllegalAccessException {
|
|
|
|
- int correctCount = 0;
|
|
|
|
- int totalCount = 0;
|
|
|
|
- if (Objects.isNull(requestUser)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("未找到请求用户");
|
|
|
|
- }
|
|
|
|
- Long schoolId = requestUser.getSchoolId();
|
|
|
|
- Long requestUserId = requestUser.getId();
|
|
|
|
- // 需要同步的用户
|
|
|
|
- QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
|
|
|
|
- queryWrapper.lambda().eq(SysUser::getSyncStatus, SyncStatusEnum.NEED_PUSH_AGAIN);
|
|
|
|
- if (SystemConstant.longNotNull(schoolId)) {
|
|
|
|
- queryWrapper.lambda().eq(SysUser::getSchoolId, schoolId);
|
|
|
|
- }
|
|
|
|
- List<SysUser> sysUserList = sysUserService.list(queryWrapper);
|
|
|
|
- totalCount = sysUserList.size();
|
|
|
|
- for (SysUser user : sysUserList) {
|
|
|
|
- Set<Long> roleIdSet = sysUserRoleService.listRoleByUserId(user.getId()).stream().map(BaseEntity::getId).collect(Collectors.toSet());
|
|
|
|
- List<PushUserTrack> pushUserTrackList = pushUserTrackService.createPushTrackUser(null, roleIdSet, user.getId(), user.getEnable(), requestUserId);
|
|
|
|
- List<UserPushParam> userPushParamList = pushUserTrackService.analyzeUserPushSpecialPrivilege(pushUserTrackList);
|
|
|
|
-
|
|
|
|
- boolean syncResult = sysUserService.userPushService(userPushParamList, requestUserId);
|
|
|
|
- if (syncResult) {
|
|
|
|
- correctCount++;
|
|
|
|
- }
|
|
|
|
- UpdateWrapper<SysUser> updateWrapper = new UpdateWrapper<>();
|
|
|
|
- updateWrapper.lambda().set(SysUser::getSyncStatus, null).eq(SysUser::getId, user.getId());
|
|
|
|
- sysUserService.update(updateWrapper);
|
|
|
|
- }
|
|
|
|
- SyncCountResult syncCountResult = new SyncCountResult();
|
|
|
|
- syncCountResult.setTotalCount(totalCount);
|
|
|
|
- syncCountResult.setCorrectCount(correctCount);
|
|
|
|
- return syncCountResult;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 查找用户角色名
|
|
* 查找用户角色名
|
|
*
|
|
*
|
|
@@ -1181,25 +1067,4 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
}
|
|
}
|
|
return roleIdList;
|
|
return roleIdList;
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 用户禁用启用特殊权限判断及处理
|
|
|
|
- *
|
|
|
|
- * @param userId 用户id
|
|
|
|
- * @param enable 启用/禁用
|
|
|
|
- * @param requestUserId 请求人id
|
|
|
|
- */
|
|
|
|
- @Deprecated
|
|
|
|
- private void analyzeUserEnableSpecialPrivilege(Long userId, boolean enable, Long requestUserId) throws IllegalAccessException {
|
|
|
|
- SysUser dbUser = sysUserService.getById(userId);
|
|
|
|
- if (Objects.isNull(dbUser)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("未找到系统用户");
|
|
|
|
- }
|
|
|
|
- Set<Long> currentRoleIdSet = new HashSet<>(sysRoleService.getUserRoles(userId));
|
|
|
|
- List<PushUserTrack> pushUserTrackList = pushUserTrackService.createPushTrackUser(null, currentRoleIdSet, userId, enable, requestUserId);
|
|
|
|
- List<UserPushParam> userPushParamList = pushUserTrackService.analyzeUserPushSpecialPrivilege(pushUserTrackList);
|
|
|
|
- if (userPushParamList != null && userPushParamList.size() > 0) {
|
|
|
|
- this.userPushService(userPushParamList, requestUserId);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|